Index: code/client/cl_keys.c =================================================================== --- code/client/cl_keys.c (revision 908) +++ code/client/cl_keys.c (working copy) @@ -44,6 +44,7 @@ int anykeydown; qkey_t keys[MAX_KEYS]; +int key_specialesc = 0; /* console key fallback state (ESC-`). */ typedef struct { @@ -176,6 +177,12 @@ {"SEMICOLON", ';'}, // because a raw semicolon seperates commands + {"CARET", '^'}, + {"QUOTE", '"'}, /* work around printing problems. */ + /* Not hard-coded any more. */ + {"TILDE", '~'}, + {"GRAVE", '`'}, + {NULL,0} }; @@ -755,6 +762,13 @@ return ""; } + // check for a key string + for ( kn=keynames ; kn->name ; kn++ ) { + if (keynum == kn->keynum) { + return kn->name; + } + } + // check for printable ascii (don't use quote) if ( keynum > 32 && keynum < 127 && keynum != '"' && keynum != ';' ) { tinystr[0] = keynum; @@ -762,13 +776,6 @@ return tinystr; } - // check for a key string - for ( kn=keynames ; kn->name ; kn++ ) { - if (keynum == kn->keynum) { - return kn->name; - } - } - // make a hex string i = keynum >> 4; j = keynum & 15; @@ -1019,6 +1026,29 @@ } } + +qboolean CL_IsConsoleKey (int key) { + if (keys[key].binding) { + /* Potentially is console key. */ + if (strcmp(keys[key].binding, "toggleconsole") == 0) { + /* It is console key. */ + return qtrue; + } + } + if (key == '`' || key == '~') { + /* Default console keys, but... */ + if ( (! keys[key].binding) || !*(keys[key].binding) ) { + /* Is unbounded||empty => toggleconsole. */ + return qtrue; + } + if (key_specialesc) { + return qtrue; + } + } + /* return (key == '`' || key == '~'); */ + return qfalse; +} + /* =================== CL_KeyEvent @@ -1066,11 +1096,12 @@ #endif // console key is hardcoded, so the user can never unbind it - if (key == '`' || key == '~') { + if ( CL_IsConsoleKey(key) /*key == '`' || key == '~'*/ ) { if (!down) { + key_specialesc = 0; return; } - Con_ToggleConsole_f (); + Con_ToggleConsole_f (); return; } @@ -1087,6 +1118,7 @@ // escape is always handled special if ( key == K_ESCAPE && down ) { + key_specialesc = 1; /* allow console fallback. */ if ( cls.keyCatchers & KEYCATCH_MESSAGE ) { // clear message mode Message_Key( key ); @@ -1114,6 +1146,8 @@ VM_Call( uivm, UI_KEY_EVENT, key, down ); return; + } else if ( key != K_ESCAPE ) { + key_specialesc = 0; } // @@ -1205,7 +1239,7 @@ */ void CL_CharEvent( int key ) { // the console key should never be used as a char - if ( key == '`' || key == '~' ) { + if ( CL_IsConsoleKey(key) /* key == '`' || key == '~' */ ) { return; }