X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fevents.c;h=3346055722afa7566fa7f249ade02584d18a4f15;hb=7732b3bda99e3cafc7db8718f2cac1f507c978e8;hp=6fee5bbce8684de0badc8642ca52a9bfeeb76e68;hpb=d81b002c4d63b292284b1bea1972b4d764f6fb59;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 6fee5bbc..33460557 100644 --- a/src/events.c +++ b/src/events.c @@ -39,6 +39,8 @@ static int cursor_mode_last = CURSOR_DEFAULT; static unsigned int special_cursor_delay = 0; static unsigned int special_cursor_delay_value = 1000; +static boolean virtual_button_pressed = FALSE; + // forward declarations for internal use static void HandleNoEvent(void); @@ -722,6 +724,8 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event) "KEY_PRESSED"); int i; + virtual_button_pressed = (key_status == KEY_PRESSED && key != KSYM_UNDEFINED); + // for any touch input event, enable overlay buttons (if activated) SetOverlayEnabled(TRUE); @@ -1452,9 +1456,15 @@ void HandleKeyEvent(KeyEvent *event) // always map the "back" button to the "escape" key on Android devices key = KSYM_Escape; } + else if (key == KSYM_Menu) + { + // the "menu" button can be used to toggle displaying virtual buttons + if (key_status == KEY_PRESSED) + SetOverlayEnabled(!GetOverlayEnabled()); + } else { - // for any key event other than "back" button, disable overlay buttons + // for any other "real" key event, disable virtual buttons SetOverlayEnabled(FALSE); } #endif @@ -1539,10 +1549,13 @@ void HandleButton(int mx, int my, int button, int button_nr) #if defined(PLATFORM_ANDROID) // when playing, only handle gadgets when using "follow finger" controls // or when using touch controls in combination with the MM game engine + // or when using gadgets that do not overlap with virtual buttons handle_gadgets = (game_status != GAME_MODE_PLAYING || level.game_engine_type == GAME_ENGINE_TYPE_MM || - strEqual(setup.touch.control_type, TOUCH_CONTROL_FOLLOW_FINGER)); + strEqual(setup.touch.control_type, TOUCH_CONTROL_FOLLOW_FINGER) || + (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS) && + !virtual_button_pressed)); #endif if (HandleGlobalAnimClicks(mx, my, button)) @@ -1836,9 +1849,9 @@ boolean HandleKeysDebug(Key key, int key_status) return TRUE; } } +#endif return FALSE; -#endif } void HandleKey(Key key, int key_status)