mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-17 01:21:12 +00:00
Gyro aiming menu options
"Gyro mode", "axis to turn" and "sensitivity" grouped with calibration.
This commit is contained in:
parent
f12b759feb
commit
077d861a57
2 changed files with 105 additions and 18 deletions
|
@ -301,6 +301,10 @@ extern cvar_t *joy_pitchsensitivity;
|
|||
extern cvar_t *joy_forwardsensitivity;
|
||||
extern cvar_t *joy_sidesensitivity;
|
||||
extern cvar_t *joy_upsensitivity;
|
||||
extern cvar_t *gyro_mode;
|
||||
extern cvar_t *gyro_turning_axis;
|
||||
extern cvar_t *gyro_yawsensitivity;
|
||||
extern cvar_t *gyro_pitchsensitivity;
|
||||
extern cvar_t *m_pitch;
|
||||
extern cvar_t *m_yaw;
|
||||
extern cvar_t *m_forward;
|
||||
|
|
|
@ -88,6 +88,22 @@ typedef struct
|
|||
menulayer_t m_layers[MAX_MENU_DEPTH];
|
||||
int m_menudepth;
|
||||
|
||||
static float
|
||||
ClampCvar(float min, float max, float value)
|
||||
{
|
||||
if (value < min)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
|
||||
if (value > max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static qboolean
|
||||
M_IsGame(const char *gamename)
|
||||
{
|
||||
|
@ -1602,6 +1618,10 @@ M_Menu_ControllerAltButtons_f(void)
|
|||
|
||||
static menuframework_s s_gyro_menu;
|
||||
|
||||
static menulist_s s_gyro_mode_box;
|
||||
static menulist_s s_turning_axis_box;
|
||||
static menuslider_s s_gyro_yawsensitivity_slider;
|
||||
static menuslider_s s_gyro_pitchsensitivity_slider;
|
||||
static menuseparator_s s_calibrating_text[2];
|
||||
static menuaction_s s_calibrate_gyro;
|
||||
|
||||
|
@ -1634,18 +1654,92 @@ CalibrationFinishedCallback(void)
|
|||
R_EndFrame();
|
||||
}
|
||||
|
||||
static void
|
||||
GyroModeFunc(void *unused)
|
||||
{
|
||||
Cvar_SetValue("gyro_mode", (int)s_gyro_mode_box.curvalue);
|
||||
}
|
||||
|
||||
static void
|
||||
TurningAxisFunc(void *unused)
|
||||
{
|
||||
Cvar_SetValue("gyro_turning_axis", (int)s_turning_axis_box.curvalue);
|
||||
}
|
||||
|
||||
static void
|
||||
GyroYawSensitivityFunc(void *unused)
|
||||
{
|
||||
Cvar_SetValue("gyro_yawsensitivity", s_gyro_yawsensitivity_slider.curvalue / 10.0F);
|
||||
}
|
||||
|
||||
static void
|
||||
GyroPitchSensitivityFunc(void *unused)
|
||||
{
|
||||
Cvar_SetValue("gyro_pitchsensitivity", s_gyro_pitchsensitivity_slider.curvalue / 10.0F);
|
||||
}
|
||||
|
||||
static void
|
||||
Gyro_MenuInit(void)
|
||||
{
|
||||
static const char *gyro_modes[] =
|
||||
{
|
||||
"always off",
|
||||
"off, button enables",
|
||||
"on, button disables",
|
||||
"always on",
|
||||
0
|
||||
};
|
||||
|
||||
static const char *axis_choices[] =
|
||||
{
|
||||
"yaw (turn)",
|
||||
"roll (lean)",
|
||||
0
|
||||
};
|
||||
|
||||
int y = 0;
|
||||
float scale = SCR_GetMenuScale();
|
||||
|
||||
s_gyro_menu.x = (int)(viddef.width * 0.50f);
|
||||
s_gyro_menu.nitems = 0;
|
||||
|
||||
s_gyro_mode_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_gyro_mode_box.generic.x = 0;
|
||||
s_gyro_mode_box.generic.y = y;
|
||||
s_gyro_mode_box.generic.name = "gyro mode";
|
||||
s_gyro_mode_box.generic.callback = GyroModeFunc;
|
||||
s_gyro_mode_box.itemnames = gyro_modes;
|
||||
s_gyro_mode_box.curvalue = ClampCvar(0, 3, gyro_mode->value);
|
||||
|
||||
s_turning_axis_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_turning_axis_box.generic.x = 0;
|
||||
s_turning_axis_box.generic.y = (y += 10);
|
||||
s_turning_axis_box.generic.name = "turning axis";
|
||||
s_turning_axis_box.generic.callback = TurningAxisFunc;
|
||||
s_turning_axis_box.itemnames = axis_choices;
|
||||
s_turning_axis_box.curvalue = ClampCvar(0, 1, gyro_turning_axis->value);
|
||||
|
||||
s_gyro_yawsensitivity_slider.generic.type = MTYPE_SLIDER;
|
||||
s_gyro_yawsensitivity_slider.generic.x = 0;
|
||||
s_gyro_yawsensitivity_slider.generic.y = (y += 20);
|
||||
s_gyro_yawsensitivity_slider.generic.name = "yaw sensitivity";
|
||||
s_gyro_yawsensitivity_slider.generic.callback = GyroYawSensitivityFunc;
|
||||
s_gyro_yawsensitivity_slider.minvalue = 1;
|
||||
s_gyro_yawsensitivity_slider.maxvalue = 80;
|
||||
s_gyro_yawsensitivity_slider.curvalue = gyro_yawsensitivity->value * 10;
|
||||
|
||||
s_gyro_pitchsensitivity_slider.generic.type = MTYPE_SLIDER;
|
||||
s_gyro_pitchsensitivity_slider.generic.x = 0;
|
||||
s_gyro_pitchsensitivity_slider.generic.y = (y += 10);
|
||||
s_gyro_pitchsensitivity_slider.generic.name = "pitch sensitivity";
|
||||
s_gyro_pitchsensitivity_slider.generic.callback = GyroPitchSensitivityFunc;
|
||||
s_gyro_pitchsensitivity_slider.minvalue = 1;
|
||||
s_gyro_pitchsensitivity_slider.maxvalue = 80;
|
||||
s_gyro_pitchsensitivity_slider.curvalue = gyro_pitchsensitivity->value * 10;
|
||||
|
||||
s_calibrating_text[0].generic.type = MTYPE_SEPARATOR;
|
||||
s_calibrating_text[0].generic.x = 48 * scale + 30;
|
||||
s_calibrating_text[0].generic.y = y;
|
||||
s_calibrating_text[0].generic.y = (y += 20);
|
||||
s_calibrating_text[0].generic.name = "place the controller on a flat,";
|
||||
|
||||
s_calibrating_text[1].generic.type = MTYPE_SEPARATOR;
|
||||
|
@ -1659,6 +1753,10 @@ Gyro_MenuInit(void)
|
|||
s_calibrate_gyro.generic.name = "calibrate";
|
||||
s_calibrate_gyro.generic.callback = CalibrateGyroFunc;
|
||||
|
||||
Menu_AddItem(&s_gyro_menu, (void *)&s_gyro_mode_box);
|
||||
Menu_AddItem(&s_gyro_menu, (void *)&s_turning_axis_box);
|
||||
Menu_AddItem(&s_gyro_menu, (void *)&s_gyro_yawsensitivity_slider);
|
||||
Menu_AddItem(&s_gyro_menu, (void *)&s_gyro_pitchsensitivity_slider);
|
||||
Menu_AddItem(&s_gyro_menu, (void *)&s_calibrating_text[0]);
|
||||
Menu_AddItem(&s_gyro_menu, (void *)&s_calibrating_text[1]);
|
||||
Menu_AddItem(&s_gyro_menu, (void *)&s_calibrate_gyro);
|
||||
|
@ -1870,7 +1968,7 @@ Joy_MenuInit(void)
|
|||
s_joy_gyro_action.generic.x = 0;
|
||||
s_joy_gyro_action.generic.y = y;
|
||||
y += 10;
|
||||
s_joy_gyro_action.generic.name = "gyro calibration";
|
||||
s_joy_gyro_action.generic.name = "gyro options";
|
||||
s_joy_gyro_action.generic.callback = ConfigGyroFunc;
|
||||
Menu_AddItem(&s_joy_menu, (void *)&s_joy_gyro_action);
|
||||
}
|
||||
|
@ -1973,22 +2071,6 @@ MouseSpeedFunc(void *unused)
|
|||
Cvar_SetValue("sensitivity", s_options_sensitivity_slider.curvalue / 2.0F);
|
||||
}
|
||||
|
||||
static float
|
||||
ClampCvar(float min, float max, float value)
|
||||
{
|
||||
if (value < min)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
|
||||
if (value > max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static void
|
||||
ControlsSetMenuItemValues(void)
|
||||
{
|
||||
|
@ -5641,6 +5723,7 @@ M_Init(void)
|
|||
Cmd_AddCommand("menu_options", M_Menu_Options_f);
|
||||
Cmd_AddCommand("menu_keys", M_Menu_Keys_f);
|
||||
Cmd_AddCommand("menu_joy", M_Menu_Joy_f);
|
||||
Cmd_AddCommand("menu_gyro", M_Menu_Gyro_f);
|
||||
Cmd_AddCommand("menu_buttons", M_Menu_ControllerButtons_f);
|
||||
Cmd_AddCommand("menu_altbuttons", M_Menu_ControllerAltButtons_f);
|
||||
Cmd_AddCommand("menu_quit", M_Menu_Quit_f);
|
||||
|
|
Loading…
Reference in a new issue