From 9cd35bed3dc59ad5d2623d546218ec1e24efc894 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 4 Jan 2024 21:40:51 +0100 Subject: [PATCH] (Android) Pressing the back button now closes the application --- es-core/src/InputManager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index dd0555381..33c56e108 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -451,6 +451,15 @@ bool InputManager::parseEvent(const SDL_Event& event) if (event.key.repeat) return false; +#if defined(__ANDROID__) + // Quit application if the back button is pressed. + if (event.key.keysym.sym == SDLK_AC_BACK) { + SDL_Event quit; + quit.type = SDL_QUIT; + SDL_PushEvent(&quit); + return false; + } +#endif // There is no need to handle the OS-default quit shortcut (Alt + F4 on Windows and // Linux and Command + Q on macOS) as that's taken care of by the window manager. // The exception is Android as there are are no default quit shortcuts on this OS.