Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rules for accessing HID devices with libusb #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robin-nitrokey
Copy link
Member

@robin-nitrokey robin-nitrokey commented Dec 16, 2024

HID devices can be accessed with libusb or with hidraw. So far, we have mostly been using hidraw and our udev rules only apply to hidraw devices. This patch adds rules for access with libusb as recommended by the hidapi developers:

https://github.com/libusb/hidapi/blob/ff67c77daddbd8e61ad3873ac16f8edc005f943f/udev/69-hid.rules


You can use the following code for testing:

import hid

devices = hid.enumerate()
print("paths: ")
print([d["path"] for d in devices])

for device in devices:
    if device["vendor_id"] == 0x20a0 and device["product_id"] == 0x42dd:
        h = hid.device()
        h.open_path(device["path"])
        h.close()

With hidapi v0.14.0 and v0.14.0.post4, this uses libusb. With hidapi v0.14.0.post1 to v0.14.0.post3, this uses hidraw. (This only applies if hidapi is installed from the PyPI wheels – packaged versions or manual builds may behave differently.) From my experience, a reboot is required to properly apply the new rules.

HID devices can be accessed with libusb or with hidraw.  So far, we have
mostly been using hidraw and our udev rules only apply to hidraw
devices.  This patch adds rules for access with libusb as recommended by
the hidapi developers:

https://github.com/libusb/hidapi/blob/ff67c77daddbd8e61ad3873ac16f8edc005f943f/udev/69-hid.rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant