src/joystick/windows/SDL_dxjoystick.c
changeset 7223 76fa20889de8
parent 7191 75360622e65f
child 7230 757e9812ef1c
equal deleted inserted replaced
7222:2435b221d77d 7223:76fa20889de8
   371     }                                               \
   371     }                                               \
   372 }
   372 }
   373 
   373 
   374 
   374 
   375 DEFINE_GUID(CLSID_WbemLocator,   0x4590f811,0x1d3a,0x11d0,0x89,0x1F,0x00,0xaa,0x00,0x4b,0x2e,0x24);
   375 DEFINE_GUID(CLSID_WbemLocator,   0x4590f811,0x1d3a,0x11d0,0x89,0x1F,0x00,0xaa,0x00,0x4b,0x2e,0x24);
       
   376 #ifndef __IWbemLocator_INTERFACE_DEFINED__
   376 DEFINE_GUID(IID_IWbemLocator,    0xdc12a687,0x737f,0x11cf,0x88,0x4d,0x00,0xaa,0x00,0x4b,0x2e,0x24);
   377 DEFINE_GUID(IID_IWbemLocator,    0xdc12a687,0x737f,0x11cf,0x88,0x4d,0x00,0xaa,0x00,0x4b,0x2e,0x24);
       
   378 #endif
   377 
   379 
   378 /*-----------------------------------------------------------------------------
   380 /*-----------------------------------------------------------------------------
   379  *
   381  *
   380  * code from MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ee417014(v=vs.85).aspx
   382  * code from MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ee417014(v=vs.85).aspx
   381  *
   383  *
   544 /* Function/thread to scan the system for joysticks.
   546 /* Function/thread to scan the system for joysticks.
   545  */
   547  */
   546 static int
   548 static int
   547 SDL_JoystickThread(void *_data)
   549 SDL_JoystickThread(void *_data)
   548 {
   550 {
   549     HRESULT result = S_OK;
       
   550     HWND messageWindow = 0;
   551     HWND messageWindow = 0;
   551     HDEVNOTIFY hNotify = 0;
   552     HDEVNOTIFY hNotify = 0;
   552     DEV_BROADCAST_DEVICEINTERFACE dbh;
   553     DEV_BROADCAST_DEVICEINTERFACE dbh;
   553     SDL_bool bOpenedXInputDevices[4];
   554     SDL_bool bOpenedXInputDevices[4];
   554     WNDCLASSEX wincl;
   555     WNDCLASSEX wincl;
   555 
   556 
   556     SDL_memset( bOpenedXInputDevices, 0x0, sizeof(bOpenedXInputDevices) );
   557     SDL_memset( bOpenedXInputDevices, 0x0, sizeof(bOpenedXInputDevices) );
   557 
   558 
   558     result = WIN_CoInitialize();
   559     WIN_CoInitialize();
   559 
   560 
   560     SDL_memset( &wincl, 0x0, sizeof(wincl) );
   561     SDL_memset( &wincl, 0x0, sizeof(wincl) );
   561     wincl.hInstance = GetModuleHandle( NULL );
   562     wincl.hInstance = GetModuleHandle( NULL );
   562     wincl.lpszClassName = L"Message";
   563     wincl.lpszClassName = L"Message";
   563     wincl.lpfnWndProc = SDL_PrivateJoystickDetectProc;      /* This function is called by windows */
   564     wincl.lpfnWndProc = SDL_PrivateJoystickDetectProc;      /* This function is called by windows */
   811 }
   812 }
   812 
   813 
   813 /* detect any new joysticks being inserted into the system */
   814 /* detect any new joysticks being inserted into the system */
   814 void SDL_SYS_JoystickDetect()
   815 void SDL_SYS_JoystickDetect()
   815 {
   816 {
   816     HRESULT result;
       
   817     JoyStick_DeviceData *pCurList = NULL;
   817     JoyStick_DeviceData *pCurList = NULL;
   818     /* only enum the devices if the joystick thread told us something changed */
   818     /* only enum the devices if the joystick thread told us something changed */
   819     if ( s_bDeviceAdded || s_bDeviceRemoved )
   819     if ( s_bDeviceAdded || s_bDeviceRemoved )
   820     {
   820     {
   821         s_bDeviceAdded = SDL_FALSE;
   821         s_bDeviceAdded = SDL_FALSE;
   830             s_pKnownJoystickGUIDs = SDL_malloc( sizeof(GUID)*MAX_JOYSTICKS );
   830             s_pKnownJoystickGUIDs = SDL_malloc( sizeof(GUID)*MAX_JOYSTICKS );
   831 
   831 
   832         SDL_memset( s_pKnownJoystickGUIDs, 0x0, sizeof(GUID)*MAX_JOYSTICKS );
   832         SDL_memset( s_pKnownJoystickGUIDs, 0x0, sizeof(GUID)*MAX_JOYSTICKS );
   833 
   833 
   834         /* Look for joysticks, wheels, head trackers, gamepads, etc.. */
   834         /* Look for joysticks, wheels, head trackers, gamepads, etc.. */
   835         result = IDirectInput8_EnumDevices(dinput,
   835         IDirectInput8_EnumDevices(dinput,
   836             DI8DEVCLASS_GAMECTRL,
   836             DI8DEVCLASS_GAMECTRL,
   837             EnumJoysticksCallback,
   837             EnumJoysticksCallback,
   838             &pCurList, DIEDFL_ATTACHEDONLY);
   838             &pCurList, DIEDFL_ATTACHEDONLY);
   839 
   839 
   840         SDL_UnlockMutex( s_mutexJoyStickEnum );
   840         SDL_UnlockMutex( s_mutexJoyStickEnum );