Commit f4d1f5ed54aecbbccf20e4967b14f965196b7694

Sam Lantinga 2022-10-23T16:35:36

SDL-HIDPS4: fix PS4 Slim controller over BT - it sends the same input report as the it does over USB, but with a larger packet size CR: saml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index 64c3054..b2df90e 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -1010,8 +1010,10 @@ HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 *data, int size
     case k_EPS4ReportIdUsbState:
         /* In the case of a DS4 USB dongle, bit[2] of byte 31 indicates if a DS4 is actually connected (indicated by '0').
          * For non-dongle, this bit is always 0 (connected).
+		 * This is usually the ID over USB, but the DS4v2 that started shipping with the PS4 Slim will also send this
+		 * packet over BT with a size of 128
          */
-        if (size == 64 && (data[31] & 0x04) == 0) {
+        if (size >= 64 && (data[31] & 0x04) == 0) {
             return SDL_TRUE;
         }
         break;