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) (cherry picked from commit 6bf5f5a221f971a5804062e365a281c30668dd9c)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index e8c60d3..68dfc01 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -320,81 +320,83 @@ 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");
#endif
- size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data));
- /* Get the device capabilities */
- if (size == 48 && data[2] == 0x27) {
- Uint8 capabilities = data[4];
- Uint8 device_type = data[5];
- Uint16 gyro_numerator = LOAD16(data[10], data[11]);
- Uint16 gyro_denominator = LOAD16(data[12], data[13]);
- Uint16 accel_numerator = LOAD16(data[14], data[15]);
- Uint16 accel_denominator = LOAD16(data[16], data[17]);
-
-#ifdef DEBUG_PS4_PROTOCOL
- HIDAPI_DumpPacket("PS4 capabilities: size = %d", data, size);
-#endif
- if (capabilities & 0x02) {
- ctx->sensors_supported = SDL_TRUE;
- }
- if (capabilities & 0x04) {
- ctx->lightbar_supported = SDL_TRUE;
- }
- if (capabilities & 0x08) {
- ctx->vibration_supported = SDL_TRUE;
- }
- if (capabilities & 0x40) {
- ctx->touchpad_supported = SDL_TRUE;
- }
-
- switch (device_type) {
- case 0x00:
- joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
- break;
- case 0x01:
- joystick_type = SDL_JOYSTICK_TYPE_GUITAR;
- break;
- case 0x02:
- joystick_type = SDL_JOYSTICK_TYPE_DRUM_KIT;
- break;
- case 0x04:
- joystick_type = SDL_JOYSTICK_TYPE_DANCE_PAD;
- break;
- case 0x06:
- joystick_type = SDL_JOYSTICK_TYPE_WHEEL;
- break;
- case 0x07:
- joystick_type = SDL_JOYSTICK_TYPE_ARCADE_STICK;
- break;
- case 0x08:
- joystick_type = SDL_JOYSTICK_TYPE_FLIGHT_STICK;
- break;
- default:
- joystick_type = SDL_JOYSTICK_TYPE_UNKNOWN;
- break;
- }
-
- if (gyro_numerator && gyro_denominator) {
- ctx->gyro_numerator = gyro_numerator;
- ctx->gyro_denominator = gyro_denominator;
- }
- if (accel_numerator && accel_denominator) {
- ctx->accel_numerator = accel_numerator;
- ctx->accel_denominator = accel_denominator;
- }
- } else if (device->vendor_id == USB_VENDOR_SONY) {
+ 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) {
- /* The Razer Raiju doesn't respond to the detection protocol, but has a touchpad and vibration */
- ctx->vibration_supported = SDL_TRUE;
- ctx->touchpad_supported = SDL_TRUE;
+ } else {
+ size = ReadFeatureReport(device->dev, k_ePS4FeatureReportIdCapabilities, data, sizeof(data));
+ /* Get the device capabilities */
+ if (size == 48 && data[2] == 0x27) {
+ Uint8 capabilities = data[4];
+ Uint8 device_type = data[5];
+ Uint16 gyro_numerator = LOAD16(data[10], data[11]);
+ Uint16 gyro_denominator = LOAD16(data[12], data[13]);
+ Uint16 accel_numerator = LOAD16(data[14], data[15]);
+ Uint16 accel_denominator = LOAD16(data[16], data[17]);
- if (device->product_id == USB_PRODUCT_RAZER_TOURNAMENT_EDITION_BLUETOOTH ||
- device->product_id == USB_PRODUCT_RAZER_ULTIMATE_EDITION_BLUETOOTH) {
- device->is_bluetooth = SDL_TRUE;
+#ifdef DEBUG_PS4_PROTOCOL
+ HIDAPI_DumpPacket("PS4 capabilities: size = %d", data, size);
+#endif
+ if (capabilities & 0x02) {
+ ctx->sensors_supported = SDL_TRUE;
+ }
+ if (capabilities & 0x04) {
+ ctx->lightbar_supported = SDL_TRUE;
+ }
+ if (capabilities & 0x08) {
+ ctx->vibration_supported = SDL_TRUE;
+ }
+ if (capabilities & 0x40) {
+ ctx->touchpad_supported = SDL_TRUE;
+ }
+
+ switch (device_type) {
+ case 0x00:
+ joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
+ break;
+ case 0x01:
+ joystick_type = SDL_JOYSTICK_TYPE_GUITAR;
+ break;
+ case 0x02:
+ joystick_type = SDL_JOYSTICK_TYPE_DRUM_KIT;
+ break;
+ case 0x04:
+ joystick_type = SDL_JOYSTICK_TYPE_DANCE_PAD;
+ break;
+ case 0x06:
+ joystick_type = SDL_JOYSTICK_TYPE_WHEEL;
+ break;
+ case 0x07:
+ joystick_type = SDL_JOYSTICK_TYPE_ARCADE_STICK;
+ break;
+ case 0x08:
+ joystick_type = SDL_JOYSTICK_TYPE_FLIGHT_STICK;
+ break;
+ default:
+ joystick_type = SDL_JOYSTICK_TYPE_UNKNOWN;
+ break;
+ }
+
+ if (gyro_numerator && gyro_denominator) {
+ ctx->gyro_numerator = gyro_numerator;
+ ctx->gyro_denominator = gyro_denominator;
+ }
+ if (accel_numerator && accel_denominator) {
+ ctx->accel_numerator = accel_numerator;
+ ctx->accel_denominator = accel_denominator;
+ }
+ } else if (device->vendor_id == USB_VENDOR_RAZER) {
+ /* The Razer Raiju doesn't respond to the detection protocol, but has a touchpad and vibration */
+ ctx->vibration_supported = SDL_TRUE;
+ ctx->touchpad_supported = SDL_TRUE;
+
+ if (device->product_id == USB_PRODUCT_RAZER_TOURNAMENT_EDITION_BLUETOOTH ||
+ device->product_id == USB_PRODUCT_RAZER_ULTIMATE_EDITION_BLUETOOTH) {
+ device->is_bluetooth = SDL_TRUE;
+ }
}
}
ctx->effects_supported = (ctx->lightbar_supported || ctx->vibration_supported);