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

From 5545be85307deecf102772a8b943143b92ce7171 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 8 Aug 2022 23:44:50 -0700
Subject: [PATCH] The player LED index wraps for PS5 controllers, like it does
 for other controller types

---
 src/joystick/hidapi/SDL_hidapi_ps5.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index 5fcdf2220cd..a881a838a6d 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;