]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - keys.c
fix two crashes that divVerent found and fixed but didn't commit
[xonotic/darkplaces.git] / keys.c
diff --git a/keys.c b/keys.c
index ea6e2d5985c397392f77eb1563806ad25adde2b2..f88ea5a4553394bf681b30679e934a96ee61cf0c 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -1686,7 +1686,7 @@ void Key_FindKeysForCommand (const char *command, int *keys, int numkeys, int bi
        }
 }
 
-qboolean CL_VM_InputEvent (qboolean down, int key, int ascii);
+extern qboolean CL_VM_InputEvent (int eventtype, int x, int y);
 
 /*
 ===================
@@ -1852,7 +1852,7 @@ Key_Event (int key, int ascii, qboolean down)
 
                        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);
+                               q = CL_VM_InputEvent(down ? 0 : 1, key, ascii);
                                if (!q && down)
                                        MR_ToggleMenu(1);
                                break;
@@ -1899,6 +1899,10 @@ Key_Event (int key, int ascii, qboolean down)
                        Con_ToggleConsole_f ();
                        return;
                }
+
+               if (COM_CheckParm ("-noconsole"))
+                       return; // only allow the key bind to turn off console
+
                Key_Console (key, ascii);
                return;
        }
@@ -1936,7 +1940,7 @@ Key_Event (int key, int ascii, qboolean down)
                        MR_KeyEvent (key, ascii, down);
                        break;
                case key_game:
-                       q = CL_VM_InputEvent(down, key, ascii);
+                       q = CL_VM_InputEvent(down ? 0 : 1, key, ascii);
                        // ignore key repeats on binds and only send the bind if the event hasnt been already processed by csqc
                        if (!q && bind)
                        {
@@ -1959,6 +1963,21 @@ Key_Event (int key, int ascii, qboolean down)
        }
 }
 
+// a helper to simulate release of ALL keys
+void
+Key_ReleaseAll (void)
+{
+       int key;
+       // clear the event queue first
+       eventqueue_idx = 0;
+       // then send all down events (possibly into the event queue)
+       for(key = 0; key < MAX_KEYS; ++key)
+               if(keydown[key])
+                       Key_Event(key, 0, false);
+       // now all keys are guaranteed down (once the event queue is unblocked)
+       // and only future events count
+}
+
 /*
 ===================
 Key_ClearStates