Worked around bug with Sony PS Now PS3 controller where DirectInput polling will continue to return success after the controller is unplugged.
The code is now reliant on SDL_PrivateJoystickAdded() and SDL_PrivateJoystickRemoved() being called correctly when devices are added or removed on Windows
This commit is contained in:
parent
90f9ce1e41
commit
29023f51e8
17 changed files with 31 additions and 118 deletions
|
@ -270,6 +270,15 @@ AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
|
|||
WINDOWS_AddJoystickDevice(pNewJoystick);
|
||||
}
|
||||
|
||||
static void
|
||||
DelXInputDevice(Uint8 userid)
|
||||
{
|
||||
if (s_arrXInputDevicePath[userid]) {
|
||||
SDL_free(s_arrXInputDevicePath[userid]);
|
||||
s_arrXInputDevicePath[userid] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
|
||||
{
|
||||
|
@ -285,6 +294,8 @@ SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
|
|||
XINPUT_CAPABILITIES capabilities;
|
||||
if (XINPUTGETCAPABILITIES(userid, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS) {
|
||||
AddXInputDevice(userid, capabilities.SubType, pContext);
|
||||
} else {
|
||||
DelXInputDevice(userid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -456,14 +467,6 @@ SDL_XINPUT_JoystickUpdate(SDL_Joystick * joystick)
|
|||
|
||||
result = XINPUTGETSTATE(joystick->hwdata->userid, &XInputState);
|
||||
if (result == ERROR_DEVICE_NOT_CONNECTED) {
|
||||
Uint8 userid = joystick->hwdata->userid;
|
||||
|
||||
joystick->hwdata->send_remove_event = SDL_TRUE;
|
||||
joystick->hwdata->removed = SDL_TRUE;
|
||||
if (s_arrXInputDevicePath[userid]) {
|
||||
SDL_free(s_arrXInputDevicePath[userid]);
|
||||
s_arrXInputDevicePath[userid] = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue