Added additional logging to track down why the NVIDIA controller doesn't send the back button
authorSam Lantinga <slouken@libsdl.org>
Mon, 27 Apr 2020 19:12:02 -0700
changeset 13783d1b79a4a95be
parent 13782 0d962fba6f52
child 13784 cd8794af675f
Added additional logging to track down why the NVIDIA controller doesn't send the back button
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Mon Apr 27 13:31:10 2020 -0700
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Mon Apr 27 19:12:02 2020 -0700
     1.3 @@ -872,7 +872,7 @@
     1.4              }
     1.5          }
     1.6  
     1.7 -        Log.v("SDL", "setOrientation() requestedOrientation=" + req + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint);
     1.8 +        Log.v(TAG, "setOrientation() requestedOrientation=" + req + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint);
     1.9          mSingleton.setRequestedOrientation(req);
    1.10      }
    1.11  
    1.12 @@ -1082,7 +1082,7 @@
    1.13              /* environment variables set! */
    1.14              return true;
    1.15          } catch (Exception e) {
    1.16 -           Log.v("SDL", "exception " + e.toString());
    1.17 +           Log.v(TAG, "exception " + e.toString());
    1.18          }
    1.19          return false;
    1.20      }
    1.21 @@ -1868,6 +1868,19 @@
    1.22          int deviceId = event.getDeviceId();
    1.23          int source = event.getSource();
    1.24  
    1.25 +        if (source == InputDevice.SOURCE_UNKNOWN) {
    1.26 +            InputDevice device = InputDevice.getDevice(deviceId);
    1.27 +            if (device != null) {
    1.28 +                source = device.getSources();
    1.29 +            }
    1.30 +        }
    1.31 +
    1.32 +//		if (event.getAction() == KeyEvent.ACTION_DOWN) {
    1.33 +//			Log.v("SDL", "key down: " + keyCode + ", deviceId = " + deviceId + ", source = " + source);
    1.34 +//		} else if (event.getAction() == KeyEvent.ACTION_UP) {
    1.35 +//			Log.v("SDL", "key up: " + keyCode + ", deviceId = " + deviceId + ", source = " + source);
    1.36 +//		}
    1.37 +
    1.38          // Dispatch the different events depending on where they come from
    1.39          // Some SOURCE_JOYSTICK, SOURCE_DPAD or SOURCE_GAMEPAD are also SOURCE_KEYBOARD
    1.40          // So, we try to process them as JOYSTICK/DPAD/GAMEPAD events first, if that fails we try them as KEYBOARD
    1.41 @@ -1888,24 +1901,14 @@
    1.42              }
    1.43          }
    1.44  
    1.45 -        if (source == InputDevice.SOURCE_UNKNOWN) {
    1.46 -            InputDevice device = InputDevice.getDevice(deviceId);
    1.47 -            if (device != null) {
    1.48 -                source = device.getSources();
    1.49 -            }
    1.50 -        }
    1.51 -
    1.52          if ((source & InputDevice.SOURCE_KEYBOARD) != 0) {
    1.53              if (event.getAction() == KeyEvent.ACTION_DOWN) {
    1.54 -                //Log.v("SDL", "key down: " + keyCode);
    1.55                  if (SDLActivity.isTextInputEvent(event)) {
    1.56                      SDLInputConnection.nativeCommitText(String.valueOf((char) event.getUnicodeChar()), 1);
    1.57                  }
    1.58                  SDLActivity.onNativeKeyDown(keyCode);
    1.59                  return true;
    1.60 -            }
    1.61 -            else if (event.getAction() == KeyEvent.ACTION_UP) {
    1.62 -                //Log.v("SDL", "key up: " + keyCode);
    1.63 +            } else if (event.getAction() == KeyEvent.ACTION_UP) {
    1.64                  SDLActivity.onNativeKeyUp(keyCode);
    1.65                  return true;
    1.66              }