mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 12:03:02 +00:00
Don't capture the back button on remotes
This commit is contained in:
parent
fcecba484f
commit
7557a3a4ae
@ -113,6 +113,7 @@ public class ControllerHandler {
|
|||||||
getMotionRangeForJoystickAxis(dev, mapping.leftStickYAxis) != null) {
|
getMotionRangeForJoystickAxis(dev, mapping.leftStickYAxis) != null) {
|
||||||
// This is a gamepad
|
// This is a gamepad
|
||||||
hasGameController = true;
|
hasGameController = true;
|
||||||
|
mapping.hasJoystickAxes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputDevice.MotionRange leftTriggerRange = getMotionRangeForJoystickAxis(dev, MotionEvent.AXIS_LTRIGGER);
|
InputDevice.MotionRange leftTriggerRange = getMotionRangeForJoystickAxis(dev, MotionEvent.AXIS_LTRIGGER);
|
||||||
@ -210,20 +211,30 @@ public class ControllerHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the Nexus Player (and probably other ATV devices), we should
|
if (devName != null) {
|
||||||
// use the back button as start since it doesn't have a start/menu button
|
// For the Nexus Player (and probably other ATV devices), we should
|
||||||
// on the controller
|
// use the back button as start since it doesn't have a start/menu button
|
||||||
if (devName != null && devName.contains("ASUS Gamepad")) {
|
// on the controller
|
||||||
// We can only do this check on KitKat or higher, but it doesn't matter since ATV
|
if (devName.contains("ASUS Gamepad")) {
|
||||||
// is Android 5.0 anyway
|
// We can only do this check on KitKat or higher, but it doesn't matter since ATV
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
|
// is Android 5.0 anyway
|
||||||
boolean[] hasStartKey = dev.hasKeys(KeyEvent.KEYCODE_BUTTON_START, KeyEvent.KEYCODE_MENU, 0);
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
|
||||||
if (!hasStartKey[0] && !hasStartKey[1]) {
|
boolean[] hasStartKey = dev.hasKeys(KeyEvent.KEYCODE_BUTTON_START, KeyEvent.KEYCODE_MENU, 0);
|
||||||
mapping.backIsStart = true;
|
if (!hasStartKey[0] && !hasStartKey[1]) {
|
||||||
|
mapping.backIsStart = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Classify this device as a remote by name
|
||||||
|
else if (devName.contains("Fire TV Remote")) {
|
||||||
|
// It's only a remote if it doesn't any sticks
|
||||||
|
if (!mapping.hasJoystickAxes) {
|
||||||
|
mapping.isRemote = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,12 +267,9 @@ public class ControllerHandler {
|
|||||||
// Return a valid keycode, 0 to consume, or -1 to not consume the event
|
// Return a valid keycode, 0 to consume, or -1 to not consume the event
|
||||||
// Device MAY BE NULL
|
// Device MAY BE NULL
|
||||||
private int handleRemapping(ControllerMapping mapping, KeyEvent event) {
|
private int handleRemapping(ControllerMapping mapping, KeyEvent event) {
|
||||||
InputDevice device = event.getDevice();
|
// For remotes, don't capture the back button
|
||||||
if (hasGameController && device != null) {
|
if (mapping.isRemote) {
|
||||||
String devName = device.getName();
|
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
||||||
if (devName != null && devName.contains("Fire TV Remote")) {
|
|
||||||
// There is already another game controller attached, so
|
|
||||||
// allow these remote events to go unhandled
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -750,5 +758,7 @@ public class ControllerHandler {
|
|||||||
public boolean isDualShock4;
|
public boolean isDualShock4;
|
||||||
public boolean isXboxController;
|
public boolean isXboxController;
|
||||||
public boolean backIsStart;
|
public boolean backIsStart;
|
||||||
|
public boolean isRemote;
|
||||||
|
public boolean hasJoystickAxes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user