-
Notifications
You must be signed in to change notification settings - Fork 1.7k
USB: HID Report Descriptor
hasu@tmk edited this page Dec 2, 2020
·
40 revisions
See this page.
https://github.com/tmk/tmk_keyboard/wiki/USB-Descriptor
http://www.slashdev.ca/2010/05/08/get-usb-report-descriptor-with-linux/
Find vendor id of device interested(046d)
$ lsusb
...
Bus 002 Device 007: ID 046d:c01d Logitech, Inc. MX510 Optical Mouse
...
Find device path from dmesg output(2-2.4:1.0)
$ dmesg | grep -i 046d | grep devices | tail -5
Aug 12 09:15:55 desk kernel: [166377.779960] input: Logitech USB-PS/2 Optical Mouse as /devices/pci0000:00/0000:00:04.1/usb2/2-2/2-2.4/2-2.4:1.0/0003:046D:C01D.0067/input/input106
Unbind the device and it stops working
$ echo -n 2-2.4:1.0 | sudo tee /sys/bus/usb/drivers/usbhid/unbind
Dump report descriptor with lsusb
$ sudo lsusb -d046d: -v
...
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 77
Report Descriptor: (length is 77)
Item(Global): Usage Page, data= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage, data= [ 0x02 ] 2
Mouse
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Local ): Usage, data= [ 0x01 ] 1
Pointer
Item(Main ): Collection, data= [ 0x00 ] 0
Physical
Item(Global): Usage Page, data= [ 0x09 ] 9
Buttons
...
Bind the deivce and it starts working again
$ echo -n 2-2.4:1.0 | sudo tee /sys/bus/usb/drivers/usbhid/bind
Dump descriptor and parse it like this.
$ sudo usbhid-dump -d046d -i255
001:005:000:DESCRIPTOR 1468982571.405056
05 01 09 02 A1 01 09 01 A1 00 05 09 19 01 29 08
15 00 25 01 95 08 75 01 81 02 95 00 81 03 06 00
FF 09 40 95 02 75 08 15 81 25 7F 81 02 05 01 09
38 15 81 25 7F 75 08 95 01 81 06 09 30 09 31 16
01 F8 26 FF 07 75 0C 95 02 81 06 C0 C0
$ sudo usbhid-dump -d046d -i255 |grep -v : | xxd -r -p | hidrd-convert -o spec
Usage Page (Desktop), ; Generic desktop controls (01h)
Usage (Mouse), ; Mouse (02h, application collection)
Collection (Application),
Usage (Pointer), ; Pointer (01h, physical collection)
Collection (Physical),
Usage Page (Button), ; Button (09h)
Usage Minimum (01h),
Usage Maximum (08h),
Logical Minimum (0),
Logical Maximum (1),
Report Count (8),
Report Size (1),
Input (Variable),
Report Count (0),
Input (Constant, Variable),
Usage Page (FF00h), ; FF00h, vendor-defined
Usage (40h),
Report Count (2),
...
$ git clone https://github.com/DIGImend/hidrd.git
$ git clone https://github.com/DIGImend/usbhid-dump.git
$ cd hidrd # or usbhid-dump
$ autoreconf --force --install
$ ./configure
$ make
$ sudo usbhid-dump -d 046d -i255 | grep -v : | xxd -r -p | hidrd-convert -o spec
Usage Page (Desktop), ; Generic desktop controls (01h)
Usage (Mouse), ; Mouse (02h, application collection)
Collection (Application),
Usage (Pointer), ; Pointer (01h, physical collection)
Collection (Physical),
Usage Page (Button), ; Button (09h)
Usage Minimum (01h),
Usage Maximum (08h),
Logical Minimum (0),
Logical Maximum (1),
Report Count (8),
Report Size (1),
Input (Variable),
Report Count (0),
Input (Constant, Variable),
Usage Page (FF00h), ; FF00h, vendor-defined
Usage (40h),
Report Count (2),
Report Size (8),
Logical Minimum (-127),
Logical Maximum (127),
Input (Variable),
Usage Page (Desktop), ; Generic desktop controls (01h)
Usage (Wheel), ; Wheel (38h, dynamic value)
Logical Minimum (-127),
Logical Maximum (127),
Report Size (8),
Report Count (1),
Input (Variable, Relative),
Usage (X), ; X (30h, dynamic value)
Usage (Y), ; Y (31h, dynamic value)
Logical Minimum (-2047),
Logical Maximum (2047),
Report Size (12),
Report Count (2),
Input (Variable, Relative),
End Collection,
End Collection
https://gist.github.com/tmk/0626b78f73575d5c1efa86470c4cdb18
https://github.com/tmk/tmk_keyboard/issues/606
https://gist.github.com/tmk/5e29450724fc30d06681212b0e9b5056
https://gist.github.com/tmk/8e8e6185af93e4e3ccd2660684f9cf7c