Add cvars to control the keys for menus and console.

The backquote is not always usable for toggling the console, and the new
bind system doesn't automatically bind a key to both game and console imts
(by design). Thus create a cvar that allows the "always works" console
toggle to be specified in eg $fs_globalcfg. While I'm at it, do one for the
menus, too.
This commit is contained in:
Bill Currie 2011-12-10 13:10:28 +09:00
parent 4f4d6b5675
commit d9d56760e1
2 changed files with 43 additions and 0 deletions

View file

@ -406,6 +406,8 @@ typedef struct {
extern keydest_t key_dest;
extern imt_t game_target;
extern knum_t key_togglemenu;
extern knum_t key_toggleconsole;
extern struct keybind_s {
char *str;

View file

@ -62,6 +62,8 @@ cvar_t *in_bind_imt;
VISIBLE keydest_t key_dest = key_console;
VISIBLE imt_t game_target = IMT_CONSOLE;
VISIBLE knum_t key_togglemenu = QFK_ESCAPE;
VISIBLE knum_t key_toggleconsole = QFK_BACKQUOTE;
VISIBLE struct keybind_s keybindings[IMT_LAST][QFK_LAST];
VISIBLE int keydown[QFK_LAST];
@ -737,6 +739,40 @@ in_bind_imt_f (cvar_t *var)
}
}
static void
in_key_togglemenu_f (cvar_t *var)
{
int k;
if (!*var->string) {
key_togglemenu = QFK_ESCAPE;
return;
}
if ((k = Key_StringToKeynum (var->string)) == -1) {
k = QFK_ESCAPE;
Sys_Printf ("\"%s\" is not a valid key. setting to \"K_ESCAPE\"\n",
var->string);
}
key_togglemenu = k;
}
static void
in_key_toggleconsole_f (cvar_t *var)
{
int k;
if (!*var->string) {
key_toggleconsole = -1;
return;
}
if ((k = Key_StringToKeynum (var->string)) == -1) {
Sys_Printf ("\"%s\" is not a valid key. not setting\n",
var->string);
return;
}
key_toggleconsole = k;
}
static void
Key_InputMappingTable_f (void)
{
@ -893,6 +929,11 @@ Key_Init_Cvars (void)
in_bind_imt = Cvar_Get ("in_bind_imt", "imt_default", CVAR_ARCHIVE,
in_bind_imt_f, "imt parameter for the bind and "
"unbind wrappers to in_bind and in_unbind");
Cvar_Get ("in_key_togglemenu", "", CVAR_NONE, in_key_togglemenu_f,
"Key for toggling the menu.");
Cvar_Get ("in_key_toggleconsole", "K_BACKQUOTE", CVAR_NONE,
in_key_toggleconsole_f,
"Key for toggling the console.");
}
const char *