Răsfoiți Sursa

Implemented SDL_GameControllerGetFirmwareVersion() for HIDAPI PS5 controllers

Sam Lantinga 2 ani în urmă
părinte
comite
9202df0472
1 a modificat fișierele cu 8 adăugiri și 0 ștergeri
  1. 8 0
      src/joystick/hidapi/SDL_hidapi_ps5.c

+ 8 - 0
src/joystick/hidapi/SDL_hidapi_ps5.c

@@ -59,6 +59,7 @@ typedef enum
 {
     k_EPS5FeatureReportIdCalibration = 0x05,
     k_EPS5FeatureReportIdSerialNumber = 0x09,
+    k_EPS5FeatureReportIdFirmwareInfo = 0x20,
 } EPS5FeatureReportId;
 
 typedef struct
@@ -601,6 +602,13 @@ HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
                 data[6], data[5], data[4], data[3], data[2], data[1]);
             joystick->serial = SDL_strdup(serial);
         }
+
+        /* Read the firmware version
+           This will also enable enhanced reports over Bluetooth
+        */
+        if (ReadFeatureReport(device->dev, k_EPS5FeatureReportIdFirmwareInfo, data, USB_PACKET_LENGTH) >= 46) {
+            joystick->firmware_version = (Uint16)data[44] | ((Uint16)data[45] << 8);
+        }
     }
 
     if (!joystick->serial && device->serial && SDL_strlen(device->serial) == 12) {