From 1ee158cd31a381c2c80799b94cc63d7157eb4713 Mon Sep 17 00:00:00 2001 From: Sanjay Govind Date: Tue, 3 Mar 2026 06:45:44 +1300 Subject: [PATCH] fix off by one with tilt on ps3 guitars (#15144) (cherry picked from commit 34378609bb68bf6e653afe8b0a1550b6ef339419) --- src/joystick/hidapi/SDL_hidapi_ps3.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c index 158f90da4c..79575be286 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps3.c +++ b/src/joystick/hidapi/SDL_hidapi_ps3.c @@ -347,6 +347,11 @@ static float HIDAPI_DriverPS3_ScaleAccel(Sint16 value) return ((float)(value - 511) / 113.0f) * SDL_STANDARD_GRAVITY; } +static float HIDAPI_DriverPS3ThirdParty_ScaleAccel(Sint16 value) +{ + return ((float)(value - 512) / 113.0f) * SDL_STANDARD_GRAVITY; +} + static void HIDAPI_DriverPS3_HandleMiniStatePacket(SDL_Joystick *joystick, SDL_DriverPS3_Context *ctx, Uint8 *data, int size) { Sint16 axis; @@ -1020,9 +1025,9 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic if (ctx->report_sensors) { float sensor_data[3]; - sensor_data[0] = -HIDAPI_DriverPS3_ScaleAccel(LOAD16(data[20], data[19])); - sensor_data[1] = -HIDAPI_DriverPS3_ScaleAccel(LOAD16(data[22], data[21])); - sensor_data[2] = -HIDAPI_DriverPS3_ScaleAccel(LOAD16(data[24], data[23])); + sensor_data[0] = -HIDAPI_DriverPS3ThirdParty_ScaleAccel(LOAD16(data[19], data[20])); + sensor_data[1] = -HIDAPI_DriverPS3ThirdParty_ScaleAccel(LOAD16(data[21], data[22])); + sensor_data[2] = -HIDAPI_DriverPS3ThirdParty_ScaleAccel(LOAD16(data[23], data[24])); SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, timestamp, sensor_data, SDL_arraysize(sensor_data)); }