Skip to content

Commit

Permalink
SDL_XINPUT_Enabled() returns false until XInput DLL is successfully l…
Browse files Browse the repository at this point in the history
…oaded

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)
  • Loading branch information
slouken committed Sep 6, 2024
1 parent 5aadfd4 commit f5ed158
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/joystick/windows/SDL_windowsjoystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ static int SDLCALL SDL_JoystickThread(void *_data)
#ifdef SDL_JOYSTICK_XINPUT
/* WM_DEVICECHANGE not working, poll for new XINPUT controllers */
SDL_CondWaitTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000);
if (SDL_XINPUT_Enabled() && XINPUTGETCAPABILITIES) {
if (SDL_XINPUT_Enabled()) {
/* scan for any change in XInput devices */
Uint8 userId;
for (userId = 0; userId < XUSER_MAX_COUNT; userId++) {
Expand Down Expand Up @@ -473,12 +473,12 @@ void WINDOWS_JoystickQuit(void);
*/
static int WINDOWS_JoystickInit(void)
{
if (SDL_DINPUT_JoystickInit() < 0) {
if (SDL_XINPUT_JoystickInit() < 0) {
WINDOWS_JoystickQuit();
return -1;
}

if (SDL_XINPUT_JoystickInit() < 0) {
if (SDL_DINPUT_JoystickInit() < 0) {
WINDOWS_JoystickQuit();
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/joystick/windows/SDL_xinputjoystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern "C" {
/*
* Internal stuff.
*/
static SDL_bool s_bXInputEnabled = SDL_TRUE;
static SDL_bool s_bXInputEnabled = SDL_FALSE;

static SDL_bool SDL_XInputUseOldJoystickMapping(void)
{
Expand Down

0 comments on commit f5ed158

Please sign in to comment.