From d1891adcede093efa763278a312c6dce821ebae6 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Mon, 12 Aug 2024 19:22:36 -0700 Subject: [PATCH] Enable `BUTTON_FORWARD` and `BUTTON_BACK` mouse buttons on Android --- doc/classes/@GlobalScope.xml | 6 +++--- editor/plugins/script_editor_plugin.cpp | 10 ++++++++-- .../java/lib/src/org/godotengine/godot/Godot.kt | 9 ++------- .../godotengine/godot/input/GodotInputHandler.java | 11 ----------- 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 63f5947280c..190e9128af9 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -2020,16 +2020,16 @@ Help key. - Media back key. Not to be confused with the Back button on an Android device. + Back key. - Media forward key. + Forward key. Media stop key. - Media refresh key. + Refresh key. Volume down key. diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index d7de5a72230..62b9f15346f 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -4183,8 +4183,14 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/show_in_file_system", TTR("Show in FileSystem")), SHOW_IN_FILE_SYSTEM); file_menu->get_popup()->add_separator(); - file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_previous", TTR("History Previous"), KeyModifierMask::ALT | Key::LEFT), WINDOW_PREV); - file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_next", TTR("History Next"), KeyModifierMask::ALT | Key::RIGHT), WINDOW_NEXT); + file_menu->get_popup()->add_shortcut( + ED_SHORTCUT_ARRAY("script_editor/history_previous", TTR("History Previous"), + { int32_t(KeyModifierMask::ALT | Key::LEFT), int32_t(Key::BACK) }), + WINDOW_PREV); + file_menu->get_popup()->add_shortcut( + ED_SHORTCUT_ARRAY("script_editor/history_next", TTR("History Next"), + { int32_t(KeyModifierMask::ALT | Key::RIGHT), int32_t(Key::FORWARD) }), + WINDOW_NEXT); ED_SHORTCUT_OVERRIDE("script_editor/history_previous", "macos", KeyModifierMask::ALT | KeyModifierMask::META | Key::LEFT); ED_SHORTCUT_OVERRIDE("script_editor/history_next", "macos", KeyModifierMask::ALT | KeyModifierMask::META | Key::RIGHT); diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt index 38bd336e2d9..b606df63d7a 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt @@ -909,15 +909,10 @@ class Godot(private val context: Context) { } fun onBackPressed() { - var shouldQuit = true for (plugin in pluginRegistry.allPlugins) { - if (plugin.onMainBackPressed()) { - shouldQuit = false - } - } - if (shouldQuit) { - renderView?.queueOnRenderThread { GodotLib.back() } + plugin.onMainBackPressed() } + renderView?.queueOnRenderThread { GodotLib.back() } } /** diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java index fb41cd00c02..36bee6ef224 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java @@ -154,10 +154,6 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens } public boolean onKeyUp(final int keyCode, KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_BACK) { - return true; - } - if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { return false; } @@ -183,13 +179,6 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens } public boolean onKeyDown(final int keyCode, KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_BACK) { - godot.onBackPressed(); - // press 'back' button should not terminate program - //normal handle 'back' event in game logic - return true; - } - if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { return false; }