mirror of https://github.com/encounter/SDL.git
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 */
|
/* Update rumble based on trigger state */
|
||||||
{
|
{
|
||||||
Uint16 low_frequency_rumble = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_TRIGGERLEFT) * 2;
|
Sint16 left = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_TRIGGERLEFT);
|
||||||
Uint16 high_frequency_rumble = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_TRIGGERRIGHT) * 2;
|
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);
|
SDL_GameControllerRumble(gamecontroller, low_frequency_rumble, high_frequency_rumble, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update trigger rumble based on thumbstick state */
|
/* Update trigger rumble based on thumbstick state */
|
||||||
{
|
{
|
||||||
Sint16 left_y = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_LEFTY);
|
Sint16 left = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_LEFTY);
|
||||||
Sint16 right_y = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_RIGHTY);
|
Sint16 right = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_RIGHTY);
|
||||||
Uint16 left_rumble = ConvertAxisToRumble(~left_y);
|
Uint16 left_rumble = ConvertAxisToRumble(~left);
|
||||||
Uint16 right_rumble = ConvertAxisToRumble(~right_y);
|
Uint16 right_rumble = ConvertAxisToRumble(~right);
|
||||||
|
|
||||||
SDL_GameControllerRumbleTriggers(gamecontroller, left_rumble, right_rumble, 250);
|
SDL_GameControllerRumbleTriggers(gamecontroller, left_rumble, right_rumble, 250);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue