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 7299280e86365933
parent 7298 60b241342303
child 7300 ee9c13257398
Check for well known XInput device GUIDs before enumerating the device list.
src/joystick/windows/SDL_dxjoystick.c
     1.1 --- a/src/joystick/windows/SDL_dxjoystick.c	Fri Jun 07 09:40:07 2013 -0700
     1.2 +++ b/src/joystick/windows/SDL_dxjoystick.c	Fri Jun 07 18:26:55 2013 -0700
     1.3 @@ -396,10 +396,10 @@
     1.4      }                                               \
     1.5  }
     1.6  
     1.7 +DEFINE_GUID(CLSID_WbemLocator,   0x4590f811,0x1d3a,0x11d0,0x89,0x1F,0x00,0xaa,0x00,0x4b,0x2e,0x24);
     1.8 +DEFINE_GUID(IID_IWbemLocator,    0xdc12a687,0x737f,0x11cf,0x88,0x4d,0x00,0xaa,0x00,0x4b,0x2e,0x24);
     1.9  
    1.10 -DEFINE_GUID(CLSID_WbemLocator,   0x4590f811,0x1d3a,0x11d0,0x89,0x1F,0x00,0xaa,0x00,0x4b,0x2e,0x24);
    1.11 -/* The Windows SDK doesn't define this GUID */
    1.12 -DEFINE_GUID(IID_IWbemLocator,    0xdc12a687,0x737f,0x11cf,0x88,0x4d,0x00,0xaa,0x00,0x4b,0x2e,0x24);
    1.13 +DEFINE_GUID(IID_ValveStreamingGamepad,  MAKELONG( 0x28DE, 0x11FF ),0x0000,0x0000,0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44);
    1.14  
    1.15  /*-----------------------------------------------------------------------------
    1.16   *
    1.17 @@ -411,6 +411,9 @@
    1.18   *-----------------------------------------------------------------------------*/
    1.19  BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput )
    1.20  {
    1.21 +    static const GUID *s_XInputProductGUID[] = {
    1.22 +        &IID_ValveStreamingGamepad
    1.23 +    };
    1.24      IWbemLocator*           pIWbemLocator  = NULL;
    1.25      IEnumWbemClassObject*   pEnumDevices   = NULL;
    1.26      IWbemClassObject*       pDevices[20];
    1.27 @@ -430,6 +433,14 @@
    1.28          return SDL_FALSE;
    1.29      }
    1.30  
    1.31 +    // Check for well known XInput device GUIDs
    1.32 +    // We need to do this for the Valve Streaming Gamepad because it's virtualized and doesn't show up in the device list.
    1.33 +    for ( iDevice = 0; iDevice < SDL_arraysize(s_XInputProductGUID); ++iDevice ) {
    1.34 +        if (SDL_memcmp(pGuidProductFromDirectInput, s_XInputProductGUID[iDevice], sizeof(GUID)) == 0) {
    1.35 +            return SDL_TRUE;
    1.36 +        }
    1.37 +    }
    1.38 +
    1.39      SDL_memset( pDevices, 0x0, sizeof(pDevices) );
    1.40  
    1.41      /* CoInit if needed */