Wired up haptic hotplugging for Windows DirectInput/XInput code.

This commit is contained in:
Ryan C. Gordon 2014-02-06 07:37:20 -05:00
parent 884709423e
commit 441bde12ca
3 changed files with 334 additions and 95 deletions

View file

@ -49,6 +49,10 @@
#define INITGUID /* Only set here, if set twice will cause mingw32 to break. */
#include "SDL_dxjoystick_c.h"
#if SDL_HAPTIC_DINPUT
#include "../../haptic/windows/SDL_syshaptic_c.h" /* For haptic hot plugging */
#endif
#ifndef DIDFT_OPTIONAL
#define DIDFT_OPTIONAL 0x80000000
#endif
@ -824,7 +828,17 @@ void SDL_SYS_JoystickDetect()
while ( pCurList )
{
JoyStick_DeviceData *pListNext = NULL;
#if SDL_HAPTIC_DINPUT
if (pCurList->bXInputDevice) {
XInputHaptic_MaybeRemoveDevice(pCurList->XInputUserId);
} else {
DirectInputHaptic_MaybeRemoveDevice(&pCurList->dxdevice);
}
#endif
#if !SDL_EVENTS_DISABLED
{
SDL_Event event;
event.type = SDL_JOYDEVICEREMOVED;
@ -835,6 +849,7 @@ void SDL_SYS_JoystickDetect()
SDL_PushEvent(&event);
}
}
}
#endif /* !SDL_EVENTS_DISABLED */
pListNext = pCurList->pNext;
@ -855,7 +870,16 @@ void SDL_SYS_JoystickDetect()
{
if ( pNewJoystick->send_add_event )
{
#if SDL_HAPTIC_DINPUT
if (pNewJoystick->bXInputDevice) {
XInputHaptic_MaybeAddDevice(pNewJoystick->XInputUserId);
} else {
DirectInputHaptic_MaybeAddDevice(&pNewJoystick->dxdevice);
}
#endif
#if !SDL_EVENTS_DISABLED
{
SDL_Event event;
event.type = SDL_JOYDEVICEADDED;
@ -866,6 +890,7 @@ void SDL_SYS_JoystickDetect()
SDL_PushEvent(&event);
}
}
}
#endif /* !SDL_EVENTS_DISABLED */
pNewJoystick->send_add_event = 0;
}