pok3rtool
pok3rtool copied to clipboard
Use LibUSB-1.0 RawHID backend for Windows/macOS/Linux
In preparation for ISP protocol support for all platforms, this PR replaces platform-specific rawhid backends with a common LibUSB-1.0 backend. With only one backend to maintain, it becomes easier to add control transfer functionality to RawHID and HIDDevice which is required by #13 for working flash programming (see #12 for more information).
Tasks:
- [x] Implement base rawhid functions using LibUSB-1.0 backend
- ~Add control transfer function to RawHID and HIDDevice~ (support will be added with ISP protocol support)
- Tested prototype:
- https://github.com/hansemro/pok3rtool/blob/182e5cee8bf0d04dd6d8db5920214e1e5146bf0a/rawhid/hiddevice.cpp#L105-L121
- https://github.com/hansemro/pok3rtool/blob/182e5cee8bf0d04dd6d8db5920214e1e5146bf0a/rawhid/hid_libusb.c#L124-L145
- Tested prototype:
- [x] Support Linux
- [x] Replace hid_LINUX.c
- [x] Support macOS
- [x] Replace hid_MACOSX.c
- [x] Support Windows (with MSYS2/MinGW build environment)
- [x] Replace hid_WINDOWS.c
I am going to drop/revert control transfer support in this PR so that it can be included alongside ISP protocol support.
@ChaoticEnigma This is ready for review.
Having issues with Windows again. It works for detecting ISP but not keyboards. The error is related to matching Usage and Usage Page in the HID Report descriptor.
I might be able to workaround this by using libusb/hidapi
hidapi works much better than the current implementation.
Reverting libhidapi changes due to odd behavior in macOS that prevents the usb device from being detected on subsequent access attempts.
Related: https://github.com/libusb/hidapi/issues/385
Workaround for Windows:
- (Option 1) Temporarily install WinUSB (or libusb-win32) driver for the interface we are interested in using Zadig (https://zadig.akeo.ie/)
- On Windows 10, HidUsb driver fails to access some HID Report descriptors for devices with multiple interfaces.
- Example: Cooler Master Pro S RGB (bootloader) detection can be fixed by installing WinUSB driver on interface 1.
- (Option 2) Keep rawhid_WINDOWS.c (and implement control transfer at a later point)