| Summary: | [patch] (OSX) Removed joysticks wrongly marked as closed. | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Rodrigo Cardoso <rodrigo.alfenas> |
| Component: | joystick | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | icculus, rodrigo.alfenas |
| Version: | HG 2.0 | Keywords: | triage-2.0.4 |
| Hardware: | x86 | ||
| OS: | Mac OS X (All) | ||
| Attachments: |
patch that fixes the issue
new patch |
||
Created attachment 1879 [details]
new patch
right after submitting the bug I noticed I was not getting the "release all buttons and center all axes" events that should be fired when removing a device, the new patch takes that into account.
notice that I left "joystick->closed" in the if even not relying in it anymore because I dont know if other platforms need it, just put an OR there.
Just some more info on why I found this. First I noticed that sometimes I was not getting the "release all buttons and center all axes" sometimes, and I was also trying to understand the purpose of SDL_JoystickGetAttached in the examples, since the joystick was invalidated before I get a change to get its instance ID and/or close it (at last on mac). Preventing SDL to flag the joystick as 'closed' early fixed this problem. After making this change, I was able to retrieve the instanceID correctly, so I could compare with the "which" field of the SDL_JOYDEVICEREMOVED event and close the joystick as I should, without keeping another copy of the instance id, and still got the release button events after that as I expected. Also, as far as I understand only SDL_SYS_JoystickClose should change the ->closed to 1, right? bye 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! (In reply to Rodrigo Cardoso from comment #2) > Also, as far as I understand only SDL_SYS_JoystickClose should change the > ->closed to 1, right? This appears to be true, and it looks like the Windows code has the same problem. I'll check this soon. --ryan. I ended up cleaning up a bunch of stuff in the joystick subsystem while trying to understand when and why we should be setting that "closed" flag. I ended up removing it altogether. :) In addition to other improvements, this specific bug is now fixed in https://hg.libsdl.org/SDL/rev/bd062398b648, thanks! --ryan. |
Created attachment 1878 [details] patch that fixes the issue I noticed that when you remove a joystick in cocoa, SDL marked it as closed internally even if it is not! This caused an annoying issue that prevented the Joystick ID from being retrieved before closing it. There is an one line patch attached that fixes the issue.