Skip to content

Commit

Permalink
Show gyro mode as "not supported" when applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Dec 29, 2023
1 parent 402663a commit dc4a493
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions Quake/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3285,10 +3285,17 @@ enum
VIDEO_OPTIONS_ITEMS = VIDEO_OPTIONS_LIST (COUNT_OPTION),
GPAD_OPTIONS_FIRST = OPTIONS_ITEMS + VIDEO_OPTIONS_ITEMS,
GPAD_OPTIONS_ITEMS = GPAD_OPTIONS_LIST (COUNT_OPTION),
GPAD_OPTIONS_GYROITEMS = GPAD_OPTIONS_FIRST + GPAD_OPTIONS_ITEMS - GPAD_OPT_GYROMODE,
#undef COUNT_OPTION

GYRO_OPTIONS_FIRST = GPAD_OPT_GYROMODE,
GYRO_OPTIONS_ITEMS = GPAD_OPTIONS_FIRST + GPAD_OPTIONS_ITEMS - GYRO_OPTIONS_FIRST,
};

static qboolean M_Options_IsGyroId (int id)
{
return (unsigned int)(id - GYRO_OPTIONS_FIRST) < GYRO_OPTIONS_ITEMS;
}

static const char *const options_names[] =
{
#define ADD_OPTION_NAME(id, name) name,
Expand Down Expand Up @@ -3378,6 +3385,8 @@ static qboolean M_Options_IsEnabled (int index)
index += optionsmenu.first_item;
if (index > GPAD_OPTIONS_FIRST && index < GPAD_OPTIONS_FIRST + GPAD_OPTIONS_ITEMS && !joy_enable.value)
return false;
if (M_Options_IsGyroId (index) && !IN_HasGyro ())
return false;
return true;
}

Expand Down Expand Up @@ -3437,7 +3446,7 @@ void M_Options_Init (enum m_state_e state)
optionsmenu.first_item = GPAD_OPTIONS_FIRST;
optionsmenu.list.numitems = GPAD_OPTIONS_ITEMS;
if (!IN_HasGyro ())
optionsmenu.list.numitems -= GPAD_OPTIONS_GYROITEMS;
optionsmenu.list.numitems -= GYRO_OPTIONS_ITEMS - 1; // remove all but the first gyro item
optionsmenu.last_cursor = &optionsmenu.gamepad_cursor;
optionsmenu.subtitle = "Gamepad Options";
}
Expand Down Expand Up @@ -4166,14 +4175,17 @@ static void M_Options_DrawItem (int y, int item)
M_DrawSlider (x, y, r);
break;
case GPAD_OPT_GYROMODE:
switch ((int)gyro_mode.value)
{
case 1: M_Print (x, y, "off, button enables"); break;
case 2: M_Print (x, y, "on, button disables"); break;
case 3: M_Print (x, y, "always on"); break;
case 4: M_Print (x, y, "on, button inverts direction"); break;
default: M_Print (x, y, "off"); break;
}
if (!IN_HasGyro ())
M_Print (x, y, "Not supported");
else
switch ((int)gyro_mode.value)
{
case 1: M_Print (x, y, "off, button enables"); break;
case 2: M_Print (x, y, "on, button disables"); break;
case 3: M_Print (x, y, "always on"); break;
case 4: M_Print (x, y, "on, button inverts direction"); break;
default: M_Print (x, y, "off"); break;
}
break;
case GPAD_OPT_GYROAXIS:
M_Print(x, y, gyro_turning_axis.value ? "roll (lean)" : "yaw (turn)");
Expand Down

0 comments on commit dc4a493

Please sign in to comment.