mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-31 19:20:09 +01:00
evdev: move the hysteresis code to a more generic location
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
parent
49b8d4ec44
commit
df879a6c4f
2 changed files with 19 additions and 19 deletions
|
|
@ -36,19 +36,6 @@
|
|||
#define THUMB_MOVE_TIMEOUT ms2us(300)
|
||||
#define FAKE_FINGER_OVERFLOW (1 << 7)
|
||||
|
||||
static inline int
|
||||
tp_hysteresis(int in, int center, int margin)
|
||||
{
|
||||
int diff = in - center;
|
||||
if (abs(diff) <= margin)
|
||||
return center;
|
||||
|
||||
if (diff > margin)
|
||||
return center + diff - margin;
|
||||
else
|
||||
return center + diff + margin;
|
||||
}
|
||||
|
||||
static inline struct device_coords *
|
||||
tp_motion_history_offset(struct tp_touch *t, int offset)
|
||||
{
|
||||
|
|
@ -105,12 +92,12 @@ tp_motion_hysteresis(struct tp_dispatch *tp,
|
|||
if (t->history.count == 0) {
|
||||
t->hysteresis_center = t->point;
|
||||
} else {
|
||||
x = tp_hysteresis(x,
|
||||
t->hysteresis_center.x,
|
||||
tp->hysteresis_margin.x);
|
||||
y = tp_hysteresis(y,
|
||||
t->hysteresis_center.y,
|
||||
tp->hysteresis_margin.y);
|
||||
x = evdev_hysteresis(x,
|
||||
t->hysteresis_center.x,
|
||||
tp->hysteresis_margin.x);
|
||||
y = evdev_hysteresis(y,
|
||||
t->hysteresis_center.y,
|
||||
tp->hysteresis_margin.y);
|
||||
t->hysteresis_center.x = x;
|
||||
t->hysteresis_center.y = y;
|
||||
t->point.x = x;
|
||||
|
|
|
|||
13
src/evdev.h
13
src/evdev.h
|
|
@ -469,4 +469,17 @@ evdev_to_left_handed(struct evdev_device *device,
|
|||
return button;
|
||||
}
|
||||
|
||||
static inline int
|
||||
evdev_hysteresis(int in, int center, int margin)
|
||||
{
|
||||
int diff = in - center;
|
||||
if (abs(diff) <= margin)
|
||||
return center;
|
||||
|
||||
if (diff > margin)
|
||||
return center + diff - margin;
|
||||
else
|
||||
return center + diff + margin;
|
||||
}
|
||||
|
||||
#endif /* EVDEV_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue