Added SDL_TryLockJoysticks()

This commit is contained in:
Sam Lantinga
2026-01-29 16:15:37 -08:00
parent 5f0c889082
commit e3e8adcb76
5 changed files with 27 additions and 0 deletions

View File

@@ -188,6 +188,21 @@ typedef enum SDL_JoystickConnectionState
*/
extern SDL_DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock);
/**
* Locking for atomic access to the joystick API.
*
* The SDL joystick functions are thread-safe, however you can lock the
* joysticks while processing to guarantee that the joystick list won't change
* and joystick and gamepad events will not be delivered.
*
* \returns true if the joysticks were successfully locked, false otherwise.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.2.0.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock);
/**
* Unlocking for atomic access to the joystick API.
*