]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
reintroduce the KEY_ESCAPE switch, but this time make sure it actually behaves right
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 2 Aug 2008 09:44:10 +0000 (09:44 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 2 Aug 2008 09:44:10 +0000 (09:44 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8433 d7cf8633-e32d-0410-b094-e92efae38249

keys.c

diff --git a/keys.c b/keys.c
index de6b3cefcc82a92bdce4639ddba6f0524b79ff4d..8a86757155ba9125eec188d10a3893abb20348ea 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -960,40 +960,53 @@ Key_Event (int key, char ascii, qboolean down)
                // ignore key repeats on escape
                if (keydown[key] > 1)
                        return;
+
                // escape does these things:
                // key_consoleactive - close console
                // key_message - abort messagemode
                // key_menu - go to parent menu (or key_game)
                // key_game - open menu
+
                // in all modes shift-escape toggles console
-               if (((key_consoleactive & KEY_CONSOLEACTIVE_USER) || keydown[K_SHIFT]) && down)
+               if (keydown[K_SHIFT])
                {
-                       Con_ToggleConsole_f ();
-                       tbl_keydest[key] = key_void; // ignore the release
+                       if(down)
+                       {
+                               Con_ToggleConsole_f ();
+                               tbl_keydest[key] = key_void; // esc release should go nowhere (especially not to key_menu or key_game)
+                       }
                        return;
                }
-#if 0
+
                switch (keydest)
                {
+                       case key_console:
+                               if(down)
+                                       if(key_consoleactive & KEY_CONSOLEACTIVE_USER)
+                                               Con_ToggleConsole_f();
+                               break;
+
                        case key_message:
                                if (down)
-                                       Key_Message (key, ascii);
+                                       Key_Message (key, ascii); // that'll close the message input
                                break;
+
                        case key_menu:
                        case key_menu_grabbed:
                                MR_KeyEvent (key, ascii, down);
                                break;
+
                        case key_game:
                                // csqc has priority over toggle menu if it wants to (e.g. handling escape for UI stuff in-game.. :sick:)
                                q = CL_VM_InputEvent(down, key, ascii);
                                if (!q && down)
                                        MR_ToggleMenu_f ();
                                break;
+
                        default:
                                Con_Printf ("Key_Event: Bad key_dest\n");
                }
                return;
-#endif
        }
 
        // send function keydowns to interpreter no matter what mode is (unless the menu has specifically grabbed the keyboard, for rebinding keys)
@@ -1018,7 +1031,7 @@ Key_Event (int key, char ascii, qboolean down)
        }
 
        // send input to console if it wants it
-       if (keydest == key_console && key != K_ESCAPE)
+       if (keydest == key_console)
        {
                if (!down)
                        return;
@@ -1028,7 +1041,6 @@ Key_Event (int key, char ascii, qboolean down)
                if (con_closeontoggleconsole.integer && bind && !strncmp(bind, "toggleconsole", strlen("toggleconsole")) && (key_consoleactive & KEY_CONSOLEACTIVE_USER) && ascii != STRING_COLOR_TAG)
                {
                        Con_ToggleConsole_f ();
-                       tbl_keydest[key] = key_void; // ignore the release
                        return;
                }
                Key_Console (key, ascii);
@@ -1036,18 +1048,6 @@ Key_Event (int key, char ascii, qboolean down)
        }
 
 
-       // FIXME: actually the up-bind should only be called if the button was actually pressed while key_dest == key_game [12/17/2007 Black]
-       //                       especially CL_VM_InputEvent should be able to prevent it from being called (to intercept the binds)
-       // key up events only generate commands if the game key binding is a button
-       // command (leading + sign).  These will occur even in console mode, to
-       // keep the character from continuing an action started before a console
-       // switch.  Button commands include the kenum as a parameter, so multiple
-       // downs can be matched with ups
-       /*
-       if (!down && bind && bind[0] == '+')
-               Cbuf_AddText(va("-%s %i\n", bind + 1, key));
-       */
-
        // ignore binds while a video is played, let the video system handle the key event
        if (cl_videoplaying)
        {
@@ -1085,11 +1085,6 @@ Key_Event (int key, char ascii, qboolean down)
                                        Cbuf_AddText(va("-%s %i\n", bind + 1, key));
                        }
                        break;
-               case key_console:
-                       // This happens for example when pressing shift in the console
-                       // closing the console, and then releasing shift.
-                       // Con_Printf("Key_Event: Console key ignored\n");
-                       break;
                default:
                        Con_Printf ("Key_Event: Bad key_dest\n");
        }