]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - keys.c
add a helper function to release all keys "properly"
[xonotic/darkplaces.git] / keys.c
diff --git a/keys.c b/keys.c
index ea6e2d5985c397392f77eb1563806ad25adde2b2..817ce92da6a38ae589788aa4f374b33ba420db61 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -1959,6 +1959,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
 /*
 ===================
 Key_ClearStates