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.


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



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



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'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.

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.

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState