Browse Source

Android: Fixed finishing Activity on some devices if right mouse button pressed.

Partially fixes Bugzilla #3227.
Philipp Wiesemann 9 years ago
parent
commit
2191abb2c9
1 changed files with 14 additions and 0 deletions
  1. 14 0
      android-project/src/org/libsdl/app/SDLActivity.java

+ 14 - 0
android-project/src/org/libsdl/app/SDLActivity.java

@@ -1196,6 +1196,20 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
             }
         }
 
+        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;
     }