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

Do we still need SDL_LockJoysticks() in the public API? #6956

Closed
icculus opened this issue Dec 30, 2022 · 4 comments · Fixed by #6960
Closed

Do we still need SDL_LockJoysticks() in the public API? #6956

icculus opened this issue Dec 30, 2022 · 4 comments · Fixed by #6960
Milestone

Comments

@icculus
Copy link
Collaborator

icculus commented Dec 30, 2022

In SDL3, SDL_GetJoysticks() returns a copy of the list to the app, which means they don't need to protect against the list changing while they iterate it.

We probably need to maintain a mutex internally, but does it make sense to make this lock public, especially if it's going to touch not just the list but the delivery of events?

It's trivial for an app to provide its own lock if they deal with the array returned by SDL_GetJoysticks() from multiple threads, but I assume most things won't be touching it from multiple threads in the first place.

@icculus icculus added this to the 3.2.0 milestone Dec 30, 2022
@slouken
Copy link
Collaborator

slouken commented Dec 30, 2022

I removed it, but then I remembered that people might want to lock around getting the list of joysticks and then querying attributes about them. I don't feel strongly either way, but it seems like it's still useful.

@icculus
Copy link
Collaborator Author

icculus commented Dec 30, 2022

My thinking is that if they query an instance that has vanished (or is bogus), we should return an error and they should ignore that device. It's probably not useful to provide correct information for a device that is no longer available.

@slouken
Copy link
Collaborator

slouken commented Dec 31, 2022

Fair enough. I’ll remove it from the public API.

slouken added a commit to slouken/SDL that referenced this issue Dec 31, 2022
All joystick functions are thread-safe and you can now get an atomic list of joysticks with SDL_GetJoysticks()

Fixes libsdl-org#6956
slouken added a commit that referenced this issue Dec 31, 2022
All joystick functions are thread-safe and you can now get an atomic list of joysticks with SDL_GetJoysticks()

Fixes #6956
@slouken
Copy link
Collaborator

slouken commented Jan 4, 2023

Yes, we still need the functions to lock joystick mappings.

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

Successfully merging a pull request may close this issue.

2 participants