Commit c501d159a90bcc0525eef5af8a6978e9fe334f79

Sam Lantinga 2021-10-03T14:10:21

Fixed range for Steam Controller sensor values

diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c
index b015e6b..fdec0f0 100644
--- a/src/joystick/hidapi/SDL_hidapi_steam.c
+++ b/src/joystick/hidapi/SDL_hidapi_steam.c
@@ -1236,14 +1236,14 @@ HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device)
             if (ctx->report_sensors) {
                 float values[3];
 
-                values[0] = (ctx->m_state.sGyroX / 32767.0f) * (2000.0f * (M_PI / 180.0f));
-                values[1] = (ctx->m_state.sGyroZ / 32767.0f) * (2000.0f * (M_PI / 180.0f));
-                values[2] = (ctx->m_state.sGyroY / 32767.0f) * (2000.0f * (M_PI / 180.0f));
+                values[0] = (ctx->m_state.sGyroX / 32768.0f) * (2000.0f * (M_PI / 180.0f));
+                values[1] = (ctx->m_state.sGyroZ / 32768.0f) * (2000.0f * (M_PI / 180.0f));
+                values[2] = (ctx->m_state.sGyroY / 32768.0f) * (2000.0f * (M_PI / 180.0f));
                 SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, values, 3);
 
-                values[0] = (ctx->m_state.sAccelX / 32767.0f) * 2.0f * SDL_STANDARD_GRAVITY;
-                values[1] = (ctx->m_state.sAccelZ / 32767.0f) * 2.0f * SDL_STANDARD_GRAVITY;
-                values[2] = (-ctx->m_state.sAccelY / 32767.0f) * 2.0f * SDL_STANDARD_GRAVITY;
+                values[0] = (ctx->m_state.sAccelX / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
+                values[1] = (ctx->m_state.sAccelZ / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
+                values[2] = (-ctx->m_state.sAccelY / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY;
                 SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, values, 3);
             }