src/joystick/winrt/SDL_xinputjoystick.c
changeset 8562 f1aac2d56c76
parent 8552 abd934eac415
child 8609 d59f0f12bf07
equal deleted inserted replaced
8561:c10e5bfa6459 8562:f1aac2d56c76
   104 
   104 
   105         /* TODO, WinRT: try making the device-detection thread wakeup sooner from its CPU-preserving SDL_Delay, if the thread was asked to quit.
   105         /* TODO, WinRT: try making the device-detection thread wakeup sooner from its CPU-preserving SDL_Delay, if the thread was asked to quit.
   106          */
   106          */
   107 
   107 
   108         /* See if any new devices are connected. */
   108         /* See if any new devices are connected. */
       
   109         SDL_LockMutex(g_DeviceInfoLock);
   109         for (i = 0; i < XUSER_MAX_COUNT; ++i) {
   110         for (i = 0; i < XUSER_MAX_COUNT; ++i) {
   110             if (!g_XInputData[i].isDeviceConnected &&
   111             if (!g_XInputData[i].isDeviceConnected &&
   111                 !g_XInputData[i].isDeviceConnectionEventPending &&
   112                 !g_XInputData[i].isDeviceConnectionEventPending &&
   112                 !g_XInputData[i].isDeviceRemovalEventPending)
   113                 !g_XInputData[i].isDeviceRemovalEventPending)
   113             {
   114             {
       
   115                 SDL_UnlockMutex(g_DeviceInfoLock);
   114                 result = XInputGetCapabilities(i, 0, &tempXInputCaps);
   116                 result = XInputGetCapabilities(i, 0, &tempXInputCaps);
       
   117                 SDL_LockMutex(g_DeviceInfoLock);
   115                 if (result == ERROR_SUCCESS) {
   118                 if (result == ERROR_SUCCESS) {
   116                     /* Yes, a device is connected.  Mark it as such.
   119                     /* Yes, a device is connected.  Mark it as such.
   117                        Others will be told about this (via an
   120                        Others will be told about this (via an
   118                        SDL_JOYDEVICEADDED event) in the next call to
   121                        SDL_JOYDEVICEADDED event) in the next call to
   119                        SDL_SYS_JoystickDetect.
   122                        SDL_SYS_JoystickDetect.
   120                      */
   123                      */
   121                     SDL_LockMutex(g_DeviceInfoLock);
       
   122                     g_XInputData[i].isDeviceConnected = SDL_TRUE;
   124                     g_XInputData[i].isDeviceConnected = SDL_TRUE;
   123                     g_XInputData[i].isDeviceConnectionEventPending = SDL_TRUE;
   125                     g_XInputData[i].isDeviceConnectionEventPending = SDL_TRUE;
   124                     SDL_UnlockMutex(g_DeviceInfoLock);
       
   125                 }
   126                 }
   126             }
   127             }
   127         }
   128         }
       
   129         SDL_UnlockMutex(g_DeviceInfoLock);
   128     }
   130     }
   129 
   131 
   130     return 0;
   132     return 0;
   131 }
   133 }
   132 
   134