summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-04-13 15:23:44 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-04-18 08:40:41 +1000
commitdf879a6c4f2c8dbe814a70c36c762f16d1835fa8 (patch)
treee62732a169a9f45132efae2d6d9209d2882e4b1c /src
parent49b8d4ec4484f19886fbb7579a84c91fa6ea4c50 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/evdev-mt-touchpad.c25
-rw-r--r--src/evdev.h13
2 files changed, 19 insertions, 19 deletions
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index cf5fffeb..40c51c68 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -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;
diff --git a/src/evdev.h b/src/evdev.h
index 0e08f6d1..4171c8a4 100644
--- a/src/evdev.h
+++ b/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 */