mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-17 18:28:28 +00:00
Added SDL_JoystickHasLED
Currently, this is only supported by the PS4 HIDAPI driver.
This commit is contained in:
parent
83cddd2ebc
commit
e555d45331
27 changed files with 278 additions and 75 deletions
|
@ -193,6 +193,18 @@ loop(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
/* Update LED based on left thumbstick position */
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
Sint16 x = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_LEFTX);
|
||||
Sint16 y = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_LEFTY);
|
||||
|
||||
r = (Uint8)((float)(((int)x + 32767) * 255) / 65535);
|
||||
b = (Uint8)((float)(((int)y + 32767) * 255) / 65535);
|
||||
g = (Uint8)((int)(r + b) / 2);
|
||||
SDL_GameControllerSetLED(gamecontroller, r, g, b);
|
||||
}
|
||||
|
||||
/* Update rumble based on trigger state */
|
||||
{
|
||||
Uint16 low_frequency_rumble = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_TRIGGERLEFT) * 2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue