Fixed race condition at startup that could cause a crash in the XInput driver

(cherry picked from commit 6d7c211faf)
This commit is contained in:
Sam Lantinga 2024-09-06 10:15:16 -07:00
parent 224a37faab
commit 5aadfd4eaf
1 changed files with 5 additions and 3 deletions

View File

@ -65,11 +65,13 @@ SDL_bool SDL_XINPUT_Enabled(void)
int SDL_XINPUT_JoystickInit(void)
{
s_bXInputEnabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE);
SDL_bool enabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE);
if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) {
s_bXInputEnabled = SDL_FALSE; /* oh well. */
if (enabled && WIN_LoadXInputDLL() < 0) {
enabled = SDL_FALSE; /* oh well. */
}
s_bXInputEnabled = enabled;
return 0;
}