Skip to content
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

[patch] (OSX) Removed joysticks wrongly marked as closed. #1651

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

[patch] (OSX) Removed joysticks wrongly marked as closed. #1651

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: Mac OS X (All), x86

Comments on the original bug report:

On 2014-09-23 07:47:26 +0000, Rodrigo Cardoso wrote:

Created attachment 1878
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.

On 2014-09-23 08:12:36 +0000, Rodrigo Cardoso wrote:

Created attachment 1879
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.

On 2014-10-07 19:39:03 +0000, Rodrigo Cardoso wrote:

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

On 2015-02-19 05:22:22 +0000, Ryan C. Gordon wrote:

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!

On 2015-03-24 01:16:52 +0000, Ryan C. Gordon wrote:

(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.

On 2015-03-24 17:55:28 +0000, Ryan C. Gordon wrote:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant