joystick: Add APIs to query rumble support

This commit is contained in:
Cameron Gutman 2021-11-11 15:53:11 -06:00 committed by Sam Lantinga
parent afccabb881
commit fe09a4930a
8 changed files with 134 additions and 9 deletions

View file

@ -951,6 +951,42 @@ SDL_JoystickHasLED(SDL_Joystick *joystick)
return result;
}
SDL_bool
SDL_JoystickHasRumble(SDL_Joystick *joystick)
{
SDL_bool result;
if (!SDL_PrivateJoystickValid(joystick)) {
return SDL_FALSE;
}
SDL_LockJoysticks();
result = (joystick->driver->GetCapabilities(joystick) & SDL_JOYCAP_RUMBLE) != 0;
SDL_UnlockJoysticks();
return result;
}
SDL_bool
SDL_JoystickHasRumbleTriggers(SDL_Joystick *joystick)
{
SDL_bool result;
if (!SDL_PrivateJoystickValid(joystick)) {
return SDL_FALSE;
}
SDL_LockJoysticks();
result = (joystick->driver->GetCapabilities(joystick) & SDL_JOYCAP_RUMBLE_TRIGGERS) != 0;
SDL_UnlockJoysticks();
return result;
}
int
SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
{