summaryrefslogtreecommitdiff
path: root/src/click_wiggle_filter_interpreter.cc
diff options
context:
space:
mode:
authorSean O'Brien <seobrien@google.com>2018-02-26 16:29:22 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-03-01 16:13:48 -0800
commit2ae685fc64fcbd256c4933d5e84ed80cb3e8ab0e (patch)
treee2d08fa4d9a9e435a5c474961aebd218592ff0bd /src/click_wiggle_filter_interpreter.cc
parent47a5cca80ce8f553c643b31ffe92bcc318f53f64 (diff)
downloadlibchrome-gestures-2ae685fc64fcbd256c4933d5e84ed80cb3e8ab0e.tar.gz
Handle clock reset more gracefully
The gesture library implicitly assumes that timestamps will be monotonically increasing. If the clock goes backward, or has a value of 0.0, gestures will not be detected correctly. This CL allows timestamp values of 0.0, and allows clock resets when there are no fingers touching. With this CL, we still assume that timestamps will be non-negative, and that the clock will not reset with fingers touching. BUG=b:65041115 TEST=Tested manually on lux using MSC_TIMESTAMP as the timestamp value fo the gesture library. MSC_TIMESTAMP resets to 0.0 whenever the no finger is touching for more than a second. Also tested using the touchtests suite, changing the timestamps to act like MSC_TIMESTAMP. Change-Id: Ib2e83022a0e714f3d228515e90afbd8a59031978 Reviewed-on: https://chromium-review.googlesource.com/938848 Commit-Ready: Sean O'Brien <seobrien@chromium.org> Tested-by: Sean O'Brien <seobrien@chromium.org> Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Diffstat (limited to 'src/click_wiggle_filter_interpreter.cc')
-rw-r--r--src/click_wiggle_filter_interpreter.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/click_wiggle_filter_interpreter.cc b/src/click_wiggle_filter_interpreter.cc
index b8684f3..2a2e626 100644
--- a/src/click_wiggle_filter_interpreter.cc
+++ b/src/click_wiggle_filter_interpreter.cc
@@ -15,7 +15,7 @@ namespace gestures {
ClickWiggleFilterInterpreter::ClickWiggleFilterInterpreter(
PropRegistry* prop_reg, Interpreter* next, Tracer* tracer)
: FilterInterpreter(NULL, next, tracer, false),
- button_edge_occurred_(0.0),
+ button_edge_occurred_(-1.0),
prev_buttons_(0),
wiggle_max_dist_(prop_reg, "Wiggle Max Distance", 5.5),
wiggle_suppress_timeout_(prop_reg, "Wiggle Timeout", 0.075),
@@ -49,6 +49,10 @@ void ClickWiggleFilterInterpreter::UpdateClickWiggle(
// Removed outdated fingers from wiggle_recs_
RemoveMissingIdsFromMap(&wiggle_recs_, hwstate);
+ // Check if clock changed backwards
+ if (hwstate.timestamp < button_edge_occurred_)
+ button_edge_occurred_ = -1.0;
+
const bool button_down = hwstate.buttons_down & GESTURES_BUTTON_LEFT;
const bool prev_button_down = prev_buttons_ & GESTURES_BUTTON_LEFT;
const bool button_down_edge = button_down && !prev_button_down;
@@ -107,7 +111,7 @@ void ClickWiggleFilterInterpreter::UpdateClickWiggle(
}
void ClickWiggleFilterInterpreter::SetWarpFlags(HardwareState* hwstate) const {
- if (button_edge_occurred_ != 0.0 &&
+ if (button_edge_occurred_ != -1.0 &&
button_edge_occurred_ < hwstate->timestamp &&
button_edge_occurred_ + one_finger_click_wiggle_timeout_.val_ >
hwstate->timestamp && button_edge_with_one_finger_) {