Android: Fixed finishing Activity on some devices if right mouse button pressed.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 13 Jan 2016 19:31:03 +0100
changeset 10053 d710a7a66aa5
parent 10052 541e2b6818a7
child 10054 fb06163059bf
Android: Fixed finishing Activity on some devices if right mouse button pressed. Partially fixes Bugzilla #3227.
android-project/src/org/libsdl/app/SDLActivity.java
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Tue Jan 12 22:23:53 2016 +0100
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Wed Jan 13 19:31:03 2016 +0100
@@ -1196,6 +1196,20 @@
             }
         }
 
+        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;
     }