X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=keys.c;h=fce61a985fcffcb512d82d9af5ca54ef5f084488;hb=6959d46a61c865f2b5ac9250c3fd940107175e16;hp=8a86757155ba9125eec188d10a3893abb20348ea;hpb=63340afe2a2fe9d185810e69462edfc0f4790db7;p=xonotic%2Fdarkplaces.git diff --git a/keys.c b/keys.c index 8a867571..fce61a98 100644 --- a/keys.c +++ b/keys.c @@ -233,7 +233,7 @@ Interactive line editing and console scrollback ==================== */ static void -Key_Console (int key, char ascii) +Key_Console (int key, int ascii) { // LordHavoc: copied most of this from Q2 to improve keyboard handling switch (key) @@ -523,19 +523,22 @@ Key_Console (int key, char ascii) //============================================================================ -qboolean chat_team; +int chat_mode; char chat_buffer[MAX_INPUTLINE]; unsigned int chat_bufferlen = 0; extern int Nicks_CompleteChatLine(char *buffer, size_t size, unsigned int pos); static void -Key_Message (int key, char ascii) +Key_Message (int key, int ascii) { if (key == K_ENTER || ascii == 10 || ascii == 13) { - Cmd_ForwardStringToServer(va("%s %s", chat_team ? "say_team" : "say ", chat_buffer)); + if(chat_mode < 0) + Cmd_ExecuteString(chat_buffer, src_command); // not Cbuf_AddText to allow semiclons in args; however, this allows no variables then. Use aliases! + else + Cmd_ForwardStringToServer(va("%s %s", chat_mode ? "say_team" : "say ", chat_buffer)); key_dest = key_game; chat_bufferlen = 0; @@ -543,6 +546,8 @@ Key_Message (int key, char ascii) return; } + // TODO add support for arrow keys and simple editing + if (key == K_ESCAPE) { key_dest = key_game; chat_bufferlen = 0; @@ -900,7 +905,7 @@ static char tbl_keyascii[MAX_KEYS]; static keydest_t tbl_keydest[MAX_KEYS]; void -Key_Event (int key, char ascii, qboolean down) +Key_Event (int key, int ascii, qboolean down) { const char *bind; qboolean q; @@ -982,8 +987,15 @@ Key_Event (int key, char ascii, qboolean down) { case key_console: if(down) - if(key_consoleactive & KEY_CONSOLEACTIVE_USER) + { + if(key_consoleactive & KEY_CONSOLEACTIVE_FORCED) + { + key_consoleactive &= ~KEY_CONSOLEACTIVE_USER; + MR_ToggleMenu_f (); + } + else Con_ToggleConsole_f(); + } break; case key_message: @@ -1011,21 +1023,22 @@ Key_Event (int key, char ascii, qboolean down) // send function keydowns to interpreter no matter what mode is (unless the menu has specifically grabbed the keyboard, for rebinding keys) if (keydest != key_menu_grabbed) - if (key >= K_F1 && key <= K_F12 && down) + if (key >= K_F1 && key <= K_F12) { - // ignore key repeats on F1-F12 binds - if (keydown[key] > 1) - return; if (bind) { - // button commands add keynum as a parm - if (bind[0] == '+') - Cbuf_AddText (va("%s %i\n", bind, key)); - else + if(keydown[key] == 1 && down) { - Cbuf_AddText (bind); - Cbuf_AddText ("\n"); - } + // button commands add keynum as a parm + if (bind[0] == '+') + Cbuf_AddText (va("%s %i\n", bind, key)); + else + { + Cbuf_AddText (bind); + Cbuf_AddText ("\n"); + } + } else if(bind[0] == '+' && !down && keydown[key] == 0) + Cbuf_AddText(va("-%s %i\n", bind + 1, key)); } return; } @@ -1047,6 +1060,16 @@ Key_Event (int key, char ascii, qboolean down) return; } + // handle toggleconsole in menu too + if (keydest == key_menu) + { + if (down && con_closeontoggleconsole.integer && bind && !strncmp(bind, "toggleconsole", strlen("toggleconsole")) && ascii != STRING_COLOR_TAG) + { + Con_ToggleConsole_f (); + tbl_keydest[key] = key_void; // key release should go nowhere (especially not to key_menu or key_game) + return; + } + } // ignore binds while a video is played, let the video system handle the key event if (cl_videoplaying)