-
Notifications
You must be signed in to change notification settings - Fork 407
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
Mapping from hid_device to hid_device_info #163
Comments
Sounds about right for all platforms, not only for Windows.
Unfortunately, this is not a well-formed piece of code. Now answering your question:
Not right now. In all backends (libusb/hidraw/WinAPI/macOS) the path isn't saved anywhere, so it can't be simply retrieved, nor reliably generated from native handle on each platform. I had to solve a similar task as you have (to match a device, when SN isn't available from the device descriptor). In my case I was able to send some commands to/from the device, and I could match it by communicating with the device. You're free to open a PR that implements a new API. |
I have submitted a pull request. The pros of the PR is that it adds hid_get_path which can get the path from a hid_device pointer. The biggest con is that now we dynamically allocate space for this path string. Each implementation hid_device structure has an additional new There are some caveats with this PR, please see the second post there for details. |
- new API function: `struct hid_device_info * hid_get_device_info(hid_device *dev);` to get `hid_device_info` after the device already opened; - reused existing implementation on Windows and macOS from enumeration routines to have the implementation; - refactored libusb implementation to have a shared routine for `hid_enumerate` and `hid_get_device_info`; - refactored hidraw implementation to have a shared routine for `hid_enumerate` and `hid_get_device_info`; Resolves: #431 Closes: #164 Closes: #163
Assuming the manufacturer of a device did not use serial_numbers to make particular hid devices unique. Is there a way to uniquely map from a given already open hid_device opaque pointer / handle back to a hid_device_info struct in the linked list provided by hid_enumerate(0,0)?
I initially thought that I could do something like the following:
Unfortunately, on windows the second hid_open_path function returns a handle that is not identical to the provided handle. As such this code can not return a match.
An alternative method would be if there were a function to extract the path from a given hid_device. In this case, the above code could be modified as following:
Is there a way to get the path from a hid_device pointer?
The text was updated successfully, but these errors were encountered: