Fixed rumble order on PS5
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
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index f2de0ef..f48f54e 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -328,7 +328,7 @@ HIDAPI_DriverPS4_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystic
}
/* In order to send rumble, we have to send a complete effect packet */
- SDL_memset(data, 0, sizeof(data));
+ SDL_zero(data);
if (ctx->is_bluetooth) {
data[0] = k_EPS4ReportIdBluetoothEffects;
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index 3e9b7ac..a2341dd 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -39,7 +39,7 @@
typedef enum
{
k_EPS5ReportIdState = 0x01,
- k_EPS5ReportIDOutput = 0x02,
+ k_EPS5ReportIDOutput = 0x02,
k_EPS5ReportIdBluetoothState = 0x31,
} EPS5ReportId;
@@ -87,22 +87,6 @@ typedef struct
/* There's more unknown data at the end, and a 32-bit CRC on Bluetooth */
} PS5StatePacket_t;
-typedef struct
-{
- Uint8 ucReportID;
- Uint8 ucHeader;
- Uint8 ucEnableBits;
- Uint8 ucRumbleRight;
- Uint8 ucRumbleLeft;
- Uint8 rgucUnknown[3];
- Uint8 ucUnknown;
- Uint8 ucMuteLED;
- Uint8 ucBits;
- Uint8 rgucForceFeedbackRight[11];
- Uint8 rgucForceFeedbackLeft[11];
- Uint8 rgucUnknown2[3];
- Uint8 rgucUnknown3[13];
-} PS5OutputReportPacket_t;
static void ReadFeatureReport(hid_device *dev, Uint8 report_id)
{
@@ -198,14 +182,16 @@ HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
static int
HIDAPI_DriverPS5_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
- PS5OutputReportPacket_t OutputReport;
- SDL_memset( &OutputReport, 0, sizeof( OutputReport ) );
- OutputReport.ucReportID = k_EPS5ReportIDOutput;
- OutputReport.ucHeader = 0x7;
- OutputReport.ucRumbleLeft = high_frequency_rumble >> 8;
- OutputReport.ucRumbleRight = low_frequency_rumble >> 8;
-
- if (SDL_HIDAPI_SendRumble(device, &OutputReport, sizeof(OutputReport)) != sizeof(OutputReport)) {
+ Uint8 data[6];
+
+ /* This works over USB, not over Bluetooth */
+ SDL_zero(data);
+ data[0] = k_EPS5ReportIDOutput;
+ data[1] = 0x7; /* Magic value */
+ data[3] = (high_frequency_rumble >> 8);
+ data[4] = (low_frequency_rumble >> 8);
+
+ if (SDL_HIDAPI_SendRumble(device, data, sizeof(data)) != sizeof(data)) {
return SDL_SetError("Couldn't send rumble packet");
}
return 0;