From 9e74943ed554d139eec9731cbd84104ca44b9637 Mon Sep 17 00:00:00 2001 From: Andrei Drexler Date: Wed, 27 Dec 2023 15:10:54 +0100 Subject: [PATCH] Simplify gyro mode/axis cycling code --- Quake/menu.c | 49 ++----------------------------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/Quake/menu.c b/Quake/menu.c index ea53277f3..f04feec98 100644 --- a/Quake/menu.c +++ b/Quake/menu.c @@ -3121,51 +3121,6 @@ void CalibrationFinishedCallback(void) #define MIN_GYRO_SENS 0.1 #define MAX_GYRO_SENS 8 -/* -================ -GYRO_Menu_ChooseNextMode - -chooses next gyro mode in order, then updates gyro_mode cvar -================ -*/ -static void GYRO_Menu_ChooseNextMode (int dir) -{ - int i, current = (int)gyro_mode.value; - - if (dir < 0) - for (i = 0; i < 5 && i <= current; i++) - ; - else - for (i = 5 - 1; i >= 0 && i >= current; i--) - ; - - if (i < 0) - i = 5 - 1; - else if (i == 5) - i = 0; - - Cvar_SetValueQuick (&gyro_mode, i); -} - -/* -================ -GYRO_Menu_ToggleTurningAxis - -toggles the turning axis, then updates gyro_turning axis cvar -================ -*/ -static void GYRO_Menu_ToggleTurningAxis (int dir) -{ - int i, current = (int)gyro_turning_axis.value; - - if (current) - i = 0; - else - i = 1; - - Cvar_SetValueQuick (&gyro_turning_axis, i); -} - /* ================ GYRO_Menu_Calibration @@ -3690,10 +3645,10 @@ void M_AdjustSliders (int dir) // Gyro Options // case GYRO_OPT_MODE: - GYRO_Menu_ChooseNextMode(-dir); + Cvar_SetValueQuick (&gyro_mode, (int)(q_max (gyro_mode.value, 0.f) + 5 + dir) % 5); break; case GYRO_OPT_TURNINGAXIS: - GYRO_Menu_ToggleTurningAxis(-dir); + Cbuf_AddText ("toggle gyro_turning_axis\n"); break; case GYRO_OPT_SENSX: Cvar_SetValueQuick (&gyro_yawsensitivity, CLAMP (MIN_GYRO_SENS, gyro_yawsensitivity.value + dir * .1f, MAX_GYRO_SENS));