2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to:
18 Free Software Foundation, Inc.
19 59 Temple Place - Suite 330
20 Boston, MA 02111-1307, USA
26 cvar_t con_closeontoggleconsole = {CVAR_SAVE, "con_closeontoggleconsole","1", "allows toggleconsole binds to close the console as well"};
29 key up events are sent even if in console mode
32 int edit_line = MAX_INPUTLINES-1;
33 int history_line = MAX_INPUTLINES-1;
34 char key_lines[MAX_INPUTLINES][MAX_INPUTLINE];
36 qboolean key_insert = true; // insert key toggle (for editing)
38 int key_consoleactive;
39 char *keybindings[MAX_BINDMAPS][MAX_KEYS];
41 static int key_bmap, key_bmap2;
42 static unsigned char keydown[MAX_KEYS]; // 0 = up, 1 = down, 2 = repeating
44 typedef struct keyname_s
51 static const keyname_t keynames[] = {
57 // spacer so it lines up with keys.h
59 {"BACKSPACE", K_BACKSPACE},
60 {"UPARROW", K_UPARROW},
61 {"DOWNARROW", K_DOWNARROW},
62 {"LEFTARROW", K_LEFTARROW},
63 {"RIGHTARROW", K_RIGHTARROW},
91 {"NUMLOCK", K_NUMLOCK},
92 {"CAPSLOCK", K_CAPSLOCK},
93 {"SCROLLOCK", K_SCROLLOCK},
95 {"KP_INS", K_KP_INS },
97 {"KP_END", K_KP_END },
99 {"KP_DOWNARROW", K_KP_DOWNARROW },
101 {"KP_PGDN", K_KP_PGDN },
103 {"KP_LEFTARROW", K_KP_LEFTARROW },
106 {"KP_RIGHTARROW", K_KP_RIGHTARROW },
108 {"KP_HOME", K_KP_HOME },
110 {"KP_UPARROW", K_KP_UPARROW },
112 {"KP_PGUP", K_KP_PGUP },
114 {"KP_DEL", K_KP_DEL },
115 {"KP_PERIOD", K_KP_PERIOD},
116 {"KP_SLASH", K_KP_SLASH },
117 {"KP_DIVIDE", K_KP_DIVIDE},
118 {"KP_MULTIPLY", K_KP_MULTIPLY},
119 {"KP_MINUS", K_KP_MINUS},
120 {"KP_PLUS", K_KP_PLUS},
121 {"KP_ENTER", K_KP_ENTER},
122 {"KP_EQUALS", K_KP_EQUALS},
126 {"MOUSE1", K_MOUSE1},
128 {"MOUSE2", K_MOUSE2},
129 {"MOUSE3", K_MOUSE3},
130 {"MWHEELUP", K_MWHEELUP},
131 {"MWHEELDOWN", K_MWHEELDOWN},
132 {"MOUSE4", K_MOUSE4},
133 {"MOUSE5", K_MOUSE5},
134 {"MOUSE6", K_MOUSE6},
135 {"MOUSE7", K_MOUSE7},
136 {"MOUSE8", K_MOUSE8},
137 {"MOUSE9", K_MOUSE9},
138 {"MOUSE10", K_MOUSE10},
139 {"MOUSE11", K_MOUSE11},
140 {"MOUSE12", K_MOUSE12},
141 {"MOUSE13", K_MOUSE13},
142 {"MOUSE14", K_MOUSE14},
143 {"MOUSE15", K_MOUSE15},
144 {"MOUSE16", K_MOUSE16},
204 {"SEMICOLON", ';'}, // because a raw semicolon separates commands
208 {"APOSTROPHE", '\''},
209 {"BACKSLASH", '\\'}, // because a raw backslash is used for special characters
215 ==============================================================================
217 LINE TYPING INTO THE CONSOLE
219 ==============================================================================
223 Key_ClearEditLine (int edit_line)
225 memset (key_lines[edit_line], '\0', sizeof(key_lines[edit_line]));
226 key_lines[edit_line][0] = ']';
232 Interactive line editing and console scrollback
236 Key_Console (int key, int ascii)
238 // LordHavoc: copied most of this from Q2 to improve keyboard handling
265 case K_KP_RIGHTARROW:
285 if ((toupper(key) == 'V' && keydown[K_CTRL]) || ((key == K_INS || key == K_KP_INS) && keydown[K_SHIFT]))
288 if ((cbd = Sys_GetClipboardData()) != 0)
295 if (*p == '\n' || *p == '\r' || *p == '\b')
303 strtok(cbd, "\n\r\b");
305 i = (int)strlen(cbd);
306 if (i + key_linepos >= MAX_INPUTLINE)
307 i= MAX_INPUTLINE - key_linepos - 1;
310 // terencehill: insert the clipboard text between the characters of the line
311 char *temp = Z_Malloc(MAX_INPUTLINE);
314 if ( key_linepos < (int)strlen(key_lines[edit_line]) )
315 strlcpy(temp, key_lines[edit_line] + key_linepos, (int)strlen(key_lines[edit_line]) - key_linepos +1);
316 key_lines[edit_line][key_linepos] = 0;
317 strlcat(key_lines[edit_line], cbd, sizeof(key_lines[edit_line]));
319 strlcat(key_lines[edit_line], temp, sizeof(key_lines[edit_line]));
332 Cbuf_AddText ("clear\n");
337 if (key == K_ENTER || key == K_KP_ENTER)
339 Cbuf_AddText (key_lines[edit_line]+1); // skip the ]
341 Con_Printf("%s\n",key_lines[edit_line]);
342 if(key_lines[edit_line][1] == 0) // empty line (just a ])?
343 return; // no, no, you can't submit empty lines to the history...
344 // LordHavoc: redesigned edit_line/history_line
346 history_line = edit_line;
347 memmove(key_lines[0], key_lines[1], sizeof(key_lines[0]) * edit_line);
348 key_lines[edit_line][0] = ']';
349 key_lines[edit_line][1] = 0; // EvilTypeGuy: null terminate
351 // force an update, because the command may take some time
352 if (cls.state == ca_disconnected)
359 // Enhanced command completion
360 // by EvilTypeGuy eviltypeguy@qeradiant.com
361 // Thanks to Fett, Taniwha
362 Con_CompleteCommandLine();
366 // Advanced Console Editing by Radix radix@planetquake.com
367 // Added/Modified by EvilTypeGuy eviltypeguy@qeradiant.com
369 // Enhanced by terencehill
371 // move cursor to the previous character
372 if (key == K_LEFTARROW || key == K_KP_LEFTARROW)
376 if(keydown[K_CTRL]) // move cursor to the previous word
384 k = key_lines[edit_line][pos];
385 if(k == '\"' || k == ';' || k == ' ' || k == '\'')
388 key_linepos = pos + 1;
390 else if(keydown[K_SHIFT]) // move cursor to the previous character ignoring colors
395 if(pos-1 > 0 && key_lines[edit_line][pos-1] == STRING_COLOR_TAG && isdigit(key_lines[edit_line][pos]))
397 else if(pos-4 > 0 && key_lines[edit_line][pos-4] == STRING_COLOR_TAG && key_lines[edit_line][pos-3] == STRING_COLOR_RGB_TAG_CHAR
398 && isxdigit(key_lines[edit_line][pos-2]) && isxdigit(key_lines[edit_line][pos-1]) && isxdigit(key_lines[edit_line][pos]))
405 key_linepos = pos + 1;
412 // delete char before cursor
413 if (key == K_BACKSPACE || (key == 'h' && keydown[K_CTRL]))
417 strlcpy(key_lines[edit_line] + key_linepos - 1, key_lines[edit_line] + key_linepos, sizeof(key_lines[edit_line]) + 1 - key_linepos);
423 // delete char on cursor
424 if (key == K_DEL || key == K_KP_DEL)
427 linelen = strlen(key_lines[edit_line]);
428 if (key_linepos < (int)linelen)
429 memmove(key_lines[edit_line] + key_linepos, key_lines[edit_line] + key_linepos + 1, linelen - key_linepos);
434 // move cursor to the next character
435 if (key == K_RIGHTARROW || key == K_KP_RIGHTARROW)
437 if (key_linepos >= (int)strlen(key_lines[edit_line]))
439 if(keydown[K_CTRL]) // move cursor to the next word
443 len = (int)strlen(key_lines[edit_line]);
447 k = key_lines[edit_line][pos];
448 if(k == '\"' || k == ';' || k == ' ' || k == '\'')
453 else if(keydown[K_SHIFT]) // move cursor to the next character ignoring colors
456 len = (int)strlen(key_lines[edit_line]);
458 // check if there is a color tag right after the cursor
459 if (key_lines[edit_line][pos] == STRING_COLOR_TAG)
461 if(isdigit(key_lines[edit_line][pos+1]))
463 else if(key_lines[edit_line][pos+1] == STRING_COLOR_RGB_TAG_CHAR && isxdigit(key_lines[edit_line][pos+2]) && isxdigit(key_lines[edit_line][pos+3]) && isxdigit(key_lines[edit_line][pos+4]))
468 // now go beyond all next consecutive color tags, if any
470 while (key_lines[edit_line][pos] == STRING_COLOR_TAG)
472 if(isdigit(key_lines[edit_line][pos+1]))
474 else if(key_lines[edit_line][pos+1] == STRING_COLOR_RGB_TAG_CHAR && isxdigit(key_lines[edit_line][pos+2]) && isxdigit(key_lines[edit_line][pos+3]) && isxdigit(key_lines[edit_line][pos+4]))
486 if (key == K_INS || key == K_KP_INS) // toggle insert mode
492 // End Advanced Console Editing
494 if (key == K_UPARROW || key == K_KP_UPARROW || (key == 'p' && keydown[K_CTRL]))
496 if (history_line > 0 && key_lines[history_line-1][1])
500 linelen = strlen(key_lines[history_line]);
501 memcpy(key_lines[edit_line], key_lines[history_line], linelen + 1);
502 key_linepos = (int)linelen;
507 if (key == K_DOWNARROW || key == K_KP_DOWNARROW || (key == 'n' && keydown[K_CTRL]))
510 if (history_line >= edit_line)
512 history_line = edit_line;
513 key_lines[edit_line][0] = ']';
514 key_lines[edit_line][1] = 0;
520 linelen = strlen(key_lines[history_line]);
521 memcpy(key_lines[edit_line], key_lines[history_line], linelen + 1);
522 key_linepos = (int)linelen;
527 if (key == K_PGUP || key == K_KP_PGUP || key == K_MWHEELUP)
534 con_backscroll += ((int) vid_conheight.integer >> 5);
538 if (key == K_PGDN || key == K_KP_PGDN || key == K_MWHEELDOWN)
545 con_backscroll -= ((int) vid_conheight.integer >> 5);
549 if (key == K_HOME || key == K_KP_HOME)
552 con_backscroll = INT_MAX;
558 if (key == K_END || key == K_KP_END)
563 key_linepos = (int)strlen(key_lines[edit_line]);
571 if (key_linepos < MAX_INPUTLINE-1)
574 len = (int)strlen(&key_lines[edit_line][key_linepos]);
575 // check insert mode, or always insert if at end of line
576 if (key_insert || len == 0)
578 // can't use strcpy to move string to right
580 memmove(&key_lines[edit_line][key_linepos + 1], &key_lines[edit_line][key_linepos], len);
582 key_lines[edit_line][key_linepos] = ascii;
587 //============================================================================
590 char chat_buffer[MAX_INPUTLINE];
591 unsigned int chat_bufferlen = 0;
593 extern int Nicks_CompleteChatLine(char *buffer, size_t size, unsigned int pos);
596 Key_Message (int key, int ascii)
599 if (key == K_ENTER || ascii == 10 || ascii == 13)
602 Cmd_ExecuteString(chat_buffer, src_command); // not Cbuf_AddText to allow semiclons in args; however, this allows no variables then. Use aliases!
604 Cmd_ForwardStringToServer(va("%s %s", chat_mode ? "say_team" : "say ", chat_buffer));
612 // TODO add support for arrow keys and simple editing
614 if (key == K_ESCAPE) {
621 if (key == K_BACKSPACE) {
622 if (chat_bufferlen) {
624 chat_buffer[chat_bufferlen] = 0;
630 chat_bufferlen = Nicks_CompleteChatLine(chat_buffer, sizeof(chat_buffer), chat_bufferlen);
634 if (chat_bufferlen == sizeof (chat_buffer) - 1)
638 return; // non printable
640 chat_buffer[chat_bufferlen++] = ascii;
641 chat_buffer[chat_bufferlen] = 0;
644 //============================================================================
649 Returns a key number to be used to index keybindings[] by looking at
650 the given string. Single ascii characters return themselves, while
651 the K_* names are matched up.
655 Key_StringToKeynum (const char *str)
662 return tolower(str[0]);
664 for (kn = keynames; kn->name; kn++) {
665 if (!strcasecmp (str, kn->name))
673 Returns a string (either a single ascii char, or a K_* name) for the
675 FIXME: handle quote special (general escape sequence?)
679 Key_KeynumToString (int keynum)
682 static char tinystr[2];
684 // -1 is an invalid code
686 return "<KEY NOT FOUND>";
688 // search overrides first, because some characters are special
689 for (kn = keynames; kn->name; kn++)
690 if (keynum == kn->keynum)
693 // if it is printable, output it as a single character
694 if (keynum > 32 && keynum < 256)
701 // if it is not overridden and not printable, we don't know what to do with it
702 return "<UNKNOWN KEYNUM>";
707 Key_SetBinding (int keynum, int bindmap, const char *binding)
712 if (keynum == -1 || keynum >= MAX_KEYS)
716 if (keybindings[bindmap][keynum]) {
717 Z_Free (keybindings[bindmap][keynum]);
718 keybindings[bindmap][keynum] = NULL;
720 if(!binding[0]) // make "" binds be removed --blub
722 // allocate memory for new binding
723 l = strlen (binding);
724 newbinding = (char *)Z_Malloc (l + 1);
725 memcpy (newbinding, binding, l + 1);
727 keybindings[bindmap][keynum] = newbinding;
731 Key_In_Unbind_f (void)
735 if (Cmd_Argc () != 3) {
736 Con_Print("in_unbind <bindmap> <key> : remove commands from a key\n");
740 m = strtol(Cmd_Argv (1), NULL, 0);
741 if ((m < 0) || (m >= 8)) {
742 Con_Printf("%d isn't a valid bindmap\n", m);
746 b = Key_StringToKeynum (Cmd_Argv (2));
748 Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv (2));
752 Key_SetBinding (b, m, "");
759 char cmd[MAX_INPUTLINE];
763 if (c != 3 && c != 4) {
764 Con_Print("in_bind <bindmap> <key> [command] : attach a command to a key\n");
768 m = strtol(Cmd_Argv (1), NULL, 0);
769 if ((m < 0) || (m >= 8)) {
770 Con_Printf("%d isn't a valid bindmap\n", m);
774 b = Key_StringToKeynum (Cmd_Argv (2));
775 if (b == -1 || b >= MAX_KEYS) {
776 Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv (2));
781 if (keybindings[m][b])
782 Con_Printf("\"%s\" = \"%s\"\n", Cmd_Argv (2), keybindings[m][b]);
784 Con_Printf("\"%s\" is not bound\n", Cmd_Argv (2));
787 // copy the rest of the command line
788 cmd[0] = 0; // start out with a null string
789 for (i = 3; i < c; i++) {
790 strlcat (cmd, Cmd_Argv (i), sizeof (cmd));
792 strlcat (cmd, " ", sizeof (cmd));
795 Key_SetBinding (b, m, cmd);
799 Key_In_Bindmap_f (void)
806 Con_Print("in_bindmap <bindmap> <fallback>: set current bindmap and fallback\n");
810 m1 = strtol(Cmd_Argv (1), NULL, 0);
811 if ((m1 < 0) || (m1 >= 8)) {
812 Con_Printf("%d isn't a valid bindmap\n", m1);
816 m2 = strtol(Cmd_Argv (2), NULL, 0);
817 if ((m2 < 0) || (m2 >= 8)) {
818 Con_Printf("%d isn't a valid bindmap\n", m2);
831 if (Cmd_Argc () != 2) {
832 Con_Print("unbind <key> : remove commands from a key\n");
836 b = Key_StringToKeynum (Cmd_Argv (1));
838 Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv (1));
842 Key_SetBinding (b, 0, "");
846 Key_Unbindall_f (void)
850 for (j = 0; j < 8; j++)
851 for (i = 0; i < (int)(sizeof(keybindings[0])/sizeof(keybindings[0][0])); i++)
852 if (keybindings[j][i])
853 Key_SetBinding (i, j, "");
861 char cmd[MAX_INPUTLINE];
865 if (c != 2 && c != 3) {
866 Con_Print("bind <key> [command] : attach a command to a key\n");
869 b = Key_StringToKeynum (Cmd_Argv (1));
870 if (b == -1 || b >= MAX_KEYS) {
871 Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv (1));
876 if (keybindings[0][b])
877 Con_Printf("\"%s\" = \"%s\"\n", Cmd_Argv (1), keybindings[0][b]);
879 Con_Printf("\"%s\" is not bound\n", Cmd_Argv (1));
882 // copy the rest of the command line
883 cmd[0] = 0; // start out with a null string
884 for (i = 2; i < c; i++) {
885 strlcat (cmd, Cmd_Argv (i), sizeof (cmd));
887 strlcat (cmd, " ", sizeof (cmd));
890 Key_SetBinding (b, 0, cmd);
895 Writes lines containing "bind key value"
899 Key_WriteBindings (qfile_t *f)
902 char bindbuf[MAX_INPUTLINE];
905 for (j = 0; j < MAX_BINDMAPS; j++)
907 for (i = 0; i < (int)(sizeof(keybindings[0])/sizeof(keybindings[0][0])); i++)
909 p = keybindings[j][i];
912 Cmd_QuoteString(bindbuf, sizeof(bindbuf), p, "\"\\");
914 FS_Printf(f, "bind %s \"%s\"\n", Key_KeynumToString (i), bindbuf);
916 FS_Printf(f, "in_bind %d %s \"%s\"\n", j, Key_KeynumToString (i), bindbuf);
928 for (i = 0; i < 32; i++) {
929 key_lines[i][0] = ']';
935 // register our functions
937 Cmd_AddCommand ("in_bind", Key_In_Bind_f, "binds a command to the specified key in the selected bindmap");
938 Cmd_AddCommand ("in_unbind", Key_In_Unbind_f, "removes command on the specified key in the selected bindmap");
939 Cmd_AddCommand ("in_bindmap", Key_In_Bindmap_f, "selects active foreground and background (used only if a key is not bound in the foreground) bindmaps for typing");
941 Cmd_AddCommand ("bind", Key_Bind_f, "binds a command to the specified key in bindmap 0");
942 Cmd_AddCommand ("unbind", Key_Unbind_f, "removes a command on the specified key in bindmap 0");
943 Cmd_AddCommand ("unbindall", Key_Unbindall_f, "removes all commands from all keys in all bindmaps (leaving only shift-escape and escape)");
945 Cvar_RegisterVariable (&con_closeontoggleconsole);
948 const char *Key_GetBind (int key)
951 if (key < 0 || key >= MAX_KEYS)
953 bind = keybindings[key_bmap][key];
955 bind = keybindings[key_bmap2][key];
959 qboolean CL_VM_InputEvent (qboolean down, int key, int ascii);
963 Called by the system between frames for both key up and key down events
964 Should NOT be called during an interrupt!
967 static char tbl_keyascii[MAX_KEYS];
968 static keydest_t tbl_keydest[MAX_KEYS];
971 Key_Event (int key, int ascii, qboolean down)
975 keydest_t keydest = key_dest;
977 if (key < 0 || key >= MAX_KEYS)
981 bind = keybindings[key_bmap][key];
983 bind = keybindings[key_bmap2][key];
985 if (developer.integer >= 1000)
986 Con_Printf("Key_Event(%i, '%c', %s) keydown %i bind \"%s\"\n", key, ascii, down ? "down" : "up", keydown[key], bind ? bind : "");
988 if(key_consoleactive)
989 keydest = key_console;
993 // increment key repeat count each time a down is received so that things
994 // which want to ignore key repeat can ignore it
995 keydown[key] = min(keydown[key] + 1, 2);
996 if(keydown[key] == 1) {
997 tbl_keyascii[key] = ascii;
998 tbl_keydest[key] = keydest;
1000 ascii = tbl_keyascii[key];
1001 keydest = tbl_keydest[key];
1006 // clear repeat count now that the key is released
1008 keydest = tbl_keydest[key];
1009 ascii = tbl_keyascii[key];
1012 if(keydest == key_void)
1015 // key_consoleactive is a flag not a key_dest because the console is a
1016 // high priority overlay ontop of the normal screen (designed as a safety
1017 // feature so that developers and users can rescue themselves from a bad
1020 // this also means that toggling the console on/off does not lose the old
1023 // specially handle escape (togglemenu) and shift-escape (toggleconsole)
1024 // engine bindings, these are not handled as normal binds so that the user
1025 // can recover from a completely empty bindmap
1026 if (key == K_ESCAPE)
1028 // ignore key repeats on escape
1029 if (keydown[key] > 1)
1032 // escape does these things:
1033 // key_consoleactive - close console
1034 // key_message - abort messagemode
1035 // key_menu - go to parent menu (or key_game)
1036 // key_game - open menu
1038 // in all modes shift-escape toggles console
1039 if (keydown[K_SHIFT])
1043 Con_ToggleConsole_f ();
1044 tbl_keydest[key] = key_void; // esc release should go nowhere (especially not to key_menu or key_game)
1054 if(key_consoleactive & KEY_CONSOLEACTIVE_FORCED)
1056 key_consoleactive &= ~KEY_CONSOLEACTIVE_USER;
1060 Con_ToggleConsole_f();
1066 Key_Message (key, ascii); // that'll close the message input
1070 case key_menu_grabbed:
1071 MR_KeyEvent (key, ascii, down);
1075 // csqc has priority over toggle menu if it wants to (e.g. handling escape for UI stuff in-game.. :sick:)
1076 q = CL_VM_InputEvent(down, key, ascii);
1082 Con_Printf ("Key_Event: Bad key_dest\n");
1087 // send function keydowns to interpreter no matter what mode is (unless the menu has specifically grabbed the keyboard, for rebinding keys)
1088 if (keydest != key_menu_grabbed)
1089 if (key >= K_F1 && key <= K_F12)
1093 if(keydown[key] == 1 && down)
1095 // button commands add keynum as a parm
1097 Cbuf_AddText (va("%s %i\n", bind, key));
1100 Cbuf_AddText (bind);
1101 Cbuf_AddText ("\n");
1103 } else if(bind[0] == '+' && !down && keydown[key] == 0)
1104 Cbuf_AddText(va("-%s %i\n", bind + 1, key));
1109 // send input to console if it wants it
1110 if (keydest == key_console)
1114 // con_closeontoggleconsole enables toggleconsole keys to close the
1115 // console, as long as they are not the color prefix character
1116 // (special exemption for german keyboard layouts)
1117 if (con_closeontoggleconsole.integer && bind && !strncmp(bind, "toggleconsole", strlen("toggleconsole")) && (key_consoleactive & KEY_CONSOLEACTIVE_USER) && ascii != STRING_COLOR_TAG)
1119 Con_ToggleConsole_f ();
1122 Key_Console (key, ascii);
1126 // handle toggleconsole in menu too
1127 if (keydest == key_menu)
1129 if (down && con_closeontoggleconsole.integer && bind && !strncmp(bind, "toggleconsole", strlen("toggleconsole")) && ascii != STRING_COLOR_TAG)
1131 Con_ToggleConsole_f ();
1132 tbl_keydest[key] = key_void; // key release should go nowhere (especially not to key_menu or key_game)
1137 // ignore binds while a video is played, let the video system handle the key event
1138 if (cl_videoplaying)
1140 CL_Video_KeyEvent (key, ascii, keydown[key] != 0);
1144 // anything else is a key press into the game, chat line, or menu
1149 Key_Message (key, ascii);
1152 case key_menu_grabbed:
1153 MR_KeyEvent (key, ascii, down);
1156 q = CL_VM_InputEvent(down, key, ascii);
1157 // ignore key repeats on binds and only send the bind if the event hasnt been already processed by csqc
1160 if(keydown[key] == 1 && down)
1162 // button commands add keynum as a parm
1164 Cbuf_AddText (va("%s %i\n", bind, key));
1167 Cbuf_AddText (bind);
1168 Cbuf_AddText ("\n");
1170 } else if(bind[0] == '+' && !down && keydown[key] == 0)
1171 Cbuf_AddText(va("-%s %i\n", bind + 1, key));
1175 Con_Printf ("Key_Event: Bad key_dest\n");
1185 Key_ClearStates (void)
1187 memset(keydown, 0, sizeof(keydown));