Add SDL_JoystickSetLED.

Currently, this is only supported by the PS4 HIDAPI driver.
This commit is contained in:
Ethan Lee
2020-04-30 11:57:29 -04:00
parent 1b8dee7caf
commit 83cddd2ebc
24 changed files with 229 additions and 1 deletions

View File

@@ -901,6 +901,36 @@ SDL_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16
return result;
}
int
SDL_JoystickSetLED(SDL_Joystick * joystick, Uint8 red, Uint8 green, Uint8 blue)
{
int result;
if (!SDL_PrivateJoystickValid(joystick)) {
return -1;
}
SDL_LockJoysticks();
if (red == joystick->led_red &&
green == joystick->led_green &&
blue == joystick->led_blue) {
/* Avoid spamming the driver */
result = 0;
} else {
result = joystick->driver->SetLED(joystick, red, green, blue);
}
/* Save the LED value regardless of success, so we don't spam the driver */
joystick->led_red = red;
joystick->led_green = green;
joystick->led_blue = blue;
SDL_UnlockJoysticks();
return result;
}
/*
* Close a joystick previously opened with SDL_JoystickOpen()
*/