From 6d45ad7fe81694485294e21d190dff9b1f1a8e07 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 20 Jan 2016 00:28:11 -0500 Subject: [PATCH] Improve precision of joystick inputs by lifting the deadzone after 150 ms. This way it prevents false inputs when activation the stick buttons but allows for precise movements after confirming that the touch is intended. --- .../binding/input/virtual_controller/AnalogStick.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/limelight/binding/input/virtual_controller/AnalogStick.java b/app/src/main/java/com/limelight/binding/input/virtual_controller/AnalogStick.java index f7130ad0..bfca58d3 100644 --- a/app/src/main/java/com/limelight/binding/input/virtual_controller/AnalogStick.java +++ b/app/src/main/java/com/limelight/binding/input/virtual_controller/AnalogStick.java @@ -35,6 +35,11 @@ public class AnalogStick extends VirtualControllerElement { */ public final static long timeoutDoubleClick = 250; + /** + * touch down time until the deadzone is lifted to allow precise movements with the analog sticks + */ + public final static long timeoutDeadzone = 150; + /** * Listener interface to update registered observers. */ @@ -262,7 +267,11 @@ public class AnalogStick extends VirtualControllerElement { // Stay active even if we're back in the deadzone because we know the user is actively // giving analog stick input and we don't want to snap back into the deadzone. - stick_state = (stick_state == STICK_STATE.MOVED_ACTIVE || movement_radius > radius_dead_zone) ? + // We also release the deadzone if the user keeps the stick pressed for a bit to allow + // them to make precise movements. + stick_state = (stick_state == STICK_STATE.MOVED_ACTIVE || + System.currentTimeMillis() - timeLastClick > timeoutDeadzone || + movement_radius > radius_dead_zone) ? STICK_STATE.MOVED_ACTIVE : STICK_STATE.MOVED_IN_DEAD_ZONE; // trigger move event if state active