Fixed Xbox 360 wireless controller being picked up by WGI when it's being managed by RAWINPUT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c
index daa7590..6852910 100644
--- a/src/joystick/windows/SDL_dinputjoystick.c
+++ b/src/joystick/windows/SDL_dinputjoystick.c
@@ -674,7 +674,7 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
#endif
#ifdef SDL_JOYSTICK_RAWINPUT
- if (RAWINPUT_IsDevicePresent(vendor, product, 0)) {
+ if (RAWINPUT_IsDevicePresent(vendor, product, 0, pNewJoystick->joystickname)) {
/* The RAWINPUT driver is taking care of this device */
SDL_free(pNewJoystick);
return DIENUM_CONTINUE;
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index 2970187..77a1f3d 100644
--- a/src/joystick/windows/SDL_rawinputjoystick.c
+++ b/src/joystick/windows/SDL_rawinputjoystick.c
@@ -923,7 +923,7 @@ RAWINPUT_IsEnabled()
}
SDL_bool
-RAWINPUT_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version)
+RAWINPUT_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
{
SDL_RAWINPUT_Device *device;
@@ -932,9 +932,16 @@ RAWINPUT_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version)
device = SDL_RAWINPUT_devices;
while (device) {
- if (device->vendor_id == vendor_id && device->product_id == product_id) {
+ if (vendor_id == device->vendor_id && product_id == device->product_id ) {
return SDL_TRUE;
}
+
+ /* The Xbox 360 wireless controller shows up as product 0 in WGI */
+ if (vendor_id == device->vendor_id && product_id == 0 &&
+ name && SDL_strstr(device->name, name) != NULL) {
+ return SDL_TRUE;
+ }
+
device = device->next;
}
return SDL_FALSE;
diff --git a/src/joystick/windows/SDL_rawinputjoystick_c.h b/src/joystick/windows/SDL_rawinputjoystick_c.h
index b7d2e63..4543798 100644
--- a/src/joystick/windows/SDL_rawinputjoystick_c.h
+++ b/src/joystick/windows/SDL_rawinputjoystick_c.h
@@ -25,7 +25,7 @@
extern SDL_bool RAWINPUT_IsEnabled();
/* Return true if a RawInput device is present and supported as a joystick */
-extern SDL_bool RAWINPUT_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version);
+extern SDL_bool RAWINPUT_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name);
/* Returns 0 if message was handled */
extern LRESULT RAWINPUT_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c
index 9ae24b9..c1c306b 100644
--- a/src/joystick/windows/SDL_windows_gaming_input.c
+++ b/src/joystick/windows/SDL_windows_gaming_input.c
@@ -249,7 +249,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde
#endif
#ifdef SDL_JOYSTICK_RAWINPUT
- if (!ignore_joystick && RAWINPUT_IsDevicePresent(vendor, product, version)) {
+ if (!ignore_joystick && RAWINPUT_IsDevicePresent(vendor, product, version, name)) {
ignore_joystick = SDL_TRUE;
}
#endif
diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c
index 715b547..bd71c54 100644
--- a/src/joystick/windows/SDL_xinputjoystick.c
+++ b/src/joystick/windows/SDL_xinputjoystick.c
@@ -302,7 +302,7 @@ AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
#endif
#ifdef SDL_JOYSTICK_RAWINPUT
- if (RAWINPUT_IsDevicePresent(vendor, product, version)) {
+ if (RAWINPUT_IsDevicePresent(vendor, product, version, pNewJoystick->joystickname)) {
/* The RAWINPUT driver is taking care of this device */
SDL_free(pNewJoystick);
return;