The HID architecture

Before writing a HID driver, it's essential to understand the HID architecture. QNX's USB-based HID input architecture is based on the Human Interface Devices (HID) 1.11 specification defined by the USB standards group. This specification defines how HID class drivers should extract data from USB devices. The HID specification expects that a HID-compliant device completely describes its function in the system and gives descriptive information about the data it generates, including:

  • Device type (e.g., joystick, keyboard, mouse).

  • Data reports (input, output, feature).

  • Usage of each bit in the report.

In QNX, the HID input pipeline involves:

  1. USB Stack (io-usb-otg): Handles USB protocol and hardware communication.

  2. HID Manager (io-hid): Manages HID devices and communicates with clients via the libhiddi.so library.

  3. HID Driver: A client application that connects to io-hid to process input reports.

The USB stack (io-usb-otg) implements USB protocol and HCI (Host Controller Interface) drivers. You can read more about the USB stack in the "USB" page of the Customizing a BSP guide. This USB stack is the first component in the input pipeline. It provides input to the HID manager, io-hid. The io-hid manager talks to io-usb-otg with the help of devh-usb.so, the DLL for USB-compliant HID devices. The io-hid manager itself knows nothing of the hardware connected; it simply passes information to and from clients, and to and from the DLLs (like devh-usb.so). Clients of io-hid, this demo for example, communicate with the HID manager using the libhiddi.so library. This library contains all the functions needed to connect to devices and communicate with them.


Writing a new device driver for a HID device involves these basic steps:

  1. Connect to io-hid and recieve a connection handle from io-hid. Check the main() function for details.

  2. Provide io-hid device insertion, removal, and input report callbacks. Refer to the main(), hid_insertion(), hid_removal(), and hid_report() functions.

  3. Send/receive HID reports to/from io-hid. Refer to the hid_report() and handle_joystick() functions.

  4. Notify io-hid when devices are removed. Refer to the hid_removal() function.

The following sections revisit each of these when discussing the implementation details.

Page updated: