From 54fcbd44166f14aace5e1113d70ea3c105524a26 Mon Sep 17 00:00:00 2001 From: ceski <56656010+ceski-1@users.noreply.github.com> Date: Mon, 14 Oct 2024 20:47:26 -0700 Subject: [PATCH] Add gyro invert turn/look options (#1963) * Don't invert local lean by default * Add gyro invert turn/look options --- src/i_gyro.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/i_gyro.c b/src/i_gyro.c index 309aad73..b83fb2fe 100644 --- a/src/i_gyro.c +++ b/src/i_gyro.c @@ -97,6 +97,8 @@ static int gyro_accel_max_threshold; static int gyro_smooth_threshold; static int gyro_smooth_time; static int gyro_tightening; +static boolean gyro_invert_turn; +static boolean gyro_invert_look; static fixed_t gyro_calibration_a; static fixed_t gyro_calibration_x; static fixed_t gyro_calibration_y; @@ -311,12 +313,29 @@ void I_CalcGyroAxes(boolean strafe) { if (GyroActive()) { - gyro_axes[GYRO_TURN] = !strafe ? RAD2TIC(gyro_axes[GYRO_TURN]) : 0.0f; + if (!strafe) + { + gyro_axes[GYRO_TURN] = RAD2TIC(gyro_axes[GYRO_TURN]); + + if (gyro_invert_turn) + { + gyro_axes[GYRO_TURN] *= -1.0f; + } + } + else + { + gyro_axes[GYRO_TURN] = 0.0f; + } if (padlook) { gyro_axes[GYRO_LOOK] = RAD2TIC(gyro_axes[GYRO_LOOK]); + if (gyro_invert_look) + { + gyro_axes[GYRO_LOOK] *= -1.0f; + } + if (correct_aspect_ratio) { gyro_axes[GYRO_LOOK] /= 1.2f; @@ -516,7 +535,7 @@ static void ApplyGyroSpace_Skip(void) static void ApplyGyroSpace_LocalLean(void) { - motion.gyro.y = -motion.gyro.z; + motion.gyro.y = motion.gyro.z; } static void ApplyGyroSpace_PlayerTurn(void) @@ -829,6 +848,10 @@ void I_BindGyroVaribales(void) BIND_NUM(gyro_tightening, 30, 0, 100, "Gyro steadying: tightening threshold " "(0 = Off; 100 = 10.0 degrees/second)"); + BIND_BOOL(gyro_invert_turn, false, + "Invert gyro turn axis"); + BIND_BOOL(gyro_invert_look, false, + "Invert gyro look axis"); BIND_NUM(gyro_calibration_a, 0, UL, UL, "Accelerometer calibration"); BIND_NUM(gyro_calibration_x, 0, UL, UL, "Gyro calibration (x-axis)");