Commit 5545be85307deecf102772a8b943143b92ce7171

Sam Lantinga 2022-08-08T23:44:50

The player LED index wraps for PS5 controllers, like it does for other controller types

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index 5fcdf22..a881a83 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -238,8 +238,9 @@ SetLightsForPlayerIndex(DS5EffectsState_t *effects, int player_index)
         0x1B
     };
 
-    if (player_index >= 0 && player_index < SDL_arraysize(lights)) {
+    if (player_index >= 0) {
         /* Bitmask, 0x1F enables all lights, 0x20 changes instantly instead of fade */
+        player_index %= SDL_arraysize(lights);
         effects->ucPadLights = lights[player_index] | 0x20;
     } else {
         effects->ucPadLights = 0x00;