From 5f29516b5acf64df0acb0efeb20f64c2945fc74b Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 22 Jun 2022 15:17:19 +0200 Subject: [PATCH] fixed synchronization problem when configuring game controller This fixes a bug that can happen due to bad initialization of a delay counter (to limit the maximum time spent on handling events), causing it to reach the maximum delay while the screen refresh is also waiting for the video delay. Resetting the counter right after screen update fixes this potential problem. --- src/screens.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/screens.c b/src/screens.c index b45e9911..533cf4c4 100644 --- a/src/screens.c +++ b/src/screens.c @@ -8630,11 +8630,6 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick) { 282, 210, MARKER_AXIS_Y, "righty", }, }; - unsigned int event_frame_delay = 0; - unsigned int event_frame_delay_value = GAME_FRAME_DELAY; - - ResetDelayCounter(&event_frame_delay); - if (!bitmaps_initialized) { controller = LoadCustomImage("joystick/controller.png"); @@ -8766,6 +8761,12 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick) screen_initialized = TRUE; + unsigned int event_frame_delay = 0; + unsigned int event_frame_delay_value = GAME_FRAME_DELAY; + + // reset frame delay counter directly after updating screen + ResetDelayCounter(&event_frame_delay); + while (NextValidEvent(&event)) { switch (event.type) -- 2.34.1