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 10053d710a7a66aa5
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
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Tue Jan 12 22:23:53 2016 +0100
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Wed Jan 13 19:31:03 2016 +0100
     1.3 @@ -1196,6 +1196,20 @@
     1.4              }
     1.5          }
     1.6  
     1.7 +        if ((event.getSource() & InputDevice.SOURCE_MOUSE) != 0) {
     1.8 +            // on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses
     1.9 +            // they are ignored here because sending them as mouse input to SDL is messy
    1.10 +            if ((keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_FORWARD)) {
    1.11 +                switch (event.getAction()) {
    1.12 +                case KeyEvent.ACTION_DOWN:
    1.13 +                case KeyEvent.ACTION_UP:
    1.14 +                    // mark the event as handled or it will be handled by system
    1.15 +                    // handling KEYCODE_BACK by system will call onBackPressed()
    1.16 +                    return true;
    1.17 +                }
    1.18 +            }
    1.19 +        }
    1.20 +
    1.21          return false;
    1.22      }
    1.23