From df879a6c4f2c8dbe814a70c36c762f16d1835fa8 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 13 Apr 2016 15:23:44 +1000 Subject: [PATCH] evdev: move the hysteresis code to a more generic location MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Hutterer Reviewed-by: Jonas Ã…dahl --- src/evdev-mt-touchpad.c | 25 ++++++------------------- src/evdev.h | 13 +++++++++++++ 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 */