-
Notifications
You must be signed in to change notification settings - Fork 443
hidapi/windows: avoid enumerating devices that may hang when queried #575
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
hidapi/windows: avoid enumerating devices that may hang when queried #575
Conversation
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
@@ -756,6 +756,28 @@ static struct hid_device_info *hid_internal_get_device_info(const wchar_t *path, | |||
return dev; | |||
} | |||
|
|||
static int hid_blacklist(unsigned short vendor_id, unsigned short product_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use also such a denylist in our app. But we use more filter criteria: USB-Interface-Number, Usage-Page, Usage and Bus-Type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that logic could be moved into SDL, but since we've definitely run into problems with those devices I thought it would be worth sharing upstream.
Interesting - does it hang only on Windows, what about other platforms? |
These are mostly from Steam customer reports, running Windows. I'm not sure whether they vary based on OS or driver version. There was one device which I observed hanging on Linux, and it was the device itself that was hanging while processing a string request, not the driver. Unfortunately this was years ago and I don't remember which one it was. |
The Speedlink Competition Pro was one I observed myself, and it was the strangest behavior. The controller actually disconnected and re-enumerated as a different (non-functional) device when queried. |
What I am afraid in hard-coded lists like this is that it makes it really difficult to support and reason about, e.g.:
I've very scepticaly of having it as part of HIDAPI implementation. I'd like to hear/investigate from someone who has one of those faulty devices. |
These are all reasonable concerns. I'll go ahead and leave this in SDL and close this PR. |
We could do both: allow SDL filter out devices like this, and avoid patching HIDAPI sources if we would introduce something like: typedef int (*HID_API_CALL hidapi_ven_dev_filter_func)(unsigned short vendor_id, unsigned short product_id);
struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate_ven_dev_filter(hidapi_ven_dev_filter_func); But that is a different effort, and would definitely need an implementation on all platforms. |
Yup, agreed. And for what it's worth the SDL filter also uses the usage page and usage, so that might be useful in this model. Let me know if you'd like me to create a PR for this approach? |
If you're up to it - the improvements are always welcome. |
No description provided.