Stop vibration on stream end

This commit is contained in:
Cameron Gutman 2019-02-16 18:05:08 -08:00
parent 92b71588d0
commit 2f7087d6d3
3 changed files with 15 additions and 0 deletions

View File

@ -1268,6 +1268,8 @@ public class Game extends Activity implements SurfaceHolder.Callback,
if (connecting || connected) { if (connecting || connected) {
connecting = connected = false; connecting = connected = false;
controllerHandler.stop();
// Stop may take a few hundred ms to do some network I/O to tell // Stop may take a few hundred ms to do some network I/O to tell
// the server we're going away and clean up. Let it run in a separate // the server we're going away and clean up. Let it run in a separate
// thread to keep things smooth for the UI. Inside moonlight-common, // thread to keep things smooth for the UI. Inside moonlight-common,

View File

@ -155,6 +155,16 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
onInputDeviceAdded(deviceId); onInputDeviceAdded(deviceId);
} }
public void stop() {
for (int i = 0; i < inputDeviceContexts.size(); i++) {
InputDeviceContext deviceContext = inputDeviceContexts.valueAt(i);
if (deviceContext.vibrator != null) {
deviceContext.vibrator.cancel();
}
}
}
private static boolean hasJoystickAxes(InputDevice device) { private static boolean hasJoystickAxes(InputDevice device) {
return (device.getSources() & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK && return (device.getSources() & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK &&
getMotionRangeForJoystickAxis(device, MotionEvent.AXIS_X) != null && getMotionRangeForJoystickAxis(device, MotionEvent.AXIS_X) != null &&

View File

@ -131,6 +131,9 @@ public abstract class AbstractXboxController extends AbstractController {
stopped = true; stopped = true;
// Cancel any rumble effects
rumble((short)0, (short)0);
// Stop the input thread // Stop the input thread
if (inputThread != null) { if (inputThread != null) {
inputThread.interrupt(); inputThread.interrupt();