touchpad: move structs into a header file
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 7 Feb 2014 03:39:27 +0000 (13:39 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 24 Mar 2014 04:56:40 +0000 (14:56 +1000)
The tapping state implementation will be in a separate file, so let's make
sure we can access the structs we need.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/Makefile.am
src/evdev-mt-touchpad.c
src/evdev-mt-touchpad.h [new file with mode: 0644]

index ae1eed02b22ed36a80cdd0640596f731879390db..da3a04802bbd3ae5eadc11f95b4fd82ed23a3202 100644 (file)
@@ -12,6 +12,7 @@ libinput_la_SOURCES =                 \
        evdev.c                         \
        evdev.h                         \
        evdev-mt-touchpad.c             \
+       evdev-mt-touchpad.h             \
        evdev-touchpad.c                \
        filter.c                        \
        filter.h                        \
index 6d1793bdc31da0217bdbd6dccbdcfd17d76e40b0..8a8586a3edf399a0e85c4445bb8f6491dc1ccf74 100644 (file)
 #include <math.h>
 #include <stdbool.h>
 
-#include "evdev.h"
-#include "filter.h"
+#include "evdev-mt-touchpad.h"
 
 #define DEFAULT_CONSTANT_ACCEL_NUMERATOR 50
 #define DEFAULT_MIN_ACCEL_FACTOR 0.16
 #define DEFAULT_MAX_ACCEL_FACTOR 1.0
 #define DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR 700.0
-#define TOUCHPAD_HISTORY_LENGTH 4
-
-#define tp_for_each_touch(_tp, _t) \
-       for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++)
-
-enum touch_state {
-       TOUCH_NONE = 0,
-       TOUCH_BEGIN,
-       TOUCH_UPDATE,
-       TOUCH_END
-};
-
-struct tp_motion {
-       int32_t x;
-       int32_t y;
-};
-
-struct tp_touch {
-       enum touch_state state;
-       bool dirty;
-       int32_t x;
-       int32_t y;
-       uint32_t millis;
-
-       struct {
-               struct tp_motion samples[TOUCHPAD_HISTORY_LENGTH];
-               unsigned int index;
-               unsigned int count;
-       } history;
-
-       struct {
-               int32_t center_x;
-               int32_t center_y;
-       } hysteresis;
-};
-
-struct tp_dispatch {
-       struct evdev_dispatch base;
-       struct evdev_device *device;
-       unsigned int nfingers_down;             /* number of fingers down */
-       unsigned int slot;                      /* current slot */
-
-       unsigned int ntouches;                  /* number of slots */
-       struct tp_touch *touches;               /* len == ntouches */
-
-       struct {
-               int32_t margin_x;
-               int32_t margin_y;
-       } hysteresis;
-
-       struct motion_filter *filter;
-
-       struct {
-               double constant_factor;
-               double min_factor;
-               double max_factor;
-       } accel;
-};
 
 static inline int
 tp_hysteresis(int in, int center, int margin)
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
new file mode 100644 (file)
index 0000000..f7f413b
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright © 2014 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#ifndef EVDEV_MT_TOUCHPAD_H
+#define EVDEV_MT_TOUCHPAD_H
+
+#include <stdbool.h>
+
+#include "evdev.h"
+#include "filter.h"
+
+#define TOUCHPAD_HISTORY_LENGTH 4
+
+enum touch_state {
+       TOUCH_NONE = 0,
+       TOUCH_BEGIN,
+       TOUCH_UPDATE,
+       TOUCH_END
+};
+
+struct tp_motion {
+       int32_t x;
+       int32_t y;
+};
+
+struct tp_touch {
+       enum touch_state state;
+       bool dirty;
+       int32_t x;
+       int32_t y;
+       uint32_t millis;
+
+       struct {
+               struct tp_motion samples[TOUCHPAD_HISTORY_LENGTH];
+               unsigned int index;
+               unsigned int count;
+       } history;
+
+       struct {
+               int32_t center_x;
+               int32_t center_y;
+       } hysteresis;
+};
+
+struct tp_dispatch {
+       struct evdev_dispatch base;
+       struct evdev_device *device;
+       unsigned int nfingers_down;             /* number of fingers down */
+       unsigned int slot;                      /* current slot */
+
+       unsigned int ntouches;                  /* number of slots */
+       struct tp_touch *touches;               /* len == ntouches */
+
+       struct {
+               int32_t margin_x;
+               int32_t margin_y;
+       } hysteresis;
+
+       struct motion_filter *filter;
+
+       struct {
+               double constant_factor;
+               double min_factor;
+               double max_factor;
+       } accel;
+};
+
+#define tp_for_each_touch(_tp, _t) \
+       for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++)
+
+#endif