From 0cfb873f4ff538e89c30da556b8fde8fe5bb59e9 Mon Sep 17 00:00:00 2001 From: minenice55 Date: Wed, 25 Feb 2026 19:12:42 -0500 Subject: [PATCH] convert accelerometer data to gs --- src/sdl/i_video.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sdl/i_video.cpp b/src/sdl/i_video.cpp index 695873dad..bf089779e 100644 --- a/src/sdl/i_video.cpp +++ b/src/sdl/i_video.cpp @@ -1055,17 +1055,19 @@ static void Impl_HandleControllerSensorEvent(SDL_GamepadSensorEvent evt) // data[0]: x acceleration in m/s // data[1]: y acceleration in m/s // data[2]: z acceleration in m/s + // we convert to gs before passing it to the event case SDL_SENSOR_ACCEL: event.type = ev_accelerometer; - event.data1 = FLOAT_TO_FIXED(evt.data[0]); - event.data2 = FLOAT_TO_FIXED(evt.data[1]); - event.data3 = FLOAT_TO_FIXED(evt.data[2]); + event.data1 = FLOAT_TO_FIXED(evt.data[0] / SDL_STANDARD_GRAVITY); + event.data2 = FLOAT_TO_FIXED(evt.data[1] / SDL_STANDARD_GRAVITY); + event.data3 = FLOAT_TO_FIXED(evt.data[2] / SDL_STANDARD_GRAVITY); D_PostEvent(&event); return; // data[0]: delta pitch in rad/s // data[1]: delta yaw in rad/s // data[2]: delta roll in rad/s + // we convert to degrees per second before passing it to the event case SDL_SENSOR_GYRO: #define RAD2DEG 57.295779513f event.type = ev_gyroscope;