| Summary: | Duplicate joysticks reported on OS X | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Kyungdahm Yun <tomyun> |
| Component: | joystick | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | icculus, tomyun |
| Version: | 2.0.3 | Keywords: | triage-2.0.4 |
| Hardware: | x86_64 | ||
| OS: | Mac OS X 10.7 | ||
| Attachments: | OS X joystick registration patch for SDL 2.0.3 | ||
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though! This patch is now https://hg.libsdl.org/SDL/rev/795d4866e4db, thanks! --ryan. |
Created attachment 1974 [details] OS X joystick registration patch for SDL 2.0.3 After upgrading to the latest mame 0.156, which now uses SDL2 by default, it is found that more than actual number of joysticks are registered and messing up input configuration on OS X. There was no problem with previous version linked against SDL1. It only happens when two joysticks are connected at the same time. And a particular joystick is always registered twice. For example, when I connected two joysticks, 1. Hori PS3 Fighting Stick Mini 3 ("STICK A") 2. Buffalo Classic USB Gaming pad ("USB,2-axis 8-button gamepad") the output from testjoystick looked like this: 2014-12-14 21:03:01.028 testjoystick[33515:603] INFO: There are 3 joysticks attached 2014-12-14 21:03:01.034 testjoystick[33515:603] INFO: Joystick 0: STICK A 2014-12-14 21:03:01.035 testjoystick[33515:603] INFO: axes: 4 2014-12-14 21:03:01.045 testjoystick[33515:603] INFO: balls: 0 2014-12-14 21:03:01.046 testjoystick[33515:603] INFO: hats: 1 2014-12-14 21:03:01.048 testjoystick[33515:603] INFO: buttons: 13 2014-12-14 21:03:01.049 testjoystick[33515:603] INFO: instance id: 0 2014-12-14 21:03:01.050 testjoystick[33515:603] INFO: guid: 0d0f0000000000004000000000000000 2014-12-14 21:03:01.053 testjoystick[33515:603] INFO: Joystick 1: STICK A 2014-12-14 21:03:01.054 testjoystick[33515:603] INFO: axes: 4 2014-12-14 21:03:01.054 testjoystick[33515:603] INFO: balls: 0 2014-12-14 21:03:01.055 testjoystick[33515:603] INFO: hats: 1 2014-12-14 21:03:01.056 testjoystick[33515:603] INFO: buttons: 13 2014-12-14 21:03:01.057 testjoystick[33515:603] INFO: instance id: 1 2014-12-14 21:03:01.063 testjoystick[33515:603] INFO: guid: 0d0f0000000000004000000000000000 2014-12-14 21:03:01.065 testjoystick[33515:603] INFO: Joystick 2: USB,2-axis 8-button gamepad 2014-12-14 21:03:01.066 testjoystick[33515:603] INFO: axes: 2 2014-12-14 21:03:01.067 testjoystick[33515:603] INFO: balls: 0 2014-12-14 21:03:01.069 testjoystick[33515:603] INFO: hats: 0 2014-12-14 21:03:01.072 testjoystick[33515:603] INFO: buttons: 8 2014-12-14 21:03:01.074 testjoystick[33515:603] INFO: instance id: 2 2014-12-14 21:03:01.075 testjoystick[33515:603] INFO: guid: 83050000000000006020000000000000 You'd notice the first and second joysticks have exactly same information including GUID. Spending some time on debugging, I found that `JoystickDeviceWasAddedCallback` was called twice from two different sources, `IOHIDManagerSetDeviceMatchingMultiple` and `CFRunLoopRunInMode`, respectively. As the registration were supposed to be handled in the run loop, the first call from `IOHIDManagerSetDeviceMatchingMultiple` would be redundant. This patch fixes this issue by registering callback AFTER setting up matching criteria, not BEFORE as is. I'm not really familiar with I/O Kit, but hopefully it shouldn't bring in another side effect.