From a23414dd1fc0558a1b8cfd5c51b6befb3cd2e932 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Tue, 12 Jun 2018 18:53:51 +0300 Subject: [PATCH] touchpad: replace last_point with history.samples Signed-off-by: Konstantin Kharlamov --- src/evdev-mt-touchpad.c | 15 +++++---------- src/evdev-mt-touchpad.h | 1 - 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 1c710a5d..b73788a9 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -155,12 +155,13 @@ tp_detect_wobbling(struct tp_dispatch *tp, { int dx, dy; uint64_t dtime; + const struct device_coords* prev_point; if (tp->nfingers_down != 1 || tp->nfingers_down != tp->old_nfingers_down) return; - if (tp->hysteresis.enabled) + if (tp->hysteresis.enabled || t->history.count == 0) return; if (!(tp->queued & TOUCHPAD_EVENT_MOTION)) { @@ -168,18 +169,12 @@ tp_detect_wobbling(struct tp_dispatch *tp, return; } - if (t->last_point.x == 0) { /* first invocation */ - dx = 0; - dy = 0; - } else { - dx = t->last_point.x - t->point.x; - dy = t->last_point.y - t->point.y; - } - + prev_point = &tp_motion_history_offset(t, 0)->point; + dx = prev_point->x - t->point.x; + dy = prev_point->y - t->point.y; dtime = time - tp->hysteresis.last_motion_time; tp->hysteresis.last_motion_time = time; - t->last_point = t->point; if ((dx == 0 && dy != 0) || dtime > ms2us(40)) { t->hysteresis.x_motion_history = 0; diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 90c20325..7a28c457 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -150,7 +150,6 @@ struct tp_touch { bool has_ended; /* TRACKING_ID == -1 */ bool dirty; struct device_coords point; - struct device_coords last_point; uint64_t time; int pressure; bool is_tool_palm; /* MT_TOOL_PALM */