Skip to content

Commit f5ed158

Browse files
committed
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 8f46cb7)
1 parent 5aadfd4 commit f5ed158

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/joystick/windows/SDL_windowsjoystick.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ static int SDLCALL SDL_JoystickThread(void *_data)
377377
#ifdef SDL_JOYSTICK_XINPUT
378378
/* WM_DEVICECHANGE not working, poll for new XINPUT controllers */
379379
SDL_CondWaitTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000);
380-
if (SDL_XINPUT_Enabled() && XINPUTGETCAPABILITIES) {
380+
if (SDL_XINPUT_Enabled()) {
381381
/* scan for any change in XInput devices */
382382
Uint8 userId;
383383
for (userId = 0; userId < XUSER_MAX_COUNT; userId++) {
@@ -473,12 +473,12 @@ void WINDOWS_JoystickQuit(void);
473473
*/
474474
static int WINDOWS_JoystickInit(void)
475475
{
476-
if (SDL_DINPUT_JoystickInit() < 0) {
476+
if (SDL_XINPUT_JoystickInit() < 0) {
477477
WINDOWS_JoystickQuit();
478478
return -1;
479479
}
480480

481-
if (SDL_XINPUT_JoystickInit() < 0) {
481+
if (SDL_DINPUT_JoystickInit() < 0) {
482482
WINDOWS_JoystickQuit();
483483
return -1;
484484
}

src/joystick/windows/SDL_xinputjoystick.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern "C" {
3939
/*
4040
* Internal stuff.
4141
*/
42-
static SDL_bool s_bXInputEnabled = SDL_TRUE;
42+
static SDL_bool s_bXInputEnabled = SDL_FALSE;
4343

4444
static SDL_bool SDL_XInputUseOldJoystickMapping(void)
4545
{

0 commit comments

Comments
 (0)