Closed drola closed 6 years ago
@drola you can always add a rule to /etc/udev/rules.d , which changes access permissions to your HID device. I added a group for my keyboard backlight, which has access to the device.
Edit: Also you should probably not just switch the linux build to hidraw. You can for example add config flags / feature sets to cargo, and let the library user choose the backend implementation.
My use case requires using hidraw driver because I am implementing advanced functionality on Logitech G203 gaming mouse. I want the kernel to normally handle mouse pointer while simultaneously setting and getting some vendor-specific reports from the device.
Letting the end user choose implementation would be the best option but unfortunately I lack the knowledge to implement it that way. It looks like specifying features in Cargo.toml is the way to go? I could look into this tomorrow and update this PR.
Yes features are the correct way. When you add some #[cfg(...)] magic in your build.rs you can even turn on hidraw by default on linux, and let it override with a feature flag.
I updated the pull request.
By default it will use libusb-1.0
backend on Linux to preserver current behaviour. Optionally a feature called linux-hidraw
can be enabled to switch to hidraw
backend. I added Cargo.toml
example to the Usage section in README.md
.
Closed in favor of #12 .
While testing hidapi-rs on Ubuntu I found that:
After a bit of research I found that libusb implementation of hidapi disconnects kernel's hidraw driver when opening a HID device. Additionally it is not possible to access HID devices connected through Bluetooth. Switching to hidraw backend for hidapi fixes issues mentioned above.