32 #define USB_TYPE_DESCRIPTOR_HID 0x21
37 #define USB_HID_VERSION_BCD 0x0110
43 #define USB_HID_SUBCLASS_NONE 0x0
44 #define USB_HID_SUBCLASS_BOOT 0x1
51 #define USB_HID_PROTOCOL_NONE 0x0
52 #define USB_HID_PROTOCOL_KEYBOARD 0x1
53 #define USB_HID_PROTOCOL_MOUSE 0x2
60 #define USB_HID_DESCR_HID 0x21
61 #define USB_HID_DESCR_REPORT 0x22
62 #define USB_HID_DESCR_PHYSICAL 0x23
68 #define USB_HID_COUNTRY_CODE_NOTSUPPORTED 0x00
74 #define USB_HID_REQUEST_GET_REPORT 0x01
75 #define USB_HID_REQUEST_GET_IDLE 0x02
76 #define USB_HID_REQUEST_GET_PROTOCOL 0x03
77 #define USB_HID_REQUEST_SET_REPORT 0x09
78 #define USB_HID_REQUEST_SET_IDLE 0x0a
79 #define USB_HID_REQUEST_SET_PROTOCOL 0x0b
85 #define USBUS_HID_EP_IN_REQUIRED_NUMOF 1
90 #define USBUS_HID_EP_OUT_REQUIRED_NUMOF 1
97 typedef struct __attribute__((packed)){
125 #define USB_HID_ITEM_TYPE_MAIN 0x0
130 #define USB_HID_ITEM_TYPE_GLOBAL 0x1
135 #define USB_HID_ITEM_TYPE_LOCAL 0x2
140 #define USB_HID_ITEM_TAG_INPUT 0x8
145 #define USB_HID_ITEM_TAG_OUTPUT 0x9
150 #define USB_HID_ITEM_TAG_COLLECTION 0xA
155 #define USB_HID_ITEM_TAG_FEATURE 0xB
160 #define USB_HID_ITEM_TAG_COLLECTION_END 0xC
165 #define USB_HID_ITEM_TAG_USAGE_PAGE 0x0
169 #define USB_HID_ITEM_TAG_LOGICAL_MIN 0x1
174 #define USB_HID_ITEM_TAG_LOGICAL_MAX 0x2
179 #define USB_HID_ITEM_TAG_PHYSICAL_MIN 0x3
184 #define USB_HID_ITEM_TAG_PHYSICAL_MAX 0x4
189 #define USB_HID_ITEM_TAG_UNIT_EXPONENT 0x5
194 #define USB_HID_ITEM_TAG_UNIT 0x6
199 #define USB_HID_ITEM_TAG_REPORT_SIZE 0x7
204 #define USB_HID_ITEM_TAG_REPORT_ID 0x8
209 #define USB_HID_ITEM_TAG_REPORT_COUNT 0x9
214 #define USB_HID_ITEM_TAG_USAGE 0x0
219 #define USB_HID_ITEM_TAG_USAGE_MIN 0x1
224 #define USB_HID_ITEM_TAG_USAGE_MAX 0x2
229 #define USB_HID_COLLECTION_PHYSICAL 0x00
234 #define USB_HID_COLLECTION_APPLICATION 0x01
239 #define USB_HID_COLLECTION_LOGICAL 0x02
244 #define USB_HID_COLLECTION_REPORT 0x03
249 #define USB_HID_COLLECTION_NAMED_ARRAY 0x04
254 #define USB_HID_COLLECTION_USAGE_SWITCH 0x05
259 #define USB_HID_COLLECTION_USAGE_MOD 0x06
268 #define USB_HID_ITEM(tag, type, size) \
269 (((tag & 0xF) << 4) | ((type & 0x3) << 2) | (size & 0x3))
278 #define USB_HID_INPUT(input) \
279 USB_HID_ITEM(USB_HID_ITEM_TAG_INPUT, USB_HID_ITEM_TYPE_MAIN, 1), \
289 #define USB_HID_OUTPUT(output) \
290 USB_HID_ITEM(USB_HID_ITEM_TAG_OUTPUT, USB_HID_ITEM_TYPE_MAIN, 1), \
300 #define USB_HID_FEATURE(feature) \
301 USB_HID_ITEM(USB_HID_ITEM_TAG_FEATURE, USB_HID_ITEM_TYPE_MAIN, 1), \
311 #define USB_HID_COLLECTION(collection) \
312 USB_HID_ITEM(USB_HID_ITEM_TAG_COLLECTION, USB_HID_ITEM_TYPE_MAIN, 1), \
318 #define USB_HID_END_COLLECTION \
319 USB_HID_ITEM(USB_HID_ITEM_TAG_COLLECTION_END, USB_HID_ITEM_TYPE_MAIN, 0)
328 #define USB_HID_USAGE_PAGE(page) \
329 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_PAGE, USB_HID_ITEM_TYPE_GLOBAL, 1), \
339 #define USB_HID_USAGE_PAGE16(page) \
340 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_PAGE, USB_HID_ITEM_TYPE_GLOBAL, 2), \
341 page & 0xff, (page >> 8)
350 #define USB_HID_LOGICAL_MIN8(minimum) \
351 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MIN, USB_HID_ITEM_TYPE_GLOBAL, 1), \
361 #define USB_HID_LOGICAL_MIN16(minimum) \
362 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MIN, USB_HID_ITEM_TYPE_GLOBAL, 2), \
363 minimum & 0xff, (minimum >> 8)
372 #define USB_HID_LOGICAL_MIN32(minimum) \
373 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MIN, USB_HID_ITEM_TYPE_GLOBAL, 3), \
375 (minimum >> 8) & 0xff, \
376 (minimum >> 16) & 0xff, \
377 (minimum >> 24) & 0xff
386 #define USB_HID_LOGICAL_MAX8(maximum) \
387 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MAX, USB_HID_ITEM_TYPE_GLOBAL, 1), \
397 #define USB_HID_LOGICAL_MAX16(maximum) \
398 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MAX, USB_HID_ITEM_TYPE_GLOBAL, 2), \
399 (maximum & 0xff), (maximum >> 8)
408 #define USB_HID_LOGICAL_MAX32(maximum) \
409 USB_HID_ITEM(USB_HID_ITEM_TAG_LOGICAL_MAX, USB_HID_ITEM_TYPE_GLOBAL, 3), \
411 (maximum >> 8) & 0xff, \
412 (maximum >> 16) & 0xff, \
413 (maximum >> 24) & 0xff
422 #define USB_HID_REPORT_SIZE(size) \
423 USB_HID_ITEM(USB_HID_ITEM_TAG_REPORT_SIZE, USB_HID_ITEM_TYPE_GLOBAL, 1), \
433 #define USB_HID_REPORT_ID(id) \
434 USB_HID_ITEM(USB_HID_ITEM_TAG_REPORT_ID, USB_HID_ITEM_TYPE_GLOBAL, 1), \
444 #define USB_HID_REPORT_COUNT(count) \
445 USB_HID_ITEM(USB_HID_ITEM_TAG_REPORT_COUNT, USB_HID_ITEM_TYPE_GLOBAL, 1), \
455 #define USB_HID_USAGE(index) \
456 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE, USB_HID_ITEM_TYPE_LOCAL, 1), \
466 #define USB_HID_USAGE_MIN8(start) \
467 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_MIN, USB_HID_ITEM_TYPE_LOCAL, 1), \
477 #define USB_HID_USAGE_MIN16(start) \
478 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_MIN, USB_HID_ITEM_TYPE_LOCAL, 2), \
479 start & 0xff, (start >> 8) & 0xff
488 #define USB_HID_USAGE_MAX8(end) \
489 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_MAX, USB_HID_ITEM_TYPE_LOCAL, 1), \
499 #define USB_HID_USAGE_MAX16(end) \
500 USB_HID_ITEM(USB_HID_ITEM_TAG_USAGE_MAX, USB_HID_ITEM_TYPE_LOCAL, 2), \
501 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.