mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 11:03:01 +00:00
Only release controller numbers if they were reserved
This commit is contained in:
parent
d822980d5a
commit
2856617fb3
@ -107,7 +107,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener {
|
|||||||
for (Map.Entry<String, ControllerContext> device : contexts.entrySet()) {
|
for (Map.Entry<String, ControllerContext> device : contexts.entrySet()) {
|
||||||
if (device.getValue().id == deviceId) {
|
if (device.getValue().id == deviceId) {
|
||||||
LimeLog.info("Removed controller: "+device.getValue().name);
|
LimeLog.info("Removed controller: "+device.getValue().name);
|
||||||
releaseControllerNumber(device.getValue().controllerNumber);
|
releaseControllerNumber(device.getValue());
|
||||||
contexts.remove(device.getKey());
|
contexts.remove(device.getKey());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -121,9 +121,11 @@ public class ControllerHandler implements InputManager.InputDeviceListener {
|
|||||||
onInputDeviceAdded(deviceId);
|
onInputDeviceAdded(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void releaseControllerNumber(int controllerNumber) {
|
private void releaseControllerNumber(ControllerContext context) {
|
||||||
LimeLog.info("Controller number "+controllerNumber+" is now available");
|
if (context.reservedControllerNumber) {
|
||||||
currentControllers &= ~(1 << controllerNumber);
|
LimeLog.info("Controller number "+context.controllerNumber+" is now available");
|
||||||
|
currentControllers &= ~(1 << context.controllerNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called before sending input but after we've determined that this
|
// Called before sending input but after we've determined that this
|
||||||
@ -148,6 +150,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener {
|
|||||||
// Found an unused controller value
|
// Found an unused controller value
|
||||||
currentControllers |= (1 << i);
|
currentControllers |= (1 << i);
|
||||||
context.controllerNumber = i;
|
context.controllerNumber = i;
|
||||||
|
context.reservedControllerNumber = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -817,6 +820,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener {
|
|||||||
public boolean hasJoystickAxes;
|
public boolean hasJoystickAxes;
|
||||||
|
|
||||||
public boolean assignedControllerNumber;
|
public boolean assignedControllerNumber;
|
||||||
|
public boolean reservedControllerNumber;
|
||||||
public short controllerNumber;
|
public short controllerNumber;
|
||||||
|
|
||||||
public short inputMap = 0x0000;
|
public short inputMap = 0x0000;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user