Don't use DPAD devices as joystick input on Android
authorSam Lantinga <slouken@libsdl.org>
Thu, 19 Oct 2017 13:54:56 -0700
changeset 116354a94743e31fe
parent 11634 ced7925b7a95
child 11636 ec1c9bded2d0
Don't use DPAD devices as joystick input on Android
android-project/src/org/libsdl/app/SDLControllerManager.java
     1.1 --- a/android-project/src/org/libsdl/app/SDLControllerManager.java	Wed Oct 18 23:49:46 2017 -0400
     1.2 +++ b/android-project/src/org/libsdl/app/SDLControllerManager.java	Thu Oct 19 13:54:56 2017 -0700
     1.3 @@ -92,17 +92,16 @@
     1.4          if ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) {
     1.5              Log.v(TAG, "Input device " + device.getName() + " is a joystick.");
     1.6          }
     1.7 +        /* A lot of things are a DPAD that we don't want to use as a joystick (e.g. gpio input, etc.)
     1.8          if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) {
     1.9              Log.v(TAG, "Input device " + device.getName() + " is a dpad.");
    1.10          }
    1.11 +        */
    1.12          if ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) {
    1.13              Log.v(TAG, "Input device " + device.getName() + " is a gamepad.");
    1.14          }
    1.15  
    1.16 -        return (((sources & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) ||
    1.17 -                ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) ||
    1.18 -                ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
    1.19 -        );
    1.20 +        return ((sources & (InputDevice.SOURCE_CLASS_JOYSTICK|InputDevice.SOURCE_GAMEPAD)) != 0);
    1.21      }
    1.22  
    1.23  }