SDL_XINPUT_Enabled() returns false until XInput DLL is successfully loaded

We make sure we initialize XInput first, so that anything checking whether it's enabled gets a valid result based on whether we were able to load it or not.

(cherry picked from commit 8f46cb771c)
(cherry picked from commit f5ed158d1f)
This commit is contained in:
Sam Lantinga committed 2024-09-06 11:24:58 -07:00
1 parent d53b22e8f0
commit 00a7191f67
2 files changed
+4 -4

No files matched your search

+3 -3
View File
@@ -377,7 +377,7 @@ static int SDLCALL SDL_JoystickThread(void *_data)
#ifdef SDL_JOYSTICK_XINPUT #ifdef SDL_JOYSTICK_XINPUT
/* WM_DEVICECHANGE not working, poll for new XINPUT controllers */ /* WM_DEVICECHANGE not working, poll for new XINPUT controllers */
SDL_CondWaitTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000); SDL_CondWaitTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000);
if (SDL_XINPUT_Enabled() && XINPUTGETCAPABILITIES) { if (SDL_XINPUT_Enabled()) {
/* scan for any change in XInput devices */ /* scan for any change in XInput devices */
Uint8 userId; Uint8 userId;
for (userId = 0; userId < XUSER_MAX_COUNT; userId++) { for (userId = 0; userId < XUSER_MAX_COUNT; userId++) {
@@ -473,12 +473,12 @@ void WINDOWS_JoystickQuit(void);
*/ */
static int WINDOWS_JoystickInit(void) static int WINDOWS_JoystickInit(void)
{ {
if (SDL_DINPUT_JoystickInit() < 0) { if (SDL_XINPUT_JoystickInit() < 0) {
WINDOWS_JoystickQuit(); WINDOWS_JoystickQuit();
return -1; return -1;
} }
if (SDL_XINPUT_JoystickInit() < 0) { if (SDL_DINPUT_JoystickInit() < 0) {
WINDOWS_JoystickQuit(); WINDOWS_JoystickQuit();
return -1; return -1;
} }
+1 -1
View File
@@ -39,7 +39,7 @@ extern "C" {
/* /*
* Internal stuff. * Internal stuff.
*/ */
static SDL_bool s_bXInputEnabled = SDL_TRUE; static SDL_bool s_bXInputEnabled = SDL_FALSE;
static SDL_bool SDL_XInputUseOldJoystickMapping(void) static SDL_bool SDL_XInputUseOldJoystickMapping(void)
{ {