Learning USB HID in Linux Part 1 - Basics
What is HID?
HID stands for Human Interface Device. From Wikipedia: "HID is a device used by humans which takes input from humans and gives output to humans"
Examples: Joysticks, Mouse, Keyboard, Barcode Readers, volume controls on speakers/headsets
Why was HID Created?
1. https://en.wikipedia.org/wiki/Human_interface_device
2. https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/introduction-to-hid-concepts
HID stands for Human Interface Device. From Wikipedia: "HID is a device used by humans which takes input from humans and gives output to humans"
Examples: Joysticks, Mouse, Keyboard, Barcode Readers, volume controls on speakers/headsets
Why was HID Created?
- Replacement of PS/2
- Creating interface over USB and to have a generic driver for HID devices like keyboard, mice and game controllers.
- Device: Interacts directly with human such as mouse, keyboard
- Host: Communicates with device and receives input data from the device on actions performed by the human. Output data flows from host to device and then to human
HID was originally defined to use over USB, but now used with other transport layers like
1. Bluetooth HID
2. HID over I2C
3. HOGP (HID over GATT Protocol)
We will be discussing mainly in this series on USB HID.
HID Terminology
Reports:
Communication in HID Happens using "Reports". Reports inform the host that something is happening on the device.
Types:
1. Input Reports: Reports from Device to Host (E.g. mouse movement, keystroke etc)
2. Output Reports: Reports from Host to Device (E.g. Turn on the Caps Lock Led)
3. Feature Reports: Reports related to configuration information
Report Descriptors:
To understand a report from the device, you need to know what each bits/bytes significance. Report descriptor is static (hard coded array of bytes) which informs significance of each bits/bytes.
Report descriptors informs:
- Size of the Report Packet
- How many packets it supports
- Purpose of each byte and bit in each packet
HID Report Descriptor is requested by a USB Host from a USB Device.
Example: Keyboard with calculator program button informs the host that the calculator buttons pressed/release state is stored as the 2nd bit in the 6th byte of the Report
Endpoints:
When a device declares itself as HID, it has to implement the following endpoints:
- Control Endpoint (EP 0)
- Interrupt IN Endpoint
- Interrupt OUT EndPoint (Optional)
Advantages of USB HID:
Enables an application to talk directly with the device without the need of vendor-supplied device drivers.
References:Enables an application to talk directly with the device without the need of vendor-supplied device drivers.
1. https://en.wikipedia.org/wiki/Human_interface_device
2. https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/introduction-to-hid-concepts
Comments
Post a Comment