mirror of https://github.com/encounter/SDL.git
Fixed crash trying to open HIDAPI controller as a haptics device on Windows
This commit is contained in:
parent
38ae49880f
commit
f1bc1c1274
|
@ -157,7 +157,7 @@ SDL_SYS_HapticMouse(void)
|
||||||
|
|
||||||
/* Grab the first mouse haptic device we find. */
|
/* Grab the first mouse haptic device we find. */
|
||||||
for (item = SDL_hapticlist; item != NULL; item = item->next) {
|
for (item = SDL_hapticlist; item != NULL; item = item->next) {
|
||||||
if (item->capabilities.dwDevType == DI8DEVCLASS_POINTER ) {
|
if (item->capabilities.dwDevType == DI8DEVCLASS_POINTER) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
|
@ -173,14 +173,16 @@ SDL_SYS_HapticMouse(void)
|
||||||
int
|
int
|
||||||
SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
|
SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
const struct joystick_hwdata *hwdata = joystick->hwdata;
|
if (joystick->driver != &SDL_WINDOWS_JoystickDriver) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#if SDL_HAPTIC_XINPUT
|
#if SDL_HAPTIC_XINPUT
|
||||||
if (hwdata->bXInputHaptic) {
|
if (joystick->hwdata->bXInputHaptic) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if SDL_HAPTIC_DINPUT
|
#if SDL_HAPTIC_DINPUT
|
||||||
if (hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
|
if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -193,6 +195,9 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
|
||||||
int
|
int
|
||||||
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
|
if (joystick->driver != &SDL_WINDOWS_JoystickDriver) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (joystick->hwdata->bXInputHaptic != haptic->hwdata->bXInputHaptic) {
|
if (joystick->hwdata->bXInputHaptic != haptic->hwdata->bXInputHaptic) {
|
||||||
return 0; /* one is XInput, one is not; not the same device. */
|
return 0; /* one is XInput, one is not; not the same device. */
|
||||||
} else if (joystick->hwdata->bXInputHaptic) {
|
} else if (joystick->hwdata->bXInputHaptic) {
|
||||||
|
@ -208,6 +213,8 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||||
int
|
int
|
||||||
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||||
{
|
{
|
||||||
|
SDL_assert(joystick->driver == &SDL_WINDOWS_JoystickDriver);
|
||||||
|
|
||||||
if (joystick->hwdata->bXInputDevice) {
|
if (joystick->hwdata->bXInputDevice) {
|
||||||
return SDL_XINPUT_HapticOpenFromJoystick(haptic, joystick);
|
return SDL_XINPUT_HapticOpenFromJoystick(haptic, joystick);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue