From 2191abb2c90ec2c465a71a12a252c78320566622 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Wed, 13 Jan 2016 19:31:03 +0100 Subject: [PATCH] Android: Fixed finishing Activity on some devices if right mouse button pressed. Partially fixes Bugzilla #3227. --- .../src/org/libsdl/app/SDLActivity.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index cc7a817e32411..fb34de85951bd 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -1196,6 +1196,20 @@ else if (event.getAction() == KeyEvent.ACTION_UP) { } } + if ((event.getSource() & InputDevice.SOURCE_MOUSE) != 0) { + // on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses + // they are ignored here because sending them as mouse input to SDL is messy + if ((keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_FORWARD)) { + switch (event.getAction()) { + case KeyEvent.ACTION_DOWN: + case KeyEvent.ACTION_UP: + // mark the event as handled or it will be handled by system + // handling KEYCODE_BACK by system will call onBackPressed() + return true; + } + } + } + return false; }