From 3924b6bba3cb60bf95ab6fb706b00f4af682d0ef Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Wed, 28 Sep 2022 09:19:02 +0300 Subject: [PATCH 1/2] Fix back button on Android --- src/win32.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win32.cc b/src/win32.cc index 6727d5b..b9474fc 100644 --- a/src/win32.cc +++ b/src/win32.cc @@ -43,6 +43,7 @@ int main(int argc, char* argv[]) #endif #if __ANDROID__ + SDL_SetHint(SDL_HINT_ANDROID_TRAP_BACK_BUTTON, "1"); SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0"); SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"); chdir(SDL_AndroidGetExternalStoragePath()); From 3cca4a81e95f08f9045e3e29d7d946d666528576 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sun, 2 Oct 2022 13:56:49 +0300 Subject: [PATCH 2/2] Check back button to RMB emulation --- .../app/src/main/java/org/libsdl/app/SDLActivity.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/os/android/app/src/main/java/org/libsdl/app/SDLActivity.java b/os/android/app/src/main/java/org/libsdl/app/SDLActivity.java index d982943..7b55563 100644 --- a/os/android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/os/android/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -2036,6 +2036,14 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, switch (event.getAction()) { case KeyEvent.ACTION_DOWN: case KeyEvent.ACTION_UP: + if (keyCode == KeyEvent.KEYCODE_BACK) { + if (event.getAction() == KeyEvent.ACTION_DOWN) { + SDLActivity.onNativeMouse(MotionEvent.BUTTON_SECONDARY, MotionEvent.ACTION_DOWN, 0, 0, true); + } else if (event.getAction() == KeyEvent.ACTION_UP) { + SDLActivity.onNativeMouse(MotionEvent.BUTTON_SECONDARY, MotionEvent.ACTION_UP, 0, 0, true); + } + } + // mark the event as handled or it will be handled by system // handling KEYCODE_BACK by system will call onBackPressed() return true;