Split usb_report_descriptor into usb_hid_{item,usage}

This is cleaner IMO.

* usb_hid_item deals with parsing the report descriptor.
* usb_hid_usage has tables that define each usage.
This commit is contained in:
David Hoppenbrouwers
2022-09-09 02:42:00 +02:00
parent 7f6eb97569
commit 2175e1ed74
11 changed files with 121 additions and 122 deletions

19
usb_hid_item/README.md Normal file
View File

@ -0,0 +1,19 @@
# HID report descriptor item parser
## Example
```rs
const QEMU_USB_TABLET: &[u8] = &[
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29,
0x03, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05,
0x81, 0x01, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x00, 0x26, 0xff, 0x7f, 0x35, 0x00,
0x46, 0xff, 0x7f, 0x75, 0x10, 0x95, 0x02, 0x81, 0x02, 0x05, 0x01, 0x09, 0x38, 0x15, 0x81,
0x25, 0x7f, 0x35, 0x00, 0x45, 0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0,
];
dbg!(usb_hid_report_descriptor::parse(QEMU_USB_TABLET).collect::<Vec<_>>());
```
## References
* <https://www.usb.org/sites/default/files/hid1_11.pdf>