Fixed SDL_HapticOpenFromJoystick() with DirectInput devices.

This commit is contained in:
Ryan C. Gordon 2014-03-17 19:11:18 -04:00
parent cf3ff16e94
commit 7eaf899796
2 changed files with 39 additions and 30 deletions

View file

@ -658,6 +658,14 @@ SDL_SYS_HapticOpenFromDevice8(SDL_Haptic * haptic,
haptic->hwdata->device = device8; haptic->hwdata->device = device8;
haptic->hwdata->is_joystick = is_joystick; haptic->hwdata->is_joystick = is_joystick;
/* !!! FIXME: opening a haptic device here first will make an attempt to
!!! FIXME: SDL_JoystickOpen() that same device fail later, since we
!!! FIXME: have it open in exclusive mode. But this will allow
!!! FIXME: SDL_JoystickOpen() followed by SDL_HapticOpenFromJoystick()
!!! FIXME: to work, and that's probably the common case. Still,
!!! FIXME: ideally, We need to unify the opening code. */
if (!is_joystick) { /* if is_joystick, we already set this up elsewhere. */
/* Grab it exclusively to use force feedback stuff. */ /* Grab it exclusively to use force feedback stuff. */
ret = IDirectInputDevice8_SetCooperativeLevel(haptic->hwdata->device, ret = IDirectInputDevice8_SetCooperativeLevel(haptic->hwdata->device,
SDL_HelperWindow, SDL_HelperWindow,
@ -691,6 +699,7 @@ SDL_SYS_HapticOpenFromDevice8(SDL_Haptic * haptic,
DI_SetError("Acquiring DirectInput device", ret); DI_SetError("Acquiring DirectInput device", ret);
goto acquire_err; goto acquire_err;
} }
}
/* Reset all actuators - just in case. */ /* Reset all actuators - just in case. */
ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,

View file

@ -1025,7 +1025,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
result = result =
IDirectInputDevice8_SetCooperativeLevel(joystick->hwdata-> IDirectInputDevice8_SetCooperativeLevel(joystick->hwdata->
InputDevice, SDL_HelperWindow, InputDevice, SDL_HelperWindow,
DISCL_NONEXCLUSIVE | DISCL_EXCLUSIVE |
DISCL_BACKGROUND); DISCL_BACKGROUND);
if (FAILED(result)) { if (FAILED(result)) {
return SetDIerror("IDirectInputDevice8::SetCooperativeLevel", result); return SetDIerror("IDirectInputDevice8::SetCooperativeLevel", result);