mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-19 23:10:11 +00:00
Also destroy the mouse emulation timer on device disconnect
This commit is contained in:
@@ -147,6 +147,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
if (context != null) {
|
if (context != null) {
|
||||||
LimeLog.info("Removed controller: "+context.name+" ("+deviceId+")");
|
LimeLog.info("Removed controller: "+context.name+" ("+deviceId+")");
|
||||||
releaseControllerNumber(context);
|
releaseControllerNumber(context);
|
||||||
|
context.destroy();
|
||||||
inputDeviceContexts.remove(deviceId);
|
inputDeviceContexts.remove(deviceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,24 +162,12 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
public void stop() {
|
public void stop() {
|
||||||
for (int i = 0; i < inputDeviceContexts.size(); i++) {
|
for (int i = 0; i < inputDeviceContexts.size(); i++) {
|
||||||
InputDeviceContext deviceContext = inputDeviceContexts.valueAt(i);
|
InputDeviceContext deviceContext = inputDeviceContexts.valueAt(i);
|
||||||
|
deviceContext.destroy();
|
||||||
if (deviceContext.mouseEmulationTimer != null) {
|
|
||||||
deviceContext.mouseEmulationTimer.cancel();
|
|
||||||
deviceContext.mouseEmulationTimer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (deviceContext.vibrator != null) {
|
|
||||||
deviceContext.vibrator.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < usbDeviceContexts.size(); i++) {
|
for (int i = 0; i < usbDeviceContexts.size(); i++) {
|
||||||
UsbDeviceContext deviceContext = usbDeviceContexts.valueAt(i);
|
UsbDeviceContext deviceContext = usbDeviceContexts.valueAt(i);
|
||||||
|
deviceContext.destroy();
|
||||||
if (deviceContext.mouseEmulationTimer != null) {
|
|
||||||
deviceContext.mouseEmulationTimer.cancel();
|
|
||||||
deviceContext.mouseEmulationTimer = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceVibrator.cancel();
|
deviceVibrator.cancel();
|
||||||
@@ -1555,6 +1544,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
if (context != null) {
|
if (context != null) {
|
||||||
LimeLog.info("Removed controller: "+controller.getControllerId());
|
LimeLog.info("Removed controller: "+controller.getControllerId());
|
||||||
releaseControllerNumber(context);
|
releaseControllerNumber(context);
|
||||||
|
context.destroy();
|
||||||
usbDeviceContexts.remove(controller.getControllerId());
|
usbDeviceContexts.remove(controller.getControllerId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1587,6 +1577,13 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
public boolean mouseEmulationActive;
|
public boolean mouseEmulationActive;
|
||||||
public Timer mouseEmulationTimer;
|
public Timer mouseEmulationTimer;
|
||||||
public short mouseEmulationLastInputMap;
|
public short mouseEmulationLastInputMap;
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
if (mouseEmulationTimer != null) {
|
||||||
|
mouseEmulationTimer.cancel();
|
||||||
|
mouseEmulationTimer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class InputDeviceContext extends GenericControllerContext {
|
class InputDeviceContext extends GenericControllerContext {
|
||||||
@@ -1628,9 +1625,25 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
|||||||
public long lastRbUpTime = 0;
|
public long lastRbUpTime = 0;
|
||||||
|
|
||||||
public long startDownTime = 0;
|
public long startDownTime = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
super.destroy();
|
||||||
|
|
||||||
|
if (vibrator != null) {
|
||||||
|
vibrator.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UsbDeviceContext extends GenericControllerContext {
|
class UsbDeviceContext extends GenericControllerContext {
|
||||||
public AbstractController device;
|
public AbstractController device;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
super.destroy();
|
||||||
|
|
||||||
|
// Nothing for now
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user