- D_ProcessEvents(): Delay EV_KeyUp events until any EV_KeyDown events for the corresponding key have been processed. This makes the mouse under SDL a lot better.

This commit is contained in:
Mitch Richters 2021-11-17 18:41:03 +11:00 committed by Christoph Oelckers
parent 312b5ce66e
commit c4f7760ab2

View file

@ -67,11 +67,20 @@ CVAR(Bool, m_filter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
void D_ProcessEvents (void) void D_ProcessEvents (void)
{ {
event_t *ev; bool keywasdown[NUM_KEYS] = { false };
TArray<event_t*> delayedevents;
while (eventtail != eventhead) while (eventtail != eventhead)
{ {
ev = &events[eventtail]; event_t *ev = &events[eventtail];
eventtail = (eventtail + 1) & (MAXEVENTS - 1); eventtail = (eventtail + 1) & (MAXEVENTS - 1);
if (ev->type == EV_KeyUp && keywasdown[ev->data1])
{
delayedevents.Push(ev);
continue;
}
if (ev->type == EV_None) if (ev->type == EV_None)
continue; continue;
if (ev->type == EV_DeviceChange) if (ev->type == EV_DeviceChange)
@ -85,7 +94,12 @@ void D_ProcessEvents (void)
continue; // menu ate the event continue; // menu ate the event
} }
G_Responder (ev); keywasdown[ev->data1] = G_Responder(ev) && ev->type == EV_KeyDown;
}
for (auto& ev: delayedevents)
{
D_PostEvent(ev);
} }
} }