mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-08 06:38:02 +02:00
touchpad: store the time in the motion history
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
0cfe8b0808
commit
10569680d9
2 changed files with 15 additions and 10 deletions
|
|
@ -36,7 +36,7 @@
|
||||||
#define THUMB_MOVE_TIMEOUT ms2us(300)
|
#define THUMB_MOVE_TIMEOUT ms2us(300)
|
||||||
#define FAKE_FINGER_OVERFLOW (1 << 7)
|
#define FAKE_FINGER_OVERFLOW (1 << 7)
|
||||||
|
|
||||||
static inline struct device_coords *
|
static inline struct tp_history_point*
|
||||||
tp_motion_history_offset(struct tp_touch *t, int offset)
|
tp_motion_history_offset(struct tp_touch *t, int offset)
|
||||||
{
|
{
|
||||||
int offset_index =
|
int offset_index =
|
||||||
|
|
@ -90,7 +90,8 @@ tp_motion_history_push(struct tp_touch *t)
|
||||||
if (t->history.count < TOUCHPAD_HISTORY_LENGTH)
|
if (t->history.count < TOUCHPAD_HISTORY_LENGTH)
|
||||||
t->history.count++;
|
t->history.count++;
|
||||||
|
|
||||||
t->history.samples[motion_index] = t->point;
|
t->history.samples[motion_index].point = t->point;
|
||||||
|
t->history.samples[motion_index].time = t->time;
|
||||||
t->history.index = motion_index;
|
t->history.index = motion_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -293,10 +294,10 @@ tp_get_delta(struct tp_touch *t)
|
||||||
if (t->history.count <= 1)
|
if (t->history.count <= 1)
|
||||||
return zero;
|
return zero;
|
||||||
|
|
||||||
delta.x = tp_motion_history_offset(t, 0)->x -
|
delta.x = tp_motion_history_offset(t, 0)->point.x -
|
||||||
tp_motion_history_offset(t, 1)->x;
|
tp_motion_history_offset(t, 1)->point.x;
|
||||||
delta.y = tp_motion_history_offset(t, 0)->y -
|
delta.y = tp_motion_history_offset(t, 0)->point.y -
|
||||||
tp_motion_history_offset(t, 1)->y;
|
tp_motion_history_offset(t, 1)->point.y;
|
||||||
|
|
||||||
return tp_normalize_delta(t->tp, delta);
|
return tp_normalize_delta(t->tp, delta);
|
||||||
}
|
}
|
||||||
|
|
@ -1252,9 +1253,10 @@ tp_need_motion_history_reset(struct tp_dispatch *tp)
|
||||||
static bool
|
static bool
|
||||||
tp_detect_jumps(const struct tp_dispatch *tp, struct tp_touch *t)
|
tp_detect_jumps(const struct tp_dispatch *tp, struct tp_touch *t)
|
||||||
{
|
{
|
||||||
struct device_coords *last, delta;
|
struct device_coords delta;
|
||||||
struct phys_coords mm;
|
struct phys_coords mm;
|
||||||
const int JUMP_THRESHOLD_MM = 20;
|
const int JUMP_THRESHOLD_MM = 20;
|
||||||
|
struct tp_history_point *last;
|
||||||
|
|
||||||
/* We haven't seen pointer jumps on Wacom tablets yet, so exclude
|
/* We haven't seen pointer jumps on Wacom tablets yet, so exclude
|
||||||
* those.
|
* those.
|
||||||
|
|
@ -1268,8 +1270,8 @@ tp_detect_jumps(const struct tp_dispatch *tp, struct tp_touch *t)
|
||||||
/* called before tp_motion_history_push, so offset 0 is the most
|
/* called before tp_motion_history_push, so offset 0 is the most
|
||||||
* recent coordinate */
|
* recent coordinate */
|
||||||
last = tp_motion_history_offset(t, 0);
|
last = tp_motion_history_offset(t, 0);
|
||||||
delta.x = abs(t->point.x - last->x);
|
delta.x = abs(t->point.x - last->point.x);
|
||||||
delta.y = abs(t->point.y - last->y);
|
delta.y = abs(t->point.y - last->point.y);
|
||||||
mm = evdev_device_unit_delta_to_mm(tp->device, &delta);
|
mm = evdev_device_unit_delta_to_mm(tp->device, &delta);
|
||||||
|
|
||||||
return hypot(mm.x, mm.y) > JUMP_THRESHOLD_MM;
|
return hypot(mm.x, mm.y) > JUMP_THRESHOLD_MM;
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,10 @@ struct tp_touch {
|
||||||
} quirks;
|
} quirks;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct device_coords samples[TOUCHPAD_HISTORY_LENGTH];
|
struct tp_history_point {
|
||||||
|
uint64_t time;
|
||||||
|
struct device_coords point;
|
||||||
|
} samples[TOUCHPAD_HISTORY_LENGTH];
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
} history;
|
} history;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue