The Linux USB Input Subsystem, Part I

As the USB input subsystem spreads further with each kernel release, it's time to understand what it's doing for your devices.
Handlers—Getting to User Space

In the previous section, we saw that the device drivers basically sat between the hardware and the input core, translating hardware events, usually interrupts, into input events. To make use of those input events, we use handlers, which provide a user-space interface.

The input subsystem includes most of the handlers you'll likely need: a keyboard handler to provide a console, a mouse handler for applications like the X Window System, a joystick handler for games and also a touchscreen handler. There is also a general-purpose handler called the event handler, which basically provides input events to user space. This means you almost never need to write a handler in the kernel, because you can do the same thing with the event handler and equivalent code in user space. This API discussion is covered in the second part of this article.

Acknowledgements

I'd like to thank Greg Kroah-Hartman and Vojtech Pavlik for their assistance with this article.

Resources

email: bhards@bigpond.net.au

Brad Hards is the technical director for Sigma Bravo, a small professional services company in Canberra. In addition to Linux, his technical focus includes aircraft system integration and certification, GPS and electronic warfare. Comments on this article can be sent to bradh@frogmouth.net.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Capture User Drawing

sfog's picture

Hello all,

My name is sony, and now i want to learn about Linux USB Input Driver.
i read this article and wondering if you can help me to understand about my question.

here is the question:

I have pen tablet (genius), and i want to develop the new driver for it.
But before i do that, i use current driver (library) and try something with it.
I want to capture the position (x,y) when the user draw something on the pad using stylus.

What i get is the position of the pen touch, but i can't get the other position until the user release the stylus.

I was wondering if you can tell me how i capture the pen drawing (lets say signature) though the driver,
or the other hand, is how to get the whole position when the user try to draw something on the pad (not the pen over).

Hope you can help me...

Thank you.....

Need more clarity how the keystores moving from keyboard to cons

Anonymous's picture

ur article is really good.i got some picture abt how keyboard is working ,can u please explain the same in to more clarity on how the keystrokes are moved from each subsystems.

ex : typing "S" in keyboard (h/w)----> how this data will move to "usbsubsystem" (usbstack - like (hid-input.o + hidcore.o=hid.o,usbkbd.o) -----> how usb data is translated/given to input subsystem---> from "input subsystem" to "console subsystem" -------> and from console to how it reaches "tty subsystem"

thanks a lot

Listing 3. aaaabbbb.c

MADNI's picture

Hi, Will you please guide me to run Listing 3. aaaabbbb.c

Also is it posiable to modify joystick pointer position by this examples

Many Thanks,

madni

LOOKING FOR PART II

MADNI's picture

Hi I am looking for part 2
where the event handler and equivalent code in user space. The API discussion is covered in the second part of this article.
Thanks

Slightly Different Name

Mitch Frazier's picture

It's called Using the Input Subsystem, Part II

Mitch Frazier is an Associate Editor for Linux Journal.

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Webcast
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
On Demand
Moderated by Linux Journal Contributor Mike Diehl

Sign up now

Sponsored by Skybot