From 1f2f536bd25e6ceccf792c9b6ab1eb67386f1463 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 27 Nov 2020 18:57:40 -0800 Subject: [PATCH] Fixed XInput correlation for raw input controllers after hotplug events --- src/joystick/windows/SDL_rawinputjoystick.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index b85c9cade..b5041715f 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -635,6 +635,17 @@ RAWINPUT_AcquireDevice(SDL_RAWINPUT_Device *device) static void RAWINPUT_ReleaseDevice(SDL_RAWINPUT_Device *device) { +#ifdef SDL_JOYSTICK_RAWINPUT_XINPUT + if (device->joystick) { + RAWINPUT_DeviceContext *ctx = device->joystick->hwdata; + + if (ctx->xinput_enabled && ctx->xinput_correlated) { + RAWINPUT_MarkXInputSlotFree(ctx->xinput_slot); + ctx->xinput_correlated = SDL_FALSE; + } + } +#endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */ + if (SDL_AtomicDecRef(&device->refcount)) { if (device->preparsed_data) { SDL_HidD_FreePreparsedData(device->preparsed_data);