Compare commits

..
4 Commits
4 changed files with 36 additions and 3 deletions

No files matched your search

+2 -2
View File
@@ -7,8 +7,8 @@ android {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 30 targetSdkVersion 30
versionName "9.8.1" versionName "9.8.2"
versionCode = 252 versionCode = 253
} }
flavorDimensions "root" flavorDimensions "root"
@@ -107,6 +107,8 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
defaultContext.rightStickDeadzoneRadius = (float) stickDeadzone; defaultContext.rightStickDeadzoneRadius = (float) stickDeadzone;
defaultContext.leftTriggerAxis = MotionEvent.AXIS_BRAKE; defaultContext.leftTriggerAxis = MotionEvent.AXIS_BRAKE;
defaultContext.rightTriggerAxis = MotionEvent.AXIS_GAS; defaultContext.rightTriggerAxis = MotionEvent.AXIS_GAS;
defaultContext.hatXAxis = MotionEvent.AXIS_HAT_X;
defaultContext.hatYAxis = MotionEvent.AXIS_HAT_Y;
defaultContext.controllerNumber = (short) 0; defaultContext.controllerNumber = (short) 0;
defaultContext.assignedControllerNumber = true; defaultContext.assignedControllerNumber = true;
defaultContext.external = false; defaultContext.external = false;
@@ -194,6 +196,28 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
return true; return true;
} }
// HACK for https://issuetracker.google.com/issues/163120692
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R) {
if (device.getId() == -1) {
// This "virtual" device could be input from any of the attached devices.
// Look to see if any gamepads are connected.
int[] ids = InputDevice.getDeviceIds();
for (int id : ids) {
InputDevice dev = InputDevice.getDevice(id);
if (dev == null) {
// This device was removed during enumeration
continue;
}
// If there are any gamepad devices connected, we'll
// report that this virtual device is a gamepad.
if (hasJoystickAxes(dev) || hasGamepadButtons(dev)) {
return true;
}
}
}
}
// Otherwise, we'll try anything that claims to be a non-alphabetic keyboard // Otherwise, we'll try anything that claims to be a non-alphabetic keyboard
return device.getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC; return device.getKeyboardType() != InputDevice.KEYBOARD_TYPE_ALPHABETIC;
} }
@@ -703,6 +727,13 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
return null; return null;
} }
// HACK for https://issuetracker.google.com/issues/163120692
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R) {
if (event.getDeviceId() == -1) {
return defaultContext;
}
}
// Return the existing context if it exists // Return the existing context if it exists
InputDeviceContext context = inputDeviceContexts.get(event.getDeviceId()); InputDeviceContext context = inputDeviceContexts.get(event.getDeviceId());
if (context != null) { if (context != null) {
+1 -1
View File
@@ -5,7 +5,7 @@ buildscript {
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.1' classpath 'com.android.tools.build:gradle:4.1.2'
} }
} }
@@ -0,0 +1,2 @@
- Add a workaround for the Android 11 gamepad bug when Accessibility features are enabled
- See https://issuetracker.google.com/issues/163120692 for more details