Added a single source of SDL object IDs

This ensures that we don't accidentally interpret an ID from one system as an ID in another system.
Audio device IDs are not covered here, since they have a unique numbering system.
This commit is contained in:
Sam Lantinga
2023-10-23 09:46:09 -07:00
parent e07f6c0a17
commit 38afd48daf
23 changed files with 37 additions and 50 deletions

View File

@@ -116,7 +116,6 @@ static SDL_bool SDL_joysticks_initialized;
static SDL_bool SDL_joysticks_quitting;
static SDL_bool SDL_joystick_being_added;
static SDL_Joystick *SDL_joysticks SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
static SDL_AtomicInt SDL_last_joystick_instance_id;
static int SDL_joystick_player_count SDL_GUARDED_BY(SDL_joystick_lock) = 0;
static SDL_JoystickID *SDL_joystick_players SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE;
@@ -413,15 +412,6 @@ SDL_JoystickID *SDL_GetJoysticks(int *count)
return joysticks;
}
/*
* Return the next available joystick instance ID
* This may be called by drivers from multiple threads, unprotected by any locks
*/
SDL_JoystickID SDL_GetNextJoystickInstanceID(void)
{
return SDL_AtomicIncRef(&SDL_last_joystick_instance_id) + 1;
}
/*
* Get the implementation dependent name of a joystick
*/