diff --git a/src/client/cl_keyboard.c b/src/client/cl_keyboard.c index 4e5919ed..2d6ee439 100644 --- a/src/client/cl_keyboard.c +++ b/src/client/cl_keyboard.c @@ -64,7 +64,10 @@ keyname_t keynames[] = { {"ENTER", K_ENTER}, {"ESCAPE", K_ESCAPE}, {"SPACE", K_SPACE}, - {"SEMICOLON", ';'}, /* because a raw semicolon separates commands */ + {"SEMICOLON", ';'}, /* because a raw semicolon separates commands */ + {"DOUBLEQUOTE", '"'}, /* because "" has special meaning in configs */ + {"QUOTE", '\'' }, /* just to be sure */ + {"DOLLAR", '$'}, /* $ is used in macros => can occur in configs */ {"BACKSPACE", K_BACKSPACE}, {"COMMAND", K_COMMAND}, @@ -733,9 +736,11 @@ Key_KeynumToString(int keynum) return ""; } - if ((keynum > 32) && (keynum < 127) && keynum != ';') + if ((keynum > 32) && (keynum < 127) && keynum != ';' && keynum != '"' && keynum != '\'' && keynum != '$') { - /* printable ascii, except for semicolon special case */ + /* printable ASCII, except for special cases that have special meanings + in configs like quotes or ; (separates commands) or $ (used to expand + cvars to their values in macros/commands) and thus need escaping */ tinystr[0] = keynum; return tinystr; } diff --git a/src/client/header/keyboard.h b/src/client/header/keyboard.h index 24870135..be613970 100644 --- a/src/client/header/keyboard.h +++ b/src/client/header/keyboard.h @@ -47,11 +47,16 @@ extern qboolean joy_altselector_pressed; /* these are the key numbers that should be passed to Key_Event - they must be mached by the low level key event processing! */ + they must be matched by the low level key event processing! */ enum QKEYS { K_TAB = 9, K_ENTER = 13, K_ESCAPE = 27, + // Note: ASCII keys are generally valid but don't get constants here, + // just use 'a' (yes, lowercase) or '2' or whatever, however there are + // some special cases when writing/parsing configs (space or quotes or + // also ; and $ have a special meaning there so we use e.g. "SPACE" instead), + // see keynames[] in cl_keyboard.c K_SPACE = 32, K_BACKSPACE = 127,