-
Notifications
You must be signed in to change notification settings - Fork 423
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
hid_enumerate specify multiple VID/PID combos. #225
Comments
use |
Right, but it turns out that running hid_enumerate(0,0) repeatedly is very bad and causes many issues on user's computers. For example it can cause clicking sounds on microphones and make other HID devices unusable. It is better to filter within the enumerate function than to run a full getDescriptor request on every single hid device on the computer. |
Not repeatedly. Enumerate once - search/filter all the devices you need in that list. |
But if you have a program and device where you have to repeatedly check for when the device was inserted or removed on the fly this does not work. |
I'm confused. Checking for hotplug/unplug events is entirely different problem, then you originally described (finding multiple devices with a single |
One detects plug and unplug events by repeatedly enumerating the the devices and checking the difference between enumerations |
And how passing multiple VIDs/PIDs into hid_enumerate help with "audio clicks" each time you call it? |
When you do hid_enumerate(0,0) it executes getDescriptor requests on every single usb device on your computer even devices such as microphones that I'm not interested in. Resource limited devices with weak CPUs such a microphones cannot do their regular job and respond to the request at the same time. When the microphone receives the request it stops streaming audio data briefly so that it can respond. This can be heard as a short "pop" or "click". If we call hid_enumerate without wildcards and only specify which devices we care about, it avoids sending this disruptive getDescriptor request to sensitive devices such as microphones, etc. |
In general, I would advise against using Instead, use an OS-specific USB insertion/removal event system. I don't know of a hidapi-like cross-platform C-based API for doing this, but you can check out the Nodejs package Another thing to note, there is a delay between device inserted and when it's available to |
Very good point from Tod. Thanks for the explanation @FabianKopp, I think I understand your problem now.
|
Its pretty much everything after this filtering line: |
I'm asking, because I was thinking a more general aproach: enumerate function, that accepts a filter function over devices attrigutes (or even over a hid_device_info), but I guess it wouldn't help your case, since only VID/PID is available for filtering, without causing negative effect on your audio device(s). |
As of now you can only specify one pair of VID PID in the hid_enumerate function. Is it possible to have a version where you can supply multiple sets of VID PIDs to the function? This would be of great use for anyone scanning for multiple products.
The text was updated successfully, but these errors were encountered: