Commit 120bc77e91da50a72d6dec4050c2f87deb84b1ca

Sam Lantinga 2023-04-19T13:10:39

Report PS3 accelerometer values in m/s2 instead of Gs (cherry picked from commit 0467301baf57389d96fafbe169fb07f4c10169bc)

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c
index 5add7e3..d5e00ba 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps3.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps3.c
@@ -311,7 +311,7 @@ static float HIDAPI_DriverPS3_ScaleAccel(Sint16 value)
 {
     /* Accelerometer values are in big endian order */
     value = SDL_SwapBE16(value);
-    return (float)(value - 511) / 113.0f;
+    return ((float)(value - 511) / 113.0f) * SDL_STANDARD_GRAVITY;
 }
 
 static void HIDAPI_DriverPS3_HandleMiniStatePacket(SDL_Joystick *joystick, SDL_DriverPS3_Context *ctx, Uint8 *data, int size)