summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseExposito <jose.exposito89@gmail.com>2021-03-29 17:31:46 +0200
committerPeter Hutterer <peter.hutterer@who-t.net>2021-04-13 14:01:11 +1000
commit73ef2d70c2f60f8dabdc26bf04a959c1f9440669 (patch)
tree8b5071bdc3aecadfe5d2364c6a584a5015acc1b8
parent020f13e10d06193d2d3a1fa09c8e9ca99302527a (diff)
downloadlibinput-73ef2d70c2f60f8dabdc26bf04a959c1f9440669.tar.gz
gestures: move up some functions to use them later
Move tp_gesture_same_directions, tp_gesture_mm_moved and tp_gesture_init_pinch to be able to use them in future commits. Signed-off-by: José Expósito <jose.exposito89@gmail.com>
-rw-r--r--src/evdev-mt-touchpad-gestures.c73
1 files changed, 37 insertions, 36 deletions
diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
index 57df44a2..0394f124 100644
--- a/src/evdev-mt-touchpad-gestures.c
+++ b/src/evdev-mt-touchpad-gestures.c
@@ -203,6 +203,33 @@ tp_gesture_get_active_touches(const struct tp_dispatch *tp,
return n;
}
+static inline int
+tp_gesture_same_directions(int dir1, int dir2)
+{
+ /*
+ * In some cases (semi-mt touchpads) we may seen one finger move
+ * e.g. N/NE and the other W/NW so we not only check for overlapping
+ * directions, but also for neighboring bits being set.
+ * The ((dira & 0x80) && (dirb & 0x01)) checks are to check for bit 0
+ * and 7 being set as they also represent neighboring directions.
+ */
+ return ((dir1 | (dir1 >> 1)) & dir2) ||
+ ((dir2 | (dir2 >> 1)) & dir1) ||
+ ((dir1 & 0x80) && (dir2 & 0x01)) ||
+ ((dir2 & 0x80) && (dir1 & 0x01));
+}
+
+static struct phys_coords
+tp_gesture_mm_moved(struct tp_dispatch *tp, struct tp_touch *t)
+{
+ struct device_coords delta;
+
+ delta.x = abs(t->point.x - t->gesture.initial.x);
+ delta.y = abs(t->point.y - t->gesture.initial.y);
+
+ return evdev_device_unit_delta_to_mm(tp->device, &delta);
+}
+
static uint32_t
tp_gesture_get_direction(struct tp_dispatch *tp, struct tp_touch *touch)
{
@@ -234,6 +261,16 @@ tp_gesture_get_pinch_info(struct tp_dispatch *tp,
*center = device_average(first->point, second->point);
}
+static inline void
+tp_gesture_init_pinch(struct tp_dispatch *tp)
+{
+ tp_gesture_get_pinch_info(tp,
+ &tp->gesture.initial_distance,
+ &tp->gesture.angle,
+ &tp->gesture.center);
+ tp->gesture.prev_scale = 1.0;
+}
+
static void
tp_gesture_set_scroll_buildup(struct tp_dispatch *tp)
{
@@ -439,42 +476,6 @@ tp_gesture_handle_state_none(struct tp_dispatch *tp, uint64_t time)
return GESTURE_STATE_UNKNOWN;
}
-static inline int
-tp_gesture_same_directions(int dir1, int dir2)
-{
- /*
- * In some cases (semi-mt touchpads) we may seen one finger move
- * e.g. N/NE and the other W/NW so we not only check for overlapping
- * directions, but also for neighboring bits being set.
- * The ((dira & 0x80) && (dirb & 0x01)) checks are to check for bit 0
- * and 7 being set as they also represent neighboring directions.
- */
- return ((dir1 | (dir1 >> 1)) & dir2) ||
- ((dir2 | (dir2 >> 1)) & dir1) ||
- ((dir1 & 0x80) && (dir2 & 0x01)) ||
- ((dir2 & 0x80) && (dir1 & 0x01));
-}
-
-static inline void
-tp_gesture_init_pinch(struct tp_dispatch *tp)
-{
- tp_gesture_get_pinch_info(tp,
- &tp->gesture.initial_distance,
- &tp->gesture.angle,
- &tp->gesture.center);
- tp->gesture.prev_scale = 1.0;
-}
-
-static struct phys_coords
-tp_gesture_mm_moved(struct tp_dispatch *tp, struct tp_touch *t)
-{
- struct device_coords delta;
-
- delta.x = abs(t->point.x - t->gesture.initial.x);
- delta.y = abs(t->point.y - t->gesture.initial.y);
-
- return evdev_device_unit_delta_to_mm(tp->device, &delta);
-}
static enum tp_gesture_state
tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)