Check for well known XInput device GUIDs before enumerating the device list.
authorSam Lantinga <slouken@libsdl.org>
Fri, 07 Jun 2013 18:26:55 -0700
changeset 7299 280e86365933
parent 7298 60b241342303
child 7300 ee9c13257398
Check for well known XInput device GUIDs before enumerating the device list.
src/joystick/windows/SDL_dxjoystick.c
--- a/src/joystick/windows/SDL_dxjoystick.c	Fri Jun 07 09:40:07 2013 -0700
+++ b/src/joystick/windows/SDL_dxjoystick.c	Fri Jun 07 18:26:55 2013 -0700
@@ -396,10 +396,10 @@
     }                                               \
 }
 
+DEFINE_GUID(CLSID_WbemLocator,   0x4590f811,0x1d3a,0x11d0,0x89,0x1F,0x00,0xaa,0x00,0x4b,0x2e,0x24);
+DEFINE_GUID(IID_IWbemLocator,    0xdc12a687,0x737f,0x11cf,0x88,0x4d,0x00,0xaa,0x00,0x4b,0x2e,0x24);
 
-DEFINE_GUID(CLSID_WbemLocator,   0x4590f811,0x1d3a,0x11d0,0x89,0x1F,0x00,0xaa,0x00,0x4b,0x2e,0x24);
-/* The Windows SDK doesn't define this GUID */
-DEFINE_GUID(IID_IWbemLocator,    0xdc12a687,0x737f,0x11cf,0x88,0x4d,0x00,0xaa,0x00,0x4b,0x2e,0x24);
+DEFINE_GUID(IID_ValveStreamingGamepad,  MAKELONG( 0x28DE, 0x11FF ),0x0000,0x0000,0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44);
 
 /*-----------------------------------------------------------------------------
  *
@@ -411,6 +411,9 @@
  *-----------------------------------------------------------------------------*/
 BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput )
 {
+    static const GUID *s_XInputProductGUID[] = {
+        &IID_ValveStreamingGamepad
+    };
     IWbemLocator*           pIWbemLocator  = NULL;
     IEnumWbemClassObject*   pEnumDevices   = NULL;
     IWbemClassObject*       pDevices[20];
@@ -430,6 +433,14 @@
         return SDL_FALSE;
     }
 
+    // Check for well known XInput device GUIDs
+    // We need to do this for the Valve Streaming Gamepad because it's virtualized and doesn't show up in the device list.
+    for ( iDevice = 0; iDevice < SDL_arraysize(s_XInputProductGUID); ++iDevice ) {
+        if (SDL_memcmp(pGuidProductFromDirectInput, s_XInputProductGUID[iDevice], sizeof(GUID)) == 0) {
+            return SDL_TRUE;
+        }
+    }
+
     SDL_memset( pDevices, 0x0, sizeof(pDevices) );
 
     /* CoInit if needed */