src/joystick/windows/SDL_windowsjoystick.c
changeset 12090 c3209fca27b2
parent 12088 399cc39583cc
child 12201 8bdc4d340419
equal deleted inserted replaced
12089:d544367b1ef0 12090:c3209fca27b2
   461     } else {
   461     } else {
   462         return SDL_DINPUT_JoystickOpen(joystick, joystickdevice);
   462         return SDL_DINPUT_JoystickOpen(joystick, joystickdevice);
   463     }
   463     }
   464 }
   464 }
   465 
   465 
   466 /* return true if this joystick is plugged in right now */
       
   467 static SDL_bool 
       
   468 WINDOWS_JoystickIsAttached(SDL_Joystick * joystick)
       
   469 {
       
   470     return joystick->hwdata && !joystick->hwdata->removed;
       
   471 }
       
   472 
       
   473 static int
   466 static int
   474 WINDOWS_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
   467 WINDOWS_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
   475 {
   468 {
   476     if (joystick->hwdata->bXInputDevice) {
   469     if (joystick->hwdata->bXInputDevice) {
   477         return SDL_XINPUT_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms);
   470         return SDL_XINPUT_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms);
   481 }
   474 }
   482 
   475 
   483 static void
   476 static void
   484 WINDOWS_JoystickUpdate(SDL_Joystick * joystick)
   477 WINDOWS_JoystickUpdate(SDL_Joystick * joystick)
   485 {
   478 {
   486     if (!joystick->hwdata || joystick->hwdata->removed) {
   479     if (!joystick->hwdata) {
   487         return;
   480         return;
   488     }
   481     }
   489 
   482 
   490     if (joystick->hwdata->bXInputDevice) {
   483     if (joystick->hwdata->bXInputDevice) {
   491         SDL_XINPUT_JoystickUpdate(joystick);
   484         SDL_XINPUT_JoystickUpdate(joystick);
   492     } else {
   485     } else {
   493         SDL_DINPUT_JoystickUpdate(joystick);
   486         SDL_DINPUT_JoystickUpdate(joystick);
   494     }
       
   495 
       
   496     if (joystick->hwdata->removed) {
       
   497         joystick->force_recentering = SDL_TRUE;
       
   498     }
   487     }
   499 }
   488 }
   500 
   489 
   501 /* Function to close a joystick after use */
   490 /* Function to close a joystick after use */
   502 static void
   491 static void
   556     WINDOWS_JoystickDetect,
   545     WINDOWS_JoystickDetect,
   557     WINDOWS_JoystickGetDeviceName,
   546     WINDOWS_JoystickGetDeviceName,
   558     WINDOWS_JoystickGetDeviceGUID,
   547     WINDOWS_JoystickGetDeviceGUID,
   559     WINDOWS_JoystickGetDeviceInstanceID,
   548     WINDOWS_JoystickGetDeviceInstanceID,
   560     WINDOWS_JoystickOpen,
   549     WINDOWS_JoystickOpen,
   561     WINDOWS_JoystickIsAttached,
       
   562     WINDOWS_JoystickRumble,
   550     WINDOWS_JoystickRumble,
   563     WINDOWS_JoystickUpdate,
   551     WINDOWS_JoystickUpdate,
   564     WINDOWS_JoystickClose,
   552     WINDOWS_JoystickClose,
   565     WINDOWS_JoystickQuit,
   553     WINDOWS_JoystickQuit,
   566 };
   554 };