fixed synchronization problem when configuring game controller
[rocksndiamonds.git] / src / screens.c
index d027efa27227ff95e00338bc6a1c8d457683932f..533cf4c4ce2cb84338297ff56d9de7ec122911a5 100644 (file)
@@ -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)
@@ -9745,6 +9746,10 @@ static void CreateScreenMenubuttons(void)
     int type = GD_TYPE_NORMAL_BUTTON;
     boolean checked = FALSE;
 
+    // do not use touch buttons if overlay touch buttons are disabled
+    if (is_touch_button && !setup.touch.overlay_buttons)
+      continue;
+
     event_mask = menubutton_info[i].event_mask;
 
     x = (is_touch_button ? pos->x : mSX + GDI_ACTIVE_POS(pos->x));