mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-30 15:08:31 +00:00
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.
This commit is contained in:
@@ -61,7 +61,7 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = {
|
|||||||
#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
|
#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
|
||||||
&SDL_WINDOWS_JoystickDriver,
|
&SDL_WINDOWS_JoystickDriver,
|
||||||
#endif
|
#endif
|
||||||
#ifdef SDL_JOYSTICK_WGI
|
#ifdef SDL_JOYSTICK_WGI // Lower priority than other Windows drivers
|
||||||
&SDL_WGI_JoystickDriver,
|
&SDL_WGI_JoystickDriver,
|
||||||
#endif
|
#endif
|
||||||
#ifdef SDL_JOYSTICK_WINMM
|
#ifdef SDL_JOYSTICK_WINMM
|
||||||
|
@@ -241,7 +241,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_WaitConditionTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000);
|
SDL_WaitConditionTimeout(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++) {
|
||||||
@@ -329,15 +329,14 @@ void WINDOWS_AddJoystickDevice(JoyStick_DeviceData *device)
|
|||||||
void WINDOWS_JoystickDetect(void);
|
void WINDOWS_JoystickDetect(void);
|
||||||
void WINDOWS_JoystickQuit(void);
|
void WINDOWS_JoystickQuit(void);
|
||||||
|
|
||||||
// Function to scan the system for joysticks.
|
|
||||||
static bool WINDOWS_JoystickInit(void)
|
static bool WINDOWS_JoystickInit(void)
|
||||||
{
|
{
|
||||||
if (!SDL_DINPUT_JoystickInit()) {
|
if (!SDL_XINPUT_JoystickInit()) {
|
||||||
WINDOWS_JoystickQuit();
|
WINDOWS_JoystickQuit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SDL_XINPUT_JoystickInit()) {
|
if (!SDL_DINPUT_JoystickInit()) {
|
||||||
WINDOWS_JoystickQuit();
|
WINDOWS_JoystickQuit();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ extern "C" {
|
|||||||
/*
|
/*
|
||||||
* Internal stuff.
|
* Internal stuff.
|
||||||
*/
|
*/
|
||||||
static bool s_bXInputEnabled = true;
|
static bool s_bXInputEnabled = false;
|
||||||
|
|
||||||
bool SDL_XINPUT_Enabled(void)
|
bool SDL_XINPUT_Enabled(void)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user