HID device selection in Windows relied on specific "ColXX" values appearing in device paths. This proved to be unreliable because different keyboards have different HID report structures and thus would cause the ISP report-capable device to appear under a different path than expected.
Changes here drop the hardcoded approach and attempt to filter out ISP-capable devices by expected usage_page & usage values. Unfortunately, some devices like the nuphy-air60 have multiple collections in their HID report descriptor with the usage_page == 0xff00 && usage == 0x0001 and thus it was necessary to introduce an isp_index value to tell which device is capable of receiving the ISP report. (Ideally, the whole HID report would be accessible so that one could pinpoint exactly which collection has the ISP report definition)
This issue only affected windows, because macos and linux (libusb) allow sending the report to any HID device that is part of the same USB device.
The current and latest hidapi-rs library does not expose usage & usage_page values when using the libusb backend, but from what I can tell support in libusb has already been implemented, perhaps I should explore whether support could be enabled and remove some of the #[cfg(...)] macros littering the codebase, but for now it's not absolutely necessary since this still works.
Side-note: I have attempted to use the hidraw backend, but the ISP device is not recognized as a USBHID device because it has no interrupt endpoint.
Idea: I guess it could also be possible to enumerate through all ColXX devices on windows, try sending the 0x05 report to each and see which one will accept it (not error out).
HID device selection in Windows relied on specific "ColXX" values appearing in device paths. This proved to be unreliable because different keyboards have different HID report structures and thus would cause the ISP report-capable device to appear under a different path than expected.
Changes here drop the hardcoded approach and attempt to filter out ISP-capable devices by expected
usage_page
&usage
values. Unfortunately, some devices like the nuphy-air60 have multiple collections in their HID report descriptor with theusage_page == 0xff00 && usage == 0x0001
and thus it was necessary to introduce anisp_index
value to tell which device is capable of receiving the ISP report. (Ideally, the whole HID report would be accessible so that one could pinpoint exactly which collection has the ISP report definition)This issue only affected windows, because macos and linux (libusb) allow sending the report to any HID device that is part of the same USB device.
The current and latest hidapi-rs library does not expose usage & usage_page values when using the libusb backend, but from what I can tell support in libusb has already been implemented, perhaps I should explore whether support could be enabled and remove some of the
#[cfg(...)]
macros littering the codebase, but for now it's not absolutely necessary since this still works.Side-note: I have attempted to use the hidraw backend, but the ISP device is not recognized as a USBHID device because it has no interrupt endpoint.
Addresses https://github.com/carlossless/sinowealth-kb-tool/issues/25 and possibly addresses https://github.com/carlossless/sinowealth-kb-tool/issues/15 https://github.com/carlossless/sinowealth-kb-tool/issues/16