Closed drc0 closed 4 years ago
This is likely an upstream issue. This ctypes wrapper simply returns the data from the hid_enumerate
call.
Its largely going to depend on your specific platform, but you can see here how on windows the usage_page
and usage
values can silently fail to be retrieved and end up being 0
:
https://github.com/signal11/hidapi/blob/a6a622ffb680c55da0de787ff93b80280498330f/windows/hid.c#L416-L420
Ok thank you. I'm testing on linux, and what made me wonder is that here is told to discriminate against usage_id and usage_page https://beta.docs.qmk.fm/using-qmk/software-features/feature_rawhid#host-windows-macos-linux and here is an example with node-hid https://github.com/BlankSourceCode/qmk-hid-display/blob/7e9282b92ceb2c685957f994a9f739780e3aa10b/index.js#L255, this worked perfectly but probably out of luck, now I can only communicate with the device that has interface number 1 (both with node-hid and pyhidapi) and not discriminating against usage_* , I don't know if that makes sense. Anyway feel free to close this issue if you want, and thanks for the insight.
You definitely don't need the usage/page to open a device with hidapi - a vid/pid is enough.
The only time I could see the usage/page being useful is:
If you know the vid/pid then you can just call:
hid.enumerate(vid, pid)
Just to add: In this case the device has multiple interface numbers: it is a promicro with qmk firmware.
{'path': b'/dev/hidraw2', 'vendor_id': 51984, 'product_id': 4403, 'serial_number': '0', 'release_number': 256, 'manufacturer_string': 'ASD', 'product_string': 'BDN9 keypad', 'usage_page': 0, 'usage': 0, 'interface_number': 0}
{'path': b'/dev/hidraw3', 'vendor_id': 51984, 'product_id': 4403, 'serial_number': '0', 'release_number': 256, 'manufacturer_string': 'ASD', 'product_string': 'BDN9 keypad', 'usage_page': 0, 'usage': 0, 'interface_number': 1}
{'path': b'/dev/hidraw4', 'vendor_id': 51984, 'product_id': 4403, 'serial_number': '0', 'release_number': 256, 'manufacturer_string': 'ASD', 'product_string': 'BDN9 keypad', 'usage_page': 0, 'usage': 0, 'interface_number': 2}
{'path': b'/dev/hidraw5', 'vendor_id': 51984, 'product_id': 4403, 'serial_number': '0', 'release_number': 256, 'manufacturer_string': 'ASD', 'product_string': 'BDN9 keypad', 'usage_page': 0, 'usage': 0, 'interface_number': 3}
When enumerating with
sometimes
d['usage']
is 0 and I cant get a stable device path for the connection.