Fixed bug 2949 - [Android] Virtual DPAD remote not registered
authorSam Lantinga <slouken@libsdl.org>
Tue, 16 Jun 2015 23:58:09 -0700
changeset 9750f6567f77f663
parent 9749 a1b920bc870d
child 9751 47ae0a3aa68f
Fixed bug 2949 - [Android] Virtual DPAD remote not registered

Sylvain

I have an android device to which I try to connect the google virtual remote application.
https://play.google.com/store/apps/details?id=com.google.android.tv.remote

The java method "pollInputDevices()" detects it as an input source 0x701 which is (SOURCE_KEYBOARD | SOURCE_GAMEPAD | SOURCE_DPAD).

It it not added because it does not AND-bitwise with "SOURCE_CLASS_JOYSTICK".
It's only a virtual DPAD and it works when checking also with SOURCE_CLASS_BUTTON
android-project/src/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Tue Jun 16 22:16:35 2015 -0700
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Tue Jun 16 23:58:09 2015 -0700
     1.3 @@ -1496,7 +1496,13 @@
     1.4              if (joystick == null) {
     1.5                  joystick = new SDLJoystick();
     1.6                  InputDevice joystickDevice = InputDevice.getDevice(deviceIds[i]);
     1.7 -                if( (joystickDevice.getSources() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
     1.8 +
     1.9 +                if ( 
    1.10 +                      (joystickDevice.getSources() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 
    1.11 +                   ||
    1.12 +                      (joystickDevice.getSources() & InputDevice.SOURCE_CLASS_BUTTON) != 0 
    1.13 +                  )
    1.14 +                {
    1.15                      joystick.device_id = deviceIds[i];
    1.16                      joystick.name = joystickDevice.getName();
    1.17                      joystick.axes = new ArrayList<InputDevice.MotionRange>();