mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 23:11:38 +00:00
Rework the legacy bind/unbind commands.
in_bind_imt is now gone. I guess mercury was right in that it was a poor design. However, it was (and still is necessary) to support "bind" and "unbind". Now, instead, they work only with the IMT_MOD table. IMT_MOD sits below IMT_0 in the imt hierarchy. If the key is not bound in IMT_0+, then IMT_MOD will be checked. This way, "bind" and "unbind" can never mess with a user's more sophisticated binding setup.
This commit is contained in:
parent
49451eea80
commit
14d8e8669f
2 changed files with 10 additions and 31 deletions
|
@ -369,6 +369,7 @@ typedef enum {
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
IMT_CONSOLE,
|
IMT_CONSOLE,
|
||||||
|
IMT_MOD,
|
||||||
IMT_0,
|
IMT_0,
|
||||||
IMT_1,
|
IMT_1,
|
||||||
IMT_2,
|
IMT_2,
|
||||||
|
|
|
@ -58,8 +58,6 @@ static __attribute__ ((used)) const char rcsid[] =
|
||||||
|
|
||||||
/* key up events are sent even if in console mode */
|
/* key up events are sent even if in console mode */
|
||||||
|
|
||||||
cvar_t *in_bind_imt;
|
|
||||||
|
|
||||||
VISIBLE keydest_t key_dest = key_console;
|
VISIBLE keydest_t key_dest = key_console;
|
||||||
VISIBLE imt_t game_target = IMT_CONSOLE;
|
VISIBLE imt_t game_target = IMT_CONSOLE;
|
||||||
VISIBLE knum_t key_togglemenu = QFK_ESCAPE;
|
VISIBLE knum_t key_togglemenu = QFK_ESCAPE;
|
||||||
|
@ -78,6 +76,7 @@ typedef struct {
|
||||||
|
|
||||||
imtname_t imtnames[] = {
|
imtname_t imtnames[] = {
|
||||||
{"IMT_CONSOLE", IMT_CONSOLE},
|
{"IMT_CONSOLE", IMT_CONSOLE},
|
||||||
|
{"IMT_MOD", IMT_MOD},
|
||||||
{"IMT_0", IMT_0},
|
{"IMT_0", IMT_0},
|
||||||
{"IMT_1", IMT_1},
|
{"IMT_1", IMT_1},
|
||||||
{"IMT_2", IMT_2},
|
{"IMT_2", IMT_2},
|
||||||
|
@ -424,6 +423,8 @@ Key_Game (knum_t key, short unicode)
|
||||||
kb = Key_GetBinding (game_target, key);
|
kb = Key_GetBinding (game_target, key);
|
||||||
if (!kb && (game_target > IMT_0))
|
if (!kb && (game_target > IMT_0))
|
||||||
kb = Key_GetBinding (IMT_0, key);
|
kb = Key_GetBinding (IMT_0, key);
|
||||||
|
if (!kb)
|
||||||
|
kb = Key_GetBinding (IMT_MOD, key);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sys_DPrintf("kb %p, game_target %d, key_dest %d, key %d\n", kb,
|
Sys_DPrintf("kb %p, game_target %d, key_dest %d, key %d\n", kb,
|
||||||
|
@ -662,14 +663,14 @@ Key_Unbind_f (void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
key = OK_TranslateKeyName (Cmd_Argv (1));
|
key = OK_TranslateKeyName (Cmd_Argv (1));
|
||||||
Key_In_Unbind (in_bind_imt->string, key);
|
Key_In_Unbind ("imt_mod", key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Key_Bind_f (void)
|
Key_Bind_f (void)
|
||||||
{
|
{
|
||||||
int c, i;
|
int c, i;
|
||||||
const char *imt, *key, *cmd = 0;
|
const char *key, *cmd = 0;
|
||||||
char cmd_buf[1024];
|
char cmd_buf[1024];
|
||||||
|
|
||||||
c = Cmd_Argc ();
|
c = Cmd_Argc ();
|
||||||
|
@ -679,8 +680,6 @@ Key_Bind_f (void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
imt = in_bind_imt->string;
|
|
||||||
|
|
||||||
key = OK_TranslateKeyName (Cmd_Argv (1));
|
key = OK_TranslateKeyName (Cmd_Argv (1));
|
||||||
|
|
||||||
if (c >= 3) {
|
if (c >= 3) {
|
||||||
|
@ -694,51 +693,33 @@ Key_Bind_f (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Key_In_Bind (imt, key, cmd);
|
Key_In_Bind ("imt_mod", key, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Key_GIB_Bind_Get_f (void)
|
Key_GIB_Bind_Get_f (void)
|
||||||
{
|
{
|
||||||
const char *imt, *key, *cmd;
|
const char *key, *cmd;
|
||||||
int t, k;
|
int k;
|
||||||
|
|
||||||
if (GIB_Argc () != 2) {
|
if (GIB_Argc () != 2) {
|
||||||
GIB_USAGE ("key");
|
GIB_USAGE ("key");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
imt = in_bind_imt->string;
|
|
||||||
|
|
||||||
key = OK_TranslateKeyName (GIB_Argv (1));
|
key = OK_TranslateKeyName (GIB_Argv (1));
|
||||||
|
|
||||||
if ((t = Key_StringToIMTnum (imt)) == -1) {
|
|
||||||
GIB_Error ("bind", "bind::get: invalid imt %s", imt);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((k = Key_StringToKeynum (key)) == -1) {
|
if ((k = Key_StringToKeynum (key)) == -1) {
|
||||||
GIB_Error ("bind", "bind::get: invalid key %s", key);
|
GIB_Error ("bind", "bind::get: invalid key %s", key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cmd = Key_GetBinding (t, k)))
|
if (!(cmd = Key_GetBinding (IMT_MOD, k)))
|
||||||
GIB_Return ("");
|
GIB_Return ("");
|
||||||
else
|
else
|
||||||
GIB_Return (cmd);
|
GIB_Return (cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
in_bind_imt_f (cvar_t *var)
|
|
||||||
{
|
|
||||||
if (Key_StringToIMTnum (var->string) == -1) {
|
|
||||||
Sys_Printf ("\"%s\" is not a valid imt. setting to \"imt_default\"\n",
|
|
||||||
var->string);
|
|
||||||
Cvar_Set (var, "imt_default");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
in_key_togglemenu_f (cvar_t *var)
|
in_key_togglemenu_f (cvar_t *var)
|
||||||
{
|
{
|
||||||
|
@ -926,9 +907,6 @@ Key_Init (cbuf_t *cb)
|
||||||
void
|
void
|
||||||
Key_Init_Cvars (void)
|
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,
|
Cvar_Get ("in_key_togglemenu", "", CVAR_NONE, in_key_togglemenu_f,
|
||||||
"Key for toggling the menu.");
|
"Key for toggling the menu.");
|
||||||
Cvar_Get ("in_key_toggleconsole", "K_BACKQUOTE", CVAR_NONE,
|
Cvar_Get ("in_key_toggleconsole", "K_BACKQUOTE", CVAR_NONE,
|
||||||
|
|
Loading…
Reference in a new issue