Don't send k_ePS4FeatureReportIdCapabilities to Sony PS4 controllers

This report is for third party controllers only, and might be causing issues with fake PS4 controllers.

Reference https://github.com/libsdl-org/SDL/issues/7960

(cherry picked from commit 092a4b780ca464de71b89ffa5dc655ce256ce350)
This commit is contained in:
Sam Lantinga 2023-07-10 09:15:02 -07:00
parent 92fd2938e7
commit 6bf5f5a221

View file

@ -320,6 +320,13 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
SDL_Log("PS4 dongle = %s, bluetooth = %s\n", ctx->is_dongle ? "TRUE" : "FALSE", device->is_bluetooth ? "TRUE" : "FALSE"); SDL_Log("PS4 dongle = %s, bluetooth = %s\n", ctx->is_dongle ? "TRUE" : "FALSE", device->is_bluetooth ? "TRUE" : "FALSE");
#endif #endif
if (device->vendor_id == USB_VENDOR_SONY) {
ctx->official_controller = SDL_TRUE;
ctx->sensors_supported = SDL_TRUE;
ctx->lightbar_supported = SDL_TRUE;
ctx->vibration_supported = SDL_TRUE;
ctx->touchpad_supported = SDL_TRUE;
} else {
size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data)); size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data));
/* Get the device capabilities */ /* Get the device capabilities */
if (size == 48 && data[2] == 0x27) { if (size == 48 && data[2] == 0x27) {
@ -381,12 +388,6 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
ctx->accel_numerator = accel_numerator; ctx->accel_numerator = accel_numerator;
ctx->accel_denominator = accel_denominator; ctx->accel_denominator = accel_denominator;
} }
} else if (device->vendor_id == USB_VENDOR_SONY) {
ctx->official_controller = SDL_TRUE;
ctx->sensors_supported = SDL_TRUE;
ctx->lightbar_supported = SDL_TRUE;
ctx->vibration_supported = SDL_TRUE;
ctx->touchpad_supported = SDL_TRUE;
} else if (device->vendor_id == USB_VENDOR_RAZER) { } else if (device->vendor_id == USB_VENDOR_RAZER) {
/* The Razer Raiju doesn't respond to the detection protocol, but has a touchpad and vibration */ /* The Razer Raiju doesn't respond to the detection protocol, but has a touchpad and vibration */
ctx->vibration_supported = SDL_TRUE; ctx->vibration_supported = SDL_TRUE;
@ -397,6 +398,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
device->is_bluetooth = SDL_TRUE; device->is_bluetooth = SDL_TRUE;
} }
} }
}
ctx->effects_supported = (ctx->lightbar_supported || ctx->vibration_supported); ctx->effects_supported = (ctx->lightbar_supported || ctx->vibration_supported);
if (device->vendor_id == USB_VENDOR_PDP && if (device->vendor_id == USB_VENDOR_PDP &&