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:
Peter Hutterer 2014-02-10 07:44:59 +10:00
parent d4bd05184a
commit 0d759edc3f
3 changed files with 34 additions and 12 deletions

View file

@ -504,6 +504,7 @@ int
tp_tap_handle_state(struct tp_dispatch *tp, uint32_t time)
{
struct tp_touch *t;
int filter_motion = 0;
if (tp->queued & TOUCHPAD_EVENT_BUTTON_PRESS)
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);
}
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

View file

@ -369,20 +369,20 @@ tp_post_events(struct tp_dispatch *tp, uint32_t time)
return;
}
tp_tap_handle_state(tp, time);
if (t->history.count < 4)
if (tp_tap_handle_state(tp, time) != 0)
return;
tp_get_delta(t, &dx, &dy);
tp_filter_motion(tp, &dx, &dy, time);
if (t->history.count >= TOUCHPAD_MIN_SAMPLES) {
tp_get_delta(t, &dx, &dy);
tp_filter_motion(tp, &dx, &dy, time);
if (dx != 0 || dy != 0)
pointer_notify_motion(
&tp->device->base,
time,
li_fixed_from_double(dx),
li_fixed_from_double(dy));
if (dx != 0 || dy != 0)
pointer_notify_motion(
&tp->device->base,
time,
li_fixed_from_double(dx),
li_fixed_from_double(dy));
}
tp_post_button_events(tp, time);
}

View file

@ -30,6 +30,7 @@
#include "filter.h"
#define TOUCHPAD_HISTORY_LENGTH 4
#define TOUCHPAD_MIN_SAMPLES 4
enum touchpad_event {
TOUCHPAD_EVENT_NONE = 0,