fixed synchronization problem when configuring keyboard
authorHolger Schemel <info@artsoft.org>
Wed, 22 Jun 2022 21:29:05 +0000 (23:29 +0200)
committerHolger Schemel <info@artsoft.org>
Wed, 22 Jun 2022 21:32:54 +0000 (23:32 +0200)
This is a somewhat similar bug like that in the previous commit, but
in this case only one event was processed for each screen update,
causing many events (like those produced from analog sticks that are
moved while the keyboard is about to be configured) to be processed
one after the other, each with a full video frame delay in between.

The fix works just like that used when configuring game controllers.

src/screens.c

index 533cf4c4ce2cb84338297ff56d9de7ec122911a5..576f1ff0566a054f1dd9d4fc2df1345cde67da33 100644 (file)
@@ -8456,8 +8456,13 @@ static boolean CustomizeKeyboardMain(int player_nr)
   while (!finished)
   {
     Event event;
+    unsigned int event_frame_delay = 0;
+    unsigned int event_frame_delay_value = GAME_FRAME_DELAY;
 
-    if (NextValidEvent(&event))
+    // reset frame delay counter directly after updating screen
+    ResetDelayCounter(&event_frame_delay);
+
+    while (NextValidEvent(&event))
     {
       switch (event.type)
       {
@@ -8528,6 +8533,10 @@ static boolean CustomizeKeyboardMain(int player_nr)
          HandleOtherEvents(&event);
          break;
       }
+
+      // do not handle events for longer than standard frame delay period
+      if (DelayReached(&event_frame_delay, event_frame_delay_value))
+       break;
     }
 
     BackToFront();