Closed Joop-Schilder closed 1 year ago
The change looks good, I have only one minor wish: can you change the "first nibble" phrasing to "high nibble" (in the comment and in the commit message)? That makes it clearer, first nibble is more up to interpretation, especially in LSB vs MSB first context.
I changed the phrasing. You are right, "first" is a bit ambiguous.
Thank you for your contribution! Looking forward to more :)
HidSharp assumes the high nibble in a unit exponent field is meaningful, while the HID Usage Tables 1.3 defines the unit exponent as a 4-bit value (Exponent 0 through F, page 302 / 303). Report Descriptors only support values in multitudes of 8 bits, so the first 4 bits are padding / meaningless. This means we should ignore the high nibble when decoding the report descriptor and not make any assumptions about its meaning.
There are some devices which define the unit exponent as 0xF0 through 0xFF. Reconstructing the report descriptor fails on these devices.
See the definition in https://www.usb.org/sites/default/files/hut1_3_0.pdf (page 302).
This is how the Linux kernel does it as well: https://github.com/torvalds/linux/blob/master/drivers/hid/hid-core.c#L422