Skip to content

Commit

Permalink
Simplify gyro mode/axis cycling code
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Dec 27, 2023
1 parent e091238 commit 9e74943
Showing 1 changed file with 2 additions and 47 deletions.
49 changes: 2 additions & 47 deletions Quake/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 9e74943

Please sign in to comment.