mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-01-12 18:55:31 +00:00
Fixed the joystick side of XInput haptic detection on Windows 8
This commit is contained in:
parent
764aa147ad
commit
c3c24a335d
|
@ -959,12 +959,13 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||||
SDL_zerop(joystick->hwdata);
|
SDL_zerop(joystick->hwdata);
|
||||||
|
|
||||||
if (joystickdevice->bXInputDevice) {
|
if (joystickdevice->bXInputDevice) {
|
||||||
const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4));
|
|
||||||
const Uint8 userId = joystickdevice->XInputUserId;
|
const Uint8 userId = joystickdevice->XInputUserId;
|
||||||
XINPUT_CAPABILITIES capabilities;
|
XINPUT_CAPABILITIES capabilities;
|
||||||
|
XINPUT_VIBRATION state;
|
||||||
|
|
||||||
SDL_assert(s_bXInputEnabled);
|
SDL_assert(s_bXInputEnabled);
|
||||||
SDL_assert(XINPUTGETCAPABILITIES);
|
SDL_assert(XINPUTGETCAPABILITIES);
|
||||||
|
SDL_assert(XINPUTSETSTATE);
|
||||||
SDL_assert(userId >= 0);
|
SDL_assert(userId >= 0);
|
||||||
SDL_assert(userId < SDL_XINPUT_MAX_DEVICES);
|
SDL_assert(userId < SDL_XINPUT_MAX_DEVICES);
|
||||||
|
|
||||||
|
@ -977,9 +978,8 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||||
} else {
|
} else {
|
||||||
/* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */
|
/* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */
|
||||||
SDL_assert(capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD);
|
SDL_assert(capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD);
|
||||||
if ((!bIs14OrLater) || (capabilities.Flags & XINPUT_CAPS_FFB_SUPPORTED)) {
|
SDL_zero(state);
|
||||||
joystick->hwdata->bXInputHaptic = SDL_TRUE;
|
joystick->hwdata->bXInputHaptic = (XINPUTSETSTATE(userId, &state) == ERROR_SUCCESS);
|
||||||
}
|
|
||||||
joystick->hwdata->userid = userId;
|
joystick->hwdata->userid = userId;
|
||||||
|
|
||||||
/* The XInput API has a hard coded button/axis mapping, so we just match it */
|
/* The XInput API has a hard coded button/axis mapping, so we just match it */
|
||||||
|
@ -987,7 +987,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||||
joystick->nbuttons = 15;
|
joystick->nbuttons = 15;
|
||||||
joystick->nballs = 0;
|
joystick->nballs = 0;
|
||||||
joystick->nhats = 0;
|
joystick->nhats = 0;
|
||||||
}
|
}
|
||||||
} else { /* use DirectInput, not XInput. */
|
} else { /* use DirectInput, not XInput. */
|
||||||
LPDIRECTINPUTDEVICE8 device;
|
LPDIRECTINPUTDEVICE8 device;
|
||||||
DIPROPDWORD dipdw;
|
DIPROPDWORD dipdw;
|
||||||
|
@ -1675,7 +1675,7 @@ SDL_bool SDL_SYS_IsXInputDeviceIndex(int device_index)
|
||||||
/* return SDL_TRUE if this device was opened with XInput */
|
/* return SDL_TRUE if this device was opened with XInput */
|
||||||
SDL_bool SDL_SYS_IsXInputJoystick(SDL_Joystick * joystick)
|
SDL_bool SDL_SYS_IsXInputJoystick(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
return joystick->hwdata->bXInputDevice;
|
return joystick->hwdata->bXInputDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SDL_JOYSTICK_DINPUT */
|
#endif /* SDL_JOYSTICK_DINPUT */
|
||||||
|
|
Loading…
Reference in a new issue