Level the six-axis orientation from the first real accelerometer reading and pull it toward gravity at 4/s while the controller is held still, so a bow aimed right after the game starts or after a load no longer turns sideways when the controller is tilted up or down

This commit is contained in:
ipavlin98 authored and Valiantsin Dzerakh committed 2026-11-18 09:00:12 +03:00
1 parent 6b0974f08d
commit b155be1881
3 files changed
+42 -15

No files matched your search

+6 -4
View File
@@ -1025,10 +1025,12 @@ static int sensors_ready(void) {
sensor_ok =SDL_GamepadHasSensor(pad, SDL_SENSOR_GYRO) && SDL_GamepadHasSensor(pad, SDL_SENSOR_ACCEL) &&
SDL_SetGamepadSensorEnabled(pad, SDL_SENSOR_GYRO, true) &&
SDL_SetGamepadSensorEnabled(pad, SDL_SENSOR_ACCEL, true);
if (sensor_ok) rt_log("input: motion sensors on (gyro %.0f Hz, accelerometer %.0f Hz)",
(double)SDL_GetGamepadSensorDataRate(pad, SDL_SENSOR_GYRO),
(double)SDL_GetGamepadSensorDataRate(pad, SDL_SENSOR_ACCEL));
else rt_log("input: \"%s\" has no gyro and accelerometer: the six-axis sensor reads a controller at rest",
if (sensor_ok) {
rt_log("input: motion sensors on (gyro %.0f Hz, accelerometer %.0f Hz)",
(double)SDL_GetGamepadSensorDataRate(pad, SDL_SENSOR_GYRO),
(double)SDL_GetGamepadSensorDataRate(pad, SDL_SENSOR_ACCEL));
motion_restart(motion_global()); // another controller: its own orientation, from its first reading
} else rt_log("input: \"%s\" has no gyro and accelerometer: the six-axis sensor reads a controller at rest",
SDL_GetGamepadName(pad));
return sensor_ok;
}