added enabling/disabling virtual button overlay depending on input events
[rocksndiamonds.git] / src / events.c
index 2472fdf5f8978b048af638730299206544445255..64fda8081da0fab274d5f3008bb35369d4a5f486 100644 (file)
@@ -250,7 +250,11 @@ void HandleOtherEvents(Event *event)
 #if defined(TARGET_SDL2)
     case SDL_CONTROLLERBUTTONDOWN:
     case SDL_CONTROLLERBUTTONUP:
 #if defined(TARGET_SDL2)
     case SDL_CONTROLLERBUTTONDOWN:
     case SDL_CONTROLLERBUTTONUP:
+      // for any game controller button event, disable overlay buttons
+      SetOverlayEnabled(FALSE);
+
       HandleSpecialGameControllerButtons(event);
       HandleSpecialGameControllerButtons(event);
+
       /* FALL THROUGH */
     case SDL_CONTROLLERDEVICEADDED:
     case SDL_CONTROLLERDEVICEREMOVED:
       /* FALL THROUGH */
     case SDL_CONTROLLERDEVICEADDED:
     case SDL_CONTROLLERDEVICEREMOVED:
@@ -668,6 +672,9 @@ void HandleFingerEvent(FingerEvent *event)
                             "KEY_PRESSED");
     int i;
 
                             "KEY_PRESSED");
     int i;
 
+    // for any touch input event, enable overlay buttons (if activated)
+    SetOverlayEnabled(TRUE);
+
     Error(ERR_DEBUG, "::: key '%s' was '%s' [fingerId: %lld]",
          getKeyNameFromKey(key), key_status_name, event->fingerId);
 
     Error(ERR_DEBUG, "::: key '%s' was '%s' [fingerId: %lld]",
          getKeyNameFromKey(key), key_status_name, event->fingerId);
 
@@ -1148,9 +1155,16 @@ void HandleKeyEvent(KeyEvent *event)
 #endif
 
 #if defined(PLATFORM_ANDROID)
 #endif
 
 #if defined(PLATFORM_ANDROID)
-  // always map the "back" button to the "escape" key on Android devices
   if (key == KSYM_Back)
   if (key == KSYM_Back)
+  {
+    // always map the "back" button to the "escape" key on Android devices
     key = KSYM_Escape;
     key = KSYM_Escape;
+  }
+  else
+  {
+    // for any key event other than "back" button, disable overlay buttons
+    SetOverlayEnabled(FALSE);
+  }
 #endif
 
   HandleKeyModState(keymod, key_status);
 #endif
 
   HandleKeyModState(keymod, key_status);