gestures: move up some functions to use them later
authorJoseExposito <jose.exposito89@gmail.com>
Mon, 29 Mar 2021 15:31:46 +0000 (17:31 +0200)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 13 Apr 2021 04:01:11 +0000 (14:01 +1000)
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>
src/evdev-mt-touchpad-gestures.c

index 57df44a..0394f12 100644 (file)
@@ -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)