diff --git a/include/QF/console.h b/include/QF/console.h index 172a4cd67..eeb9010d6 100644 --- a/include/QF/console.h +++ b/include/QF/console.h @@ -146,4 +146,9 @@ int Menu_KeyEvent (knum_t key, short unicode, qboolean down); void Menu_Enter (void); void Menu_Leave (void); +void Menu_Enter_f (void); +void Menu_Leave_f (void); +void Menu_Prev_f (void); +void Menu_Next_f (void); + #endif // __console_h diff --git a/include/QF/joystick.h b/include/QF/joystick.h index 0d622515b..6aaaf0890 100644 --- a/include/QF/joystick.h +++ b/include/QF/joystick.h @@ -51,6 +51,7 @@ typedef enum { } js_dest_t; typedef enum { + js_clear, js_amp, js_pre_amp, js_deadzone, @@ -94,6 +95,7 @@ extern struct joy_button joy_buttons[JOY_MAX_BUTTONS]; joy_enable->int_val are zero. */ void JOY_Command (void); +void joy_clear_axis (int i); /* JOY_Move (usercmd_t *) // FIXME: Not anymore! diff --git a/libs/console/menu.c b/libs/console/menu.c index afc2bd624..c055986d6 100644 --- a/libs/console/menu.c +++ b/libs/console/menu.c @@ -452,6 +452,26 @@ bi_Menu_Enter (progs_t *pr) } } +static void +bi_Menu_Leave (progs_t *pr) +{ + if (menu) { + if (menu->leave_hook) { + run_menu_pre (); + PR_ExecuteProgram (&menu_pr_state, menu->leave_hook); + run_menu_post (); + } + menu = menu->parent; + if (!menu) { + if (con_data.force_commandline) { + Key_SetKeyDest (key_console); + } else { + Key_SetKeyDest (key_game); + } + } + } +} + static void togglemenu_f (void) { @@ -517,9 +537,38 @@ static builtin_t builtins[] = { {"Menu_Next", bi_Menu_Next, -1}, {"Menu_Prev", bi_Menu_Prev, -1}, {"Menu_Enter", bi_Menu_Enter, -1}, + {"Menu_Leave", bi_Menu_Leave, -1}, {0}, }; + + +void +Menu_Enter_f (void) +{ + if (!Menu_KeyEvent(QFK_RETURN, '\0', true)) + Menu_KeyEvent('y', 'y', true); +} + +void +Menu_Leave_f (void) +{ + Menu_Leave (); +} + +void +Menu_Prev_f (void) +{ + Menu_KeyEvent (QFK_UP, '\0', true); +} + +void +Menu_Next_f (void) +{ + Menu_KeyEvent (QFK_DOWN, '\0', true); +} + + void Menu_Init (void) { @@ -549,6 +598,10 @@ Menu_Init (void) "Toggle the display of the menu"); Cmd_RemoveCommand ("quit"); Cmd_AddCommand ("quit", quit_f, "Exit the program"); + Cmd_AddCommand ("Menu_Enter", Menu_Enter_f, "Do menu action/move up in the menu tree."); + Cmd_AddCommand ("Menu_Leave", Menu_Leave_f, "Move down in the menu tree."); + Cmd_AddCommand ("Menu_Prev", Menu_Prev_f, "Move cursor up."); + Cmd_AddCommand ("Menu_Next", Menu_Next_f, "Move cursor up."); } void diff --git a/libs/video/targets/joy.c b/libs/video/targets/joy.c index fc15e75c7..7f67d65fd 100644 --- a/libs/video/targets/joy.c +++ b/libs/video/targets/joy.c @@ -69,6 +69,21 @@ ocvar_t joy_axes_cvar_init[JOY_MAX_AXES] = { struct joy_axis joy_axes[JOY_MAX_AXES]; struct joy_button joy_buttons[JOY_MAX_BUTTONS]; +void +joy_clear_axis (int i) +{ + joy_axes[i].dest = js_none; + joy_axes[i].amp = 1; + joy_axes[i].pre_amp = 1; + joy_axes[i].deadzone = 12500; + + joy_axes[i].num_buttons = 0; + if (joy_axes[i].axis_buttons) { + free (joy_axes[i].axis_buttons); + joy_axes[i].axis_buttons = NULL; + } +} + static void joy_check_axis_buttons (struct joy_axis *ja, float value) { @@ -203,6 +218,7 @@ js_dests_t js_dests[] = { js_opts_t js_opts[] = { + {"clear", js_clear}, {"amp", js_amp}, {"pre_amp", js_pre_amp}, {"deadzone",js_deadzone}, @@ -267,6 +283,12 @@ in_joy_f (void) if (c == 2) { ax = JOY_GetOption_i (Cmd_Argv(1)); switch (ax) { + case js_clear: + Sys_Printf("Clearing all joystick settings...\n"); + for (i = 0; i [<#amp>]: Axis sensitivity\n"); break; @@ -302,15 +324,23 @@ in_joy_f (void) Sys_Printf ("<====================>\n"); break; } - + return; } else if (c < 4) { - Sys_Printf ("in_joy [ ]* : Configures the joystick behaviour\n"); - return; + if (JOY_GetOption_i (Cmd_Argv(2)) == js_clear) { + ax = strtol(Cmd_Argv(1), NULL ,0); + + joy_clear_axis (ax); + return; + } else { + Sys_Printf ("in_joy [ ]* : Configures the joystick behaviour\n"); + return; + } } ax = strtol(Cmd_Argv(1), NULL ,0); + const char *arg; i = 2; while(i 0) { + int n; + for (n=0;n