Commit 50daa7b3 authored by Peter Hutterer's avatar Peter Hutterer

touchpad: automatically disable the hysteresis where not required

Touchpads that require the hysteresis do not have filtering in the firmware
and holding a finger still causes continuous cursor movements. This implies
that we get a continuous stream of events with motion data.

If the finger is on the touchpad but we don't see any motion, the finger is
stationary and the touchpad firmware does filtering. In that case, we don't
need to add a hysteresis on top.

https://bugs.freedesktop.org/show_bug.cgi?id=98839Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 8b923d37
......@@ -131,6 +131,21 @@ 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 (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)
......@@ -276,6 +291,7 @@ tp_begin_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
t->thumb.first_touch_time = time;
t->tap.is_thumb = false;
assert(tp->nfingers_down >= 1);
tp->hysteresis.last_motion_time = time;
}
/**
......@@ -1529,6 +1545,9 @@ 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);
......
......@@ -272,6 +272,8 @@ struct tp_dispatch {
struct {
bool enabled;
struct device_coords margin;
unsigned int other_event_count;
uint64_t last_motion_time;
} hysteresis;
struct {
......
......@@ -3223,6 +3223,12 @@ litest_timeout_tablet_proxout(void)
msleep(70);
}
void
litest_timeout_hysteresis(void)
{
msleep(90);
}
void
litest_push_event_frame(struct litest_device *dev)
{
......
......@@ -766,6 +766,9 @@ litest_timeout_trackpoint(void);
void
litest_timeout_tablet_proxout(void);
void
litest_timeout_hysteresis(void);
void
litest_push_event_frame(struct litest_device *dev);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment