ThemsAllTook / libstem_gamepad

Gamepad C API wrapper for OS X, Windows, and Linux
Other
181 stars 31 forks source link

Win32/DInput: check for device notification before enumerating gamepads #3

Closed oncer closed 1 year ago

oncer commented 9 years ago

Calling Gamepad_detectDevices() in a thread loop to enable gamepad hotplugging will currently cause problems on some systems because of the IDirectInput_EnumDevices call. Some USB sound cards, speakers, microphones, or keyboards will act strangely if you do this too often.

This code I borrowed from SDL2 will only call IDirectInput_EnumDevices if an input device was either plugged in or unplugged since the last call. This is done with the RegisterDeviceNotification call essentially.

looki commented 7 years ago

A mere hours left before the IGF submission deadline, and after over a year of no reports, this tester comes up with these constant crashes in EnumDevices. I was absolutely clueless and couldn't reproduce it, so it was really hard to figure out why it would break. And then of course, I find this magical patch! Thank you so much for this :)