usbd-hid
usbd-hid copied to clipboard
Win10 compatibility.
There seems to be some compatibility issue with Win10 and the generated descriptor(s).
#[gen_hid_descriptor(
(collection = APPLICATION, usage = 0x01, usage_page = 0xff00) = {
#[item_settings data] data=input;
}
)]
#[allow(dead_code)]
struct Data {
data: u8,
}
The generated descriptor looks like this.
data [
0x6, 0x0, 0xff, // USEGE PAGE Vendor
0x9, 0x1, // USAGE Vendor
0xa1, 0x1, // Collection (Application)
0x15, 0x0, // Logical minimum
0x26, 0xff, 0x0, // Logical maximum
0x75, 0x8, // Report size 8
0x95, 0x1, // Report count 1
0x81, 0x0, // Input
0xc0, // End application collection
]
This works well under Linux (tested under arch) and OSX. Hower under Win10 the device is not properly detected/configured (USB Device Viewer
shows the descriptors correctly but claims the devic to be in low power state.
Adding a usage
before Input
solves the issue.
data [
0x6, 0x0, 0xff, // USEGE PAGE Vendor
0x9, 0x1, // USAGE Vendor
0xa1, 0x1, // Collection (Application)
0x15, 0x0, // Logical minimum
0x26, 0xff, 0x0, // Logical maximum
0x75, 0x8, // Report size 8
0x95, 0x1, // Report count 1
0x09, 0x01, // USAGE Vendor <---- manually added here
0x81, 0x0, // Input
0xc0, // End application collection
]
Either MS is out of specs (the wrapping usage should be inherited) or Linux/OSX just playing nice guessing, not sure.
Maybe there is already some workaround for this problem that I missed. If not, perhaps a syntax extension to the #[item_settings usage = 0x01, ...]
would be possible. Or maybe let the proc macro always emit inherited usage
from the wrapping collection (in this case).
Admittedly I'm a USB novice, so not sure what's best here. /Per