This is an improvement of commit
ba20bcc8, which totally cleared the
event queue after fading and after door/envelope requests, and which
prevented entering multiple key presses by intention (like starting
the game and immediately going to pause mode with the very first
game frame, by quickly pressing "space" twice in the main menu).
This change only removes key presses entered by keyboard auto-repeat
during fading or door/envelope animations, effectively preventing
accidentally entered multiple key events by pressing a key like
"space" or "return" a bit too long (which then triggers auto-repeat),
while it keeps multiple key events that were manually entered.
}
}
+void ClearAutoRepeatKeyEvents()
+{
+ while (PendingEvent())
+ {
+ Event next_event;
+
+ PeekEvent(&next_event);
+
+ /* if event is repeated key press event, remove it from event queue */
+ if (next_event.type == EVENT_KEYPRESS &&
+ next_event.key.repeat)
+ WaitEvent(&next_event);
+ else
+ break;
+ }
+}
+
void ClearEventQueue()
{
Event event;
void EventLoop(void);
void HandleOtherEvents(Event *);
+void ClearAutoRepeatKeyEvents(void);
void ClearEventQueue(void);
void ClearPlayerAction(void);
void SleepWhileUnmapped(void);
redraw_mask &= ~fade_mask;
- ClearEventQueue();
+ ClearAutoRepeatKeyEvents();
}
static void SetScreenStates_BeforeFadingIn()
SkipUntilDelayReached(&anim_delay, anim_delay_value, &i, last_frame);
}
- ClearEventQueue();
+ ClearAutoRepeatKeyEvents();
}
void ShowEnvelope(int envelope_nr)
SkipUntilDelayReached(&anim_delay, anim_delay_value, &i, last_frame);
}
- ClearEventQueue();
+ ClearAutoRepeatKeyEvents();
}
void ShowEnvelopeRequest(char *text, unsigned int req_state, int action)
DrawMaskedBorder(REDRAW_DOOR_1);
DrawMaskedBorder(REDRAW_DOOR_2);
- ClearEventQueue();
+ ClearAutoRepeatKeyEvents();
return (door1 | door2);
}