-
Notifications
You must be signed in to change notification settings - Fork 393
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
Windows version doesn't enumerate devices when exactly one is connected #234
Comments
I assume you're using build 0.10.1. Can you step-trace a "single device" scenario with a debugger and tell what do you get from SetupDiGetClassDevsA/SetupDiEnumDeviceInterfaces (or after those)? |
driver_name is "Battery" which is weird as in windows device manager the device class shows "HIDClass" as expected. |
And when you have two devices connected? |
Yes, I believe on Windows, with the HID Battery driver, that removes it from the list of devices hidapi can access. (as what happens to gamepads) http://batcmd.com/windows/10/services/hidbatt/ |
I just tested an APC Back-UPS ES 550 on Windows 10 Pro. It appears as both a HID device and as a "Battery" to device driver (see screenshot below). And it appears to hidapi's Oh, wait, but I see, the issue is that if the UPS is the only HID device. Hmmm. |
UPD: this conversation looks weird, when we both edit our messages :D |
Yes I understand that better now. :) Trying to figure out how to test this since RDP just decided to stop working with a recent Win10 update... |
@Youw when I plug the keyboard and the mouse in, all iterations returns "Keyborad" as a device name. Something is definetely wrong in this code. I found old, open but abandoned pull request that claims that the index passed to the It seems that after simillar change the driver_name shows more apriopriate values to the ones that are shown in Windows Device Manager. To sumarise that, it looks like This is coincidence that the code works with my UPS because This way, we can expect that we could get rid of the "Keyboard" and "Mouse" exceptions, because for those devices the device manager also shows "HIDClass" value. Yet, I am not very familiar with WinApi so I don't know (yet) how to retrive it using WinApi. |
How about solution straight from Microsoft: https://github.com/microsoft/Windows-driver-samples/blob/master/hid/hclient/pnp.c#L32 ? It is similar but instead of checking device class name, it just uses |
I'm afraid, opening a device might cause issue, like described here: #225 (comment) |
We already do this: It is being open with |
Hmm, right, fair enough. |
The PR works for me, please review. I didn't use |
Based on https://github.com/microsoft/Windows-driver-samples/blob/d40232638faaab19de557e70a3ee938da7a35295/hid/hclient/pnp.c#L32 Fixes wrong detection of the class of devices. Fixes: #234
I don't know if this is coincidence, but this is my case:
I plug UPS HID device (CyberPower or APC) as an only HID device in the whole system, and
hid_enumerate
returnsnullptr
.When I plug USB keyboard as a second device,
hid_enumerate
enumerates both - keyboard and UPS.On Linux and exactly the same machine it works fine.
The text was updated successfully, but these errors were encountered: