mirror of
https://github.com/shadps4-emu/ext-SDL.git
synced 2024-12-18 08:18:35 +00:00
Some controllers don't always reset their triggers to zero when they are released (e.g. Xbox One S in Bluetooth mode), so only trigger rumble if the trigger is pulled halfway or more.
This commit is contained in:
parent
6a7f29cdbb
commit
24cc0012f0
@ -308,17 +308,19 @@ loop(void *arg)
|
||||
|
||||
/* Update rumble based on trigger state */
|
||||
{
|
||||
Uint16 low_frequency_rumble = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_TRIGGERLEFT) * 2;
|
||||
Uint16 high_frequency_rumble = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_TRIGGERRIGHT) * 2;
|
||||
Sint16 left = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_TRIGGERLEFT);
|
||||
Sint16 right = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
|
||||
Uint16 low_frequency_rumble = ConvertAxisToRumble(left);
|
||||
Uint16 high_frequency_rumble = ConvertAxisToRumble(right);
|
||||
SDL_GameControllerRumble(gamecontroller, low_frequency_rumble, high_frequency_rumble, 250);
|
||||
}
|
||||
|
||||
/* Update trigger rumble based on thumbstick state */
|
||||
{
|
||||
Sint16 left_y = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_LEFTY);
|
||||
Sint16 right_y = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_RIGHTY);
|
||||
Uint16 left_rumble = ConvertAxisToRumble(~left_y);
|
||||
Uint16 right_rumble = ConvertAxisToRumble(~right_y);
|
||||
Sint16 left = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_LEFTY);
|
||||
Sint16 right = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_RIGHTY);
|
||||
Uint16 left_rumble = ConvertAxisToRumble(~left);
|
||||
Uint16 right_rumble = ConvertAxisToRumble(~right);
|
||||
|
||||
SDL_GameControllerRumbleTriggers(gamecontroller, left_rumble, right_rumble, 250);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user