mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 05:58:01 +02:00
touchpad: Filter motion in a certain number of tap states
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
d4bd05184a
commit
0d759edc3f
3 changed files with 34 additions and 12 deletions
|
|
@ -504,6 +504,7 @@ int
|
||||||
tp_tap_handle_state(struct tp_dispatch *tp, uint32_t time)
|
tp_tap_handle_state(struct tp_dispatch *tp, uint32_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
int filter_motion = 0;
|
||||||
|
|
||||||
if (tp->queued & TOUCHPAD_EVENT_BUTTON_PRESS)
|
if (tp->queued & TOUCHPAD_EVENT_BUTTON_PRESS)
|
||||||
tp_tap_handle_event(tp, TAP_EVENT_BUTTON, time);
|
tp_tap_handle_event(tp, TAP_EVENT_BUTTON, time);
|
||||||
|
|
@ -521,7 +522,27 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint32_t time)
|
||||||
tp_tap_handle_event(tp, TAP_EVENT_MOTION, time);
|
tp_tap_handle_event(tp, TAP_EVENT_MOTION, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
/**
|
||||||
|
* In any state where motion exceeding the move threshold would
|
||||||
|
* move to the next state, filter that motion until we actually
|
||||||
|
* exceed it. This prevents small motion events while we're waiting
|
||||||
|
* on a decision if a tap is a tap.
|
||||||
|
*/
|
||||||
|
switch (tp->tap.state) {
|
||||||
|
case TAP_STATE_TOUCH:
|
||||||
|
case TAP_STATE_TAPPED:
|
||||||
|
case TAP_STATE_DRAGGING_OR_DOUBLETAP:
|
||||||
|
case TAP_STATE_TOUCH_2:
|
||||||
|
case TAP_STATE_TOUCH_3:
|
||||||
|
filter_motion = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return filter_motion;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -369,20 +369,20 @@ tp_post_events(struct tp_dispatch *tp, uint32_t time)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tp_tap_handle_state(tp, time);
|
if (tp_tap_handle_state(tp, time) != 0)
|
||||||
|
|
||||||
if (t->history.count < 4)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tp_get_delta(t, &dx, &dy);
|
if (t->history.count >= TOUCHPAD_MIN_SAMPLES) {
|
||||||
tp_filter_motion(tp, &dx, &dy, time);
|
tp_get_delta(t, &dx, &dy);
|
||||||
|
tp_filter_motion(tp, &dx, &dy, time);
|
||||||
|
|
||||||
if (dx != 0 || dy != 0)
|
if (dx != 0 || dy != 0)
|
||||||
pointer_notify_motion(
|
pointer_notify_motion(
|
||||||
&tp->device->base,
|
&tp->device->base,
|
||||||
time,
|
time,
|
||||||
li_fixed_from_double(dx),
|
li_fixed_from_double(dx),
|
||||||
li_fixed_from_double(dy));
|
li_fixed_from_double(dy));
|
||||||
|
}
|
||||||
|
|
||||||
tp_post_button_events(tp, time);
|
tp_post_button_events(tp, time);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
|
|
||||||
#define TOUCHPAD_HISTORY_LENGTH 4
|
#define TOUCHPAD_HISTORY_LENGTH 4
|
||||||
|
#define TOUCHPAD_MIN_SAMPLES 4
|
||||||
|
|
||||||
enum touchpad_event {
|
enum touchpad_event {
|
||||||
TOUCHPAD_EVENT_NONE = 0,
|
TOUCHPAD_EVENT_NONE = 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue