Usages
USB HID devices and their components can be given a Usage code. The Usage code is an optional suggestion to the application on what the control is to be used for.
A usage code is broken up into two parts: the Usage Page and the Usage. Both are 16-bit numbers (0-65535). Any values can be used, but there are a set of defined values.
The Usage Page is used to group usages. A set of Usage Pages has been defined by the USB group. These are listed below...
GENERIC_DESKTOP_CONTROLS | 0x01 |
SIMULATION_CONTROLS | 0x02 |
VR_CONTROLS | 0x03 |
SPORT_CONTROLS | 0x04 |
GAME_CONTROLS | 0x05 |
GENERIC_DEVICE_CONTROLS | 0x06 |
KEYBOARD_KEYPAD | 0x07 |
LEDS | 0x08 |
BUTTON | 0x09 |
ORDINAL | 0x0A |
TELEPHONY | 0x0B |
CONSUMER | 0x0C |
DIGITIZER | 0x0D |
PID_PAGE | 0x0F |
UNICODE | 0x10 |
ALPHANUMERIC_DISPLAY | 0x14 |
MEDICAL_INSTRUMENTS | 0x40 |
MONITOR_PAGES | 0x83 |
POWER_PAGES | 0x87 |
BAR_CODE_SCANNER_PAGE | 0x8C |
SCALE_PAGE | 0x8D |
MAGNETIC_STRIPE_READING_DEVICES | 0x8E |
CAMERA_CONTROL_PAGE | 0x90 |
ARCADE_PAGE | 0x91 |
VENDOR_DEFINED | 0xFF00 |
Each Usage Page has a collection of Usages. For example, these are Usages for the Usage Page GENERIC_DESKTOP_CONTROLS.
POINTER | 0x01 |
MOUSE | 0x02 |
JOYSTICK | 0x04 |
GAME PAD | 0x05 |
KEYBOARD | 0x06 |
KEYPAD | 0x07 |
X | 0x30 |
Y | 0x31 |
Z | 0x32 |
RX | 0x33 |
RY | 0x34 |
RZ | 0x35 |
SLIDER | 0x36 |
DIAL | 0x37 |
WHEEL | 0x38 |
HATSWITCH | 0x39 |
START | 0x3D |
SELECT | 0x3E |
DPAD_UP | 0x90 |
DPAD_DOWN | 0x91 |
DPAD_RIGHT | 0x92 |
DPAD_LEFT | 0x93 |
Generally, it is not important what the Usage Page and Usage are, however there are some exceptions...
- LCD display modules must have a Usage of ALPHANUMERIC_DISPLAY:ALPHANUMERIC_DISPLAY otherwise it will not be identified as a display device. Generic HID will not let this be changed.
- A directional switch/hat switch must be called GENERIC_DESKTOP_CONTROLS:HATSWITCH otherwise the values will not be reinterpreted as a directional angle.
- To get Windows and other operating systems to recognise the device as a joystick or game pad, it must be called GENERIC_DESKTOP_CONTROLS:JOYSTICK or GENERIC_DESKTOP_CONTROLS:GAMEPAD. Windows will also typically want the usage of an axis set X, Y, Z, etc.
- Avoid using GENERIC_DESKTOP_CONTROLS:MOUSE or GENERIC_DESKTOP_CONTROLS:POINTER as the usage for a device. The operating system will take control of the device and interpret actions as mouse moves and button presses.
The property field for the Usage is displayed as the Usage Page and the Usage. These are two drop down lists that contain the standard Usage Pages and Usages as shown below.
It is not necessary to use one of the predefined values. A user defined
number may be entered. This is required on some usage pages like LED.