old_key_consoleactive = key_consoleactive;
key_dest = key_void;
key_consoleactive = false;
- Sys_SendKeyEvents();
+ Key_EventQueue_Block(); Sys_SendKeyEvents();
key_dest = old_key_dest;
key_consoleactive = old_key_consoleactive;
}
static char tbl_keyascii[MAX_KEYS];
static keydest_t tbl_keydest[MAX_KEYS];
+typedef struct eventqueueitem_s
+{
+ int key;
+ int ascii;
+ qboolean down;
+}
+eventqueueitem_t;
+static int events_blocked = 0;
+static eventqueueitem_t eventqueue[32];
+static unsigned eventqueue_idx = 0;
+
+static void Key_EventQueue_Add(int key, int ascii, qboolean down)
+{
+ if(eventqueue_idx < sizeof(eventqueue) / sizeof(*eventqueue))
+ {
+ eventqueue[eventqueue_idx].key = key;
+ eventqueue[eventqueue_idx].ascii = ascii;
+ eventqueue[eventqueue_idx].down = down;
+ ++eventqueue_idx;
+ }
+}
+
+void Key_EventQueue_Block(void)
+{
+ // block key events until call to Unblock
+ events_blocked = true;
+}
+
+void Key_EventQueue_Unblock(void)
+{
+ // unblocks key events again
+ unsigned i;
+ events_blocked = false;
+ for(i = 0; i < eventqueue_idx; ++i)
+ Key_Event(eventqueue[i].key, eventqueue[i].ascii, eventqueue[i].down);
+ eventqueue_idx = 0;
+}
+
void
Key_Event (int key, int ascii, qboolean down)
{
if (key < 0 || key >= MAX_KEYS)
return;
+ if(events_blocked)
+ {
+ Key_EventQueue_Add(key, ascii, down);
+ return;
+ }
+
// get key binding
bind = keybindings[key_bmap][key];
if (!bind)
void Key_Event(int key, int ascii, qboolean down);
void Key_ClearStates (void);
void Key_SetBinding (int keynum, int bindmap, const char *binding);
+void Key_EventQueue_Block(void);
+void Key_EventQueue_Unblock(void);
#endif // __KEYS_H