diff --git a/0001-touchpad-move-the-hysteresis-into-its-own-substruct.patch b/0001-touchpad-move-the-hysteresis-into-its-own-substruct.patch new file mode 100644 index 0000000..53099f9 --- /dev/null +++ b/0001-touchpad-move-the-hysteresis-into-its-own-substruct.patch @@ -0,0 +1,60 @@ +From 298b28d7f1eec7ebc7cd239915966ca0c322cf54 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Fri, 23 Feb 2018 11:21:04 +1000 +Subject: [PATCH libinput 1/3] touchpad: move the hysteresis into its own + substruct + +Prep work for the wobbling detection patch + +Signed-off-by: Peter Hutterer +Reviewed-by: Konstantin Kharlamov +(cherry picked from commit e43bd4ae3a75f72b45c6bab6168bd859ab4a01b3) +--- + src/evdev-mt-touchpad.c | 10 +++++----- + src/evdev-mt-touchpad.h | 4 +++- + 2 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c +index 7bce8114..a024be28 100644 +--- a/src/evdev-mt-touchpad.c ++++ b/src/evdev-mt-touchpad.c +@@ -162,16 +162,16 @@ tp_motion_hysteresis(struct tp_dispatch *tp, + return; + + if (t->history.count == 0) { +- t->hysteresis_center = t->point; ++ t->hysteresis.center = t->point; + } else { + x = evdev_hysteresis(x, +- t->hysteresis_center.x, ++ t->hysteresis.center.x, + tp->hysteresis.margin.x); + y = evdev_hysteresis(y, +- t->hysteresis_center.y, ++ t->hysteresis.center.y, + tp->hysteresis.margin.y); +- t->hysteresis_center.x = x; +- t->hysteresis_center.y = y; ++ t->hysteresis.center.x = x; ++ t->hysteresis.center.y = y; + t->point.x = x; + t->point.y = y; + } +diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h +index 442f34a3..4c2f156b 100644 +--- a/src/evdev-mt-touchpad.h ++++ b/src/evdev-mt-touchpad.h +@@ -173,7 +173,9 @@ struct tp_touch { + unsigned int count; + } history; + +- struct device_coords hysteresis_center; ++ struct { ++ struct device_coords center; ++ } hysteresis; + + /* A pinned touchpoint is the one that pressed the physical button + * on a clickpad. After the release, it won't move until the center +-- +2.14.3 + diff --git a/0002-touchpad-remove-the-code-for-disabling-hysteresis.patch b/0002-touchpad-remove-the-code-for-disabling-hysteresis.patch new file mode 100644 index 0000000..0bdee04 --- /dev/null +++ b/0002-touchpad-remove-the-code-for-disabling-hysteresis.patch @@ -0,0 +1,63 @@ +From 5f4d975861ace89b47b6d7e265d38103045c1cc6 Mon Sep 17 00:00:00 2001 +From: Konstantin Kharlamov +Date: Sun, 18 Feb 2018 13:09:23 +0300 +Subject: [PATCH libinput 2/3] touchpad: remove the code for disabling + hysteresis + +Signed-off-by: Konstantin Kharlamov +Signed-off-by: Peter Hutterer +Reviewed-by: Konstantin Kharlamov +(cherry picked from commit e8dffbd73a1b3c17716f972f210e420de94028c2) +--- + src/evdev-mt-touchpad.c | 21 +-------------------- + 1 file changed, 1 insertion(+), 20 deletions(-) + +diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c +index a024be28..9f36fcbe 100644 +--- a/src/evdev-mt-touchpad.c ++++ b/src/evdev-mt-touchpad.c +@@ -135,22 +135,6 @@ tp_motion_history_push(struct tp_touch *t) + t->history.index = motion_index; + } + +-static inline void +-tp_maybe_disable_hysteresis(struct tp_dispatch *tp, uint64_t time) +-{ +- /* If the finger is down for 80ms without seeing motion events, +- the firmware filters and we don't need a software hysteresis */ +- if (tp->nfingers_down >= 1 && +- time - tp->hysteresis.last_motion_time > ms2us(80)) { +- tp->hysteresis.enabled = false; +- evdev_log_debug(tp->device, "hysteresis disabled\n"); +- return; +- } +- +- if (tp->queued & TOUCHPAD_EVENT_MOTION) +- tp->hysteresis.last_motion_time = time; +-} +- + static inline void + tp_motion_hysteresis(struct tp_dispatch *tp, + struct tp_touch *t) +@@ -1550,9 +1534,6 @@ static void + tp_handle_state(struct tp_dispatch *tp, + uint64_t time) + { +- if (tp->hysteresis.enabled) +- tp_maybe_disable_hysteresis(tp, time); +- + tp_process_state(tp, time); + tp_post_events(tp, time); + tp_post_process_state(tp, time); +@@ -2942,7 +2923,7 @@ tp_init_hysteresis(struct tp_dispatch *tp) + res_y = tp->device->abs.absinfo_y->resolution; + tp->hysteresis.margin.x = res_x/2; + tp->hysteresis.margin.y = res_y/2; +- tp->hysteresis.enabled = true; ++ tp->hysteresis.enabled = false; + } + + static void +-- +2.14.3 + diff --git a/0003-touchpad-add-wobbling-detection.patch b/0003-touchpad-add-wobbling-detection.patch new file mode 100644 index 0000000..27e20e9 --- /dev/null +++ b/0003-touchpad-add-wobbling-detection.patch @@ -0,0 +1,126 @@ +From 3efd7c82aa4758a012e0bac7a148f270060f0e54 Mon Sep 17 00:00:00 2001 +From: Konstantin Kharlamov +Date: Wed, 21 Feb 2018 20:16:41 +0300 +Subject: [PATCH libinput 3/3] touchpad: add wobbling detection + +The details are explained in comment in the code. That aside, I shall +mention the check is so light, that it shouldn't influence CPU +performance even a bit, and can blindly be kept always enabled. + +Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104828 + +Signed-off-by: Konstantin Kharlamov +Signed-off-by: Peter Hutterer +Reviewed-by: Konstantin Kharlamov +(cherry picked from commit 400aadd53ac00ca773533d14e231ba192f4141a9) +--- + src/evdev-mt-touchpad.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++- + src/evdev-mt-touchpad.h | 2 ++ + 2 files changed, 59 insertions(+), 1 deletion(-) + +diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c +index 9f36fcbe..d9ed8ab3 100644 +--- a/src/evdev-mt-touchpad.c ++++ b/src/evdev-mt-touchpad.c +@@ -135,6 +135,61 @@ tp_motion_history_push(struct tp_touch *t) + t->history.index = motion_index; + } + ++/* Idea: if we got a tuple of *very* quick moves like {Left, Right, ++ * Left}, or {Right, Left, Right}, it means touchpad jitters since no ++ * human can move like that within thresholds. ++ * ++ * We encode left moves as zeroes, and right as ones. We also drop ++ * the array to all zeroes when contraints are not satisfied. Then we ++ * search for the pattern {1,0,1}. It can't match {Left, Right, Left}, ++ * but it does match {Left, Right, Left, Right}, so it's okay. ++ * ++ * This only looks at x changes, y changes are ignored. ++ */ ++static inline void ++tp_detect_wobbling(struct tp_dispatch *tp, ++ struct tp_touch *t, ++ uint64_t time) ++{ ++ int dx, dy; ++ uint64_t dtime; ++ ++ if (!(tp->queued & TOUCHPAD_EVENT_MOTION) || tp->hysteresis.enabled) ++ 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; ++ } ++ ++ dtime = time - tp->hysteresis.last_motion_time; ++ ++ tp->hysteresis.last_motion_time = time; ++ t->last_point = t->point; ++ ++ if (dx == 0 && dy != 0) /* ignore y-only changes */ ++ return; ++ ++ if (dtime > ms2us(40)) { ++ t->hysteresis.x_motion_history = 0; ++ return; ++ } ++ ++ t->hysteresis.x_motion_history <<= 1; ++ if (dx > 0) { /* right move */ ++ static const char r_l_r = 0x5; /* {Right, Left, Right} */ ++ ++ t->hysteresis.x_motion_history |= 0x1; ++ if (t->hysteresis.x_motion_history == r_l_r) { ++ tp->hysteresis.enabled = true; ++ evdev_log_debug(tp->device, "hysteresis enabled\n"); ++ } ++ } ++} ++ + static inline void + tp_motion_hysteresis(struct tp_dispatch *tp, + struct tp_touch *t) +@@ -264,6 +319,7 @@ tp_new_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) + t->time = time; + t->speed.last_speed = 0; + t->speed.exceeded_count = 0; ++ t->hysteresis.x_motion_history = 0; + tp->queued |= TOUCHPAD_EVENT_MOTION; + } + +@@ -1410,7 +1466,7 @@ tp_process_state(struct tp_dispatch *tp, uint64_t time) + + tp_thumb_detect(tp, t, time); + tp_palm_detect(tp, t, time); +- ++ tp_detect_wobbling(tp, t, time); + tp_motion_hysteresis(tp, t); + tp_motion_history_push(t); + +diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h +index 4c2f156b..467aca57 100644 +--- a/src/evdev-mt-touchpad.h ++++ b/src/evdev-mt-touchpad.h +@@ -147,6 +147,7 @@ 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 */ +@@ -175,6 +176,7 @@ struct tp_touch { + + struct { + struct device_coords center; ++ uint8_t x_motion_history; + } hysteresis; + + /* A pinned touchpoint is the one that pressed the physical button +-- +2.14.3 + diff --git a/libinput.spec b/libinput.spec index a7e6445..cdd120d 100644 --- a/libinput.spec +++ b/libinput.spec @@ -5,7 +5,7 @@ Name: libinput Version: 1.10.1 -Release: 1%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist} +Release: 2%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist} Summary: Input device library License: MIT @@ -18,6 +18,10 @@ Source2: commitid Source0: http://www.freedesktop.org/software/libinput/libinput-%{version}.tar.xz %endif +Patch01: 0001-touchpad-move-the-hysteresis-into-its-own-substruct.patch +Patch02: 0002-touchpad-remove-the-code-for-disabling-hysteresis.patch +Patch03: 0003-touchpad-add-wobbling-detection.patch + BuildRequires: git-core BuildRequires: gcc BuildRequires: meson @@ -109,6 +113,10 @@ The %{name}-utils package contains tools to debug hardware and analyze %{_mandir}/man1/libinput-measure-trackpoint-range.1* %changelog +* Fri Mar 02 2018 Peter Hutterer 1.10.1-2 +- Fix touchpad jitter by changing from "disable if no jitter" to "enable if + jitter" (#1548550) + * Wed Feb 28 2018 Peter Hutterer 1.10.1-1 - libinput 1.10.1