diff --git a/Quake/in_sdl.c b/Quake/in_sdl.c index 79560540b..8a06df403 100644 --- a/Quake/in_sdl.c +++ b/Quake/in_sdl.c @@ -99,6 +99,7 @@ static float gyro_accum[3]; static unsigned int num_samples; static unsigned int updates_countdown = 0; +static qboolean gyro_present = false; static qboolean gyro_active = false; static int SDLCALL IN_FilterMouseEvents (const SDL_Event *event) @@ -326,6 +327,7 @@ void IN_StartupJoystick (void) if (SDL_GameControllerHasSensor(joy_active_controller, SDL_SENSOR_GYRO) && !SDL_GameControllerSetSensorEnabled(joy_active_controller, SDL_SENSOR_GYRO, SDL_TRUE)) { + gyro_present = true; #if SDL_VERSION_ATLEAST(2, 0, 16) Con_Printf("Gyro sensor enabled at %.2f Hz\n", SDL_GameControllerGetSensorDataRate(joy_active_controller, SDL_SENSOR_GYRO)); #else @@ -334,6 +336,7 @@ void IN_StartupJoystick (void) } else { + gyro_present = false; Con_Printf("Gyro sensor not found\n"); } break; @@ -1090,6 +1093,11 @@ static void IN_UpdateGyroCalibration (void) } } +qboolean IN_HasGyro (void) +{ + return gyro_present; +} + qboolean IN_IsCalibratingGyro (void) { return updates_countdown != 0; diff --git a/Quake/input.h b/Quake/input.h index 38a1fb4a9..1c9a19c1f 100644 --- a/Quake/input.h +++ b/Quake/input.h @@ -34,6 +34,8 @@ void IN_Commands (void); // mouse moved by dx and dy pixels void IN_MouseMotion(int dx, int dy); +// controller gyro +qboolean IN_HasGyro (void); void IN_StartGyroCalibration (void); qboolean IN_IsCalibratingGyro (void); diff --git a/Quake/menu.c b/Quake/menu.c index b0c432e5d..630e0c8cf 100644 --- a/Quake/menu.c +++ b/Quake/menu.c @@ -3285,6 +3285,7 @@ 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 }; @@ -3425,6 +3426,8 @@ 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.last_cursor = &optionsmenu.gamepad_cursor; optionsmenu.subtitle = "Gamepad Options"; }