hidraw: report only Top-Level Usage_page/Usage pairs as 'unique' devices #601
No reviewers
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi!601
Loading…
Reference in a new issue
No description provided.
Delete branch "hidraw-usage-parse"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
To be consistent with Windows/macOS (OS-level implementations).
Fixes: #298
Fixes: #454
I haven't tested it properly yet, but at least the PR should give an idea what's wrong/what the fix is.@haata I'd appreciate if you could check/review it as the original author of this routine.
This seems to help comparied to git main.
If we ignore the two Windows pseudo HID devices (
path: \\?\HID#ConvertedDevice&xxxxxxx) andAcer Airplane Mode ControllerandPortable Device Control device with path: \\?\HID#INTC816#3&d2322f2&0&0000, this PR seems to be good for the 2.4G Mouse and the track-pad.Please take note that I did not connect the bluetooth mouse to Linux so that one is correct.
Output from Ubuntu 20.04 Linux (not using sudo to print the report descriptors)
Windows 11 output from git main (dual boot laptop, so the devices should be the same).
More detailed Linux output using Ubuntu 23.04, using sudo to dump the report descriptors.
click for the details
06cb cd40is a perfect device to test this change, thanks.Yeap, all looks good.
In general this is an improvements, but the HID standard does not define something like a usage pair. While there must be always a
Usage Pageand aUsagedefined (due to the clause on top of page 25 of the class specification), only the Usage is relevant for the collection.The sole purpose of the
Usage Pageitem is to to conserve space in a report descriptor by setting the high order 16 bits of a subsequent usages. But this is only one variant. The report descriptor can also contain the 'Extended Usage' of 32Bit, in this case, the usage page has no meaning for the collection.Example:
The same meaning for the collection with extended 32Bit Usage:
And you could also do this - than the
Usage Pageitem influences only the second collection:To implement this correct, the Usage Page should only be use in
github.com/libusb/hidapi@78c6adec7c/linux/hid.c (L361-L364)here the 32 Bit extended usage value has to be defined. Depending on the size of the
Usage0, 1, 2, or 4 Bytes of the Usage Page value have to be used to fill the missing bytes of the 32Bit usage value, which defines the nature of the following collection.I think this looks good.
@mcuee do you know if that device is HID compliant? You can only run this on windows, but https://www.usb.org/compliancetools has USB3CV (that's usually what you want). The hid test can be quite useful in this case.
@ -271,6 +271,60 @@ static __u32 get_hid_report_bytes(__u8 *rpt, size_t len, size_t num_bytes, size_return 0;found -> find
The device
06cb:cd40is not a USB HID device, but rather I2C-HID (touch pad).@ -271,6 +271,60 @@ static __u32 get_hid_report_bytes(__u8 *rpt, size_t len, size_t num_bytes, size_return 0;Thanks @JoergAtGithub.
To support this case I'd need to have access to at least one device that implements 32-bit usage in the descriptor. I'll keep a support of that to #454 for now.
I suspected something like that might be the case but wasn't sure. I'll try to implement that case as part of this PR.
@JoergAtGithub
Do you have such a device with 32bit usage? Would you please post the HID Report Descriptor of that device? I will see if I can find one or change my test device to have that.
Oh, we could craft/change any descriptor for that.
It was easier than I thought.
Sorry for the delay. Looks good!
If any issues - will fix those later in master