From: divverent Date: Tue, 2 Aug 2011 18:58:57 +0000 (+0000) Subject: add a helper function to release all keys "properly" X-Git-Tag: xonotic-v0.6.0~163^2~289 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=137357d6b7e13e7b2d4bbaeb719dfd4f218a1e5e add a helper function to release all keys "properly" (not used yet) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11263 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/keys.c b/keys.c index ea6e2d59..817ce92d 100644 --- 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 diff --git a/keys.h b/keys.h index c2587aed..e471a235 100644 --- a/keys.h +++ b/keys.h @@ -377,7 +377,8 @@ void Key_Init(void); void Key_Shutdown(void); void Key_Init_Cvars(void); void Key_Event(int key, int ascii, qboolean down); -void Key_ClearStates (void); +void Key_ReleaseAll (void); +void Key_ClearStates (void); // FIXME: should this function still exist? Or should Key_ReleaseAll be used instead when shutting down a vid driver? void Key_EventQueue_Block(void); void Key_EventQueue_Unblock(void);