From ebfe843299cd53a71ac4b04b2869645e6211ce8d Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 26 Oct 2023 00:05:24 -0500 Subject: [PATCH] Don't process incoming input device requests from the host after we've stopped --- .../binding/input/ControllerHandler.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/src/main/java/com/limelight/binding/input/ControllerHandler.java b/app/src/main/java/com/limelight/binding/input/ControllerHandler.java index 67b7319d..c75a8b52 100644 --- a/app/src/main/java/com/limelight/binding/input/ControllerHandler.java +++ b/app/src/main/java/com/limelight/binding/input/ControllerHandler.java @@ -293,6 +293,10 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD } public void enableSensors() { + if (stopped) { + return; + } + for (int i = 0; i < inputDeviceContexts.size(); i++) { InputDeviceContext deviceContext = inputDeviceContexts.valueAt(i); deviceContext.enableSensors(); @@ -2030,6 +2034,10 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD boolean foundMatchingDevice = false; boolean vibrated = false; + if (stopped) { + return; + } + for (int i = 0; i < inputDeviceContexts.size(); i++) { InputDeviceContext deviceContext = inputDeviceContexts.valueAt(i); @@ -2090,6 +2098,10 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD } public void handleRumbleTriggers(short controllerNumber, short leftTrigger, short rightTrigger) { + if (stopped) { + return; + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { for (int i = 0; i < inputDeviceContexts.size(); i++) { InputDeviceContext deviceContext = inputDeviceContexts.valueAt(i); @@ -2201,6 +2213,10 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD } public void handleSetMotionEventState(final short controllerNumber, final byte motionType, short reportRateHz) { + if (stopped) { + return; + } + // Report rate is restricted to <= 200 Hz without the HIGH_SAMPLING_RATE_SENSORS permission reportRateHz = (short) Math.min(200, reportRateHz); @@ -2262,6 +2278,10 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD } public void handleSetControllerLED(short controllerNumber, byte r, byte g, byte b) { + if (stopped) { + return; + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { for (int i = 0; i < inputDeviceContexts.size(); i++) { InputDeviceContext deviceContext = inputDeviceContexts.valueAt(i);