36#define USB_TYPE_DESCRIPTOR_HID 0x21
41#define USB_HID_VERSION_BCD 0x0110
47#define USB_HID_SUBCLASS_NONE 0x0
48#define USB_HID_SUBCLASS_BOOT 0x1
55#define USB_HID_PROTOCOL_NONE 0x0
56#define USB_HID_PROTOCOL_KEYBOARD 0x1
57#define USB_HID_PROTOCOL_MOUSE 0x2
64#define USB_HID_DESCR_HID 0x21
65#define USB_HID_DESCR_REPORT 0x22
66#define USB_HID_DESCR_PHYSICAL 0x23
72#define USB_HID_COUNTRY_CODE_NOTSUPPORTED 0x00
78#define USB_HID_REQUEST_GET_REPORT 0x01
79#define USB_HID_REQUEST_GET_IDLE 0x02
80#define USB_HID_REQUEST_GET_PROTOCOL 0x03
81#define USB_HID_REQUEST_SET_REPORT 0x09
82#define USB_HID_REQUEST_SET_IDLE 0x0a
83#define USB_HID_REQUEST_SET_PROTOCOL 0x0b
89#define USBUS_HID_EP_IN_REQUIRED_NUMOF 1
94#define USBUS_HID_EP_OUT_REQUIRED_NUMOF 1
101typedef struct __attribute__((packed)){
130#define USB_HID_ITEM_TYPE_MAIN 0x0
135#define USB_HID_ITEM_TYPE_GLOBAL 0x1
140#define USB_HID_ITEM_TYPE_LOCAL 0x2
145#define USB_HID_ITEM_TAG_INPUT 0x8
150#define USB_HID_ITEM_TAG_OUTPUT 0x9
155#define USB_HID_ITEM_TAG_COLLECTION 0xA
160#define USB_HID_ITEM_TAG_FEATURE 0xB
165#define USB_HID_ITEM_TAG_COLLECTION_END 0xC
170#define USB_HID_ITEM_TAG_USAGE_PAGE 0x0
174#define USB_HID_ITEM_TAG_LOGICAL_MIN 0x1
179#define USB_HID_ITEM_TAG_LOGICAL_MAX 0x2
184#define USB_HID_ITEM_TAG_PHYSICAL_MIN 0x3
189#define USB_HID_ITEM_TAG_PHYSICAL_MAX 0x4
194#define USB_HID_ITEM_TAG_UNIT_EXPONENT 0x5
199#define USB_HID_ITEM_TAG_UNIT 0x6
204#define USB_HID_ITEM_TAG_REPORT_SIZE 0x7
209#define USB_HID_ITEM_TAG_REPORT_ID 0x8
214#define USB_HID_ITEM_TAG_REPORT_COUNT 0x9
219#define USB_HID_ITEM_TAG_USAGE 0x0
224#define USB_HID_ITEM_TAG_USAGE_MIN 0x1
229#define USB_HID_ITEM_TAG_USAGE_MAX 0x2
234#define USB_HID_COLLECTION_PHYSICAL 0x00
239#define USB_HID_COLLECTION_APPLICATION 0x01
244#define USB_HID_COLLECTION_LOGICAL 0x02
249#define USB_HID_COLLECTION_REPORT 0x03
254#define USB_HID_COLLECTION_NAMED_ARRAY 0x04
259#define USB_HID_COLLECTION_USAGE_SWITCH 0x05
264#define USB_HID_COLLECTION_USAGE_MOD 0x06
273#define USB_HID_ITEM(tag, type, size) \
274 (((tag & 0xF) << 4) | ((type & 0x3) << 2) | (size & 0x3))
283#define USB_HID_INPUT(input) \
284 USB_HID_ITEM(USB_HID_ITEM_TAG_INPUT, USB_HID_ITEM_TYPE_MAIN, 1), \
294#define USB_HID_OUTPUT(output) \
295 USB_HID_ITEM(USB_HID_ITEM_TAG_OUTPUT, USB_HID_ITEM_TYPE_MAIN, 1), \
306#define USB_HID_FEATURE(feature) \
307 USB_HID_ITEM(USB_HID_ITEM_TAG_FEATURE, USB_HID_ITEM_TYPE_MAIN, 1), \
317#define USB_HID_COLLECTION(collection) \
318 USB_HID_ITEM(USB_HID_ITEM_TAG_COLLECTION, USB_HID_ITEM_TYPE_MAIN, 1), \
324#define USB_HID_END_COLLECTION \
325 USB_HID_ITEM(USB_HID_ITEM_TAG_COLLECTION_END, USB_HID_ITEM_TYPE_MAIN, 0)
334#define USB_HID_USAGE_PAGE(page) \
335 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_PAGE, USB_HID_ITEM_TYPE_GLOBAL, 1), \
345#define USB_HID_USAGE_PAGE16(page) \
346 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_PAGE, USB_HID_ITEM_TYPE_GLOBAL, 2), \
347 page & 0xff, (page >> 8)
356#define USB_HID_LOGICAL_MIN8(minimum) \
357 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MIN, USB_HID_ITEM_TYPE_GLOBAL, 1), \
367#define USB_HID_LOGICAL_MIN16(minimum) \
368 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MIN, USB_HID_ITEM_TYPE_GLOBAL, 2), \
369 minimum & 0xff, (minimum >> 8)
379#define USB_HID_LOGICAL_MIN32(minimum) \
380 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MIN, USB_HID_ITEM_TYPE_GLOBAL, 3), \
382 (minimum >> 8) & 0xff, \
383 (minimum >> 16) & 0xff, \
384 (minimum >> 24) & 0xff
393#define USB_HID_LOGICAL_MAX8(maximum) \
394 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MAX, USB_HID_ITEM_TYPE_GLOBAL, 1), \
404#define USB_HID_LOGICAL_MAX16(maximum) \
405 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MAX, USB_HID_ITEM_TYPE_GLOBAL, 2), \
406 (maximum & 0xff), (maximum >> 8)
415#define USB_HID_LOGICAL_MAX32(maximum) \
416 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MAX, USB_HID_ITEM_TYPE_GLOBAL, 3), \
418 (maximum >> 8) & 0xff, \
419 (maximum >> 16) & 0xff, \
420 (maximum >> 24) & 0xff
429#define USB_HID_REPORT_SIZE(size) \
430 USB_HID_ITEM(USB_HID_ITEM_TAG_REPORT_SIZE, USB_HID_ITEM_TYPE_GLOBAL, 1), \
440#define USB_HID_REPORT_ID(id) \
441 USB_HID_ITEM(USB_HID_ITEM_TAG_REPORT_ID, USB_HID_ITEM_TYPE_GLOBAL, 1), \
451#define USB_HID_REPORT_COUNT(count) \
452 USB_HID_ITEM(USB_HID_ITEM_TAG_REPORT_COUNT, USB_HID_ITEM_TYPE_GLOBAL, 1), \
462#define USB_HID_USAGE(index) \
463 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE, USB_HID_ITEM_TYPE_LOCAL, 1), \
473#define USB_HID_USAGE_MIN8(start) \
474 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_MIN, USB_HID_ITEM_TYPE_LOCAL, 1), \
484#define USB_HID_USAGE_MIN16(start) \
485 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_MIN, USB_HID_ITEM_TYPE_LOCAL, 2), \
486 start & 0xff, (start >> 8) & 0xff
495#define USB_HID_USAGE_MAX8(end) \
496 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_MAX, USB_HID_ITEM_TYPE_LOCAL, 1), \
506#define USB_HID_USAGE_MAX16(end) \
507 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_MAX, USB_HID_ITEM_TYPE_LOCAL, 2), \
508 end & 0xff, (end >> 8) & 0xff
Definition for USB HID usage tables.
USB HID descriptor struct.
uint8_t report_type
Type of HID class report.
uint8_t country_code
Numeric expression identifying country code of the localized hardware.
uint16_t report_length
the total size of the Report descriptor.
uint8_t desc_type
Constant name specifying type of HID descriptor.
uint8_t length
Numeric expression that is the total size of the HID descriptor.
uint16_t bcd_hid
Numeric expression identifying the HID Class Specification release.
uint8_t num_descrs
Numeric expression specifying the number of class descriptors.