#include "quakedef.h"
#include "cl_video.h"
-cvar_t con_closeontoggleconsole = {CVAR_SAVE, "con_closeontoggleconsole","0", "allows toggleconsole binds to close the console as well"};
+cvar_t con_closeontoggleconsole = {CVAR_SAVE, "con_closeontoggleconsole","1", "allows toggleconsole binds to close the console as well"};
/*
key up events are sent even if in console mode
{"AUX31", K_AUX31},
{"AUX32", K_AUX32},
- {"SEMICOLON", ';'}, // because a raw semicolon seperates commands
+ {"SEMICOLON", ';'}, // because a raw semicolon separates commands
{"TILDE", '~'},
{"BACKQUOTE", '`'},
{"QUOTE", '"'},
{"APOSTROPHE", '\''},
+ {"BACKSLASH", '\\'}, // because a raw backslash is used for special characters
{NULL, 0}
};
Key_Message (int key, char ascii)
{
- if (key == K_ENTER)
+ if (key == K_ENTER || ascii == 10 || ascii == 13)
{
Cmd_ForwardStringToServer(va("%s %s", chat_team ? "say_team" : "say ", chat_buffer));
const keyname_t *kn;
static char tinystr[2];
- if (keynum == -1)
+ // -1 is an invalid code
+ if (keynum < 0)
return "<KEY NOT FOUND>";
- if (keynum > 32 && keynum < 127) { // printable ascii
- tinystr[0] = keynum;
- tinystr[1] = 0;
- return tinystr;
- }
+ // search overrides first, because some characters are special
for (kn = keynames; kn->name; kn++)
if (keynum == kn->keynum)
return kn->name;
+ // if it is printable, output it as a single character
+ if (keynum > 32 && keynum < 256)
+ {
+ tinystr[0] = keynum;
+ tinystr[1] = 0;
+ return tinystr;
+ }
+
+ // if it is not overridden and not printable, we don't know what to do with it
return "<UNKNOWN KEYNUM>";
}
Z_Free (keybindings[bindmap][keynum]);
keybindings[bindmap][keynum] = NULL;
}
+ if(!binding[0]) // make "" binds be removed --blub
+ return;
// allocate memory for new binding
l = strlen (binding);
newbinding = (char *)Z_Malloc (l + 1);
Key_WriteBindings (qfile_t *f)
{
int i, j;
+ char bindbuf[MAX_INPUTLINE];
+ const char *p;
- for (i = 0; i < (int)(sizeof(keybindings[0])/sizeof(keybindings[0][0])); i++)
- if (keybindings[0][i])
- FS_Printf(f, "bind \"%s\" \"%s\"\n",
- Key_KeynumToString (i), keybindings[0][i]);
- for (j = 1; j < 8; j++)
+ for (j = 0; j < MAX_BINDMAPS; j++)
+ {
for (i = 0; i < (int)(sizeof(keybindings[0])/sizeof(keybindings[0][0])); i++)
- if (keybindings[j][i])
- FS_Printf(f, "in_bind %d \"%s\" \"%s\"\n",
- j, Key_KeynumToString (i), keybindings[j][i]);
+ {
+ p = keybindings[j][i];
+ if (p)
+ {
+ Cmd_QuoteString(bindbuf, sizeof(bindbuf), p, "\"\\");
+ if (j == 0)
+ FS_Printf(f, "bind %s \"%s\"\n", Key_KeynumToString (i), bindbuf);
+ else
+ FS_Printf(f, "in_bind %d %s \"%s\"\n", j, Key_KeynumToString (i), bindbuf);
+ }
+ }
+ }
}
if (!bind)
bind = keybindings[key_bmap2][key];
+ if (developer.integer >= 1000)
+ Con_Printf("Key_Event(%i, '%c', %s) keydown %i bind \"%s\"\n", key, ascii, down ? "down" : "up", keydown[key], bind ? bind : "");
+
if(key_dest == key_game)
{
q = CL_VM_InputEvent(!down, key);