Implemented SDL_GameControllerGetFirmwareVersion() for HIDAPI PS5 controllers

This commit is contained in:
Sam Lantinga 2022-06-09 18:11:34 -07:00
parent e5a3acd6bd
commit 9202df0472

View file

@ -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) {