Use the triggers to test rumble for more fine grained vibration feedback
diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c
index 085f5e5..6ed3105 100644
--- a/test/testgamecontroller.c
+++ b/test/testgamecontroller.c
@@ -114,11 +114,6 @@ loop(void *arg)
case SDL_CONTROLLERBUTTONDOWN:
case SDL_CONTROLLERBUTTONUP:
SDL_Log("Controller button %s %s\n", SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button), event.cbutton.state ? "pressed" : "released");
- /* First button triggers a 0.5 second full strength rumble */
- if (event.type == SDL_CONTROLLERBUTTONDOWN &&
- event.cbutton.button == SDL_CONTROLLER_BUTTON_A) {
- SDL_GameControllerRumble(gamecontroller, 0xFFFF, 0xFFFF, 500);
- }
break;
case SDL_KEYDOWN:
if (event.key.keysym.sym != SDLK_ESCAPE) {
@@ -155,6 +150,13 @@ 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;
+ SDL_GameControllerRumble(gamecontroller, low_frequency_rumble, high_frequency_rumble, 250);
+ }
+
SDL_RenderPresent(screen);
if (!SDL_GameControllerGetAttached(gamecontroller)) {