aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-06-16 02:30:41 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-06-16 02:30:41 +0200
commit8dff8642c43a473713d48533974d9c7883bbc5c1 (patch)
treeea8513c76d38f2612a1202d30abf0f2e768f204c /include
parent1c73d171b2814bf2809aa48c2d4b683a064a4f7e (diff)
downloadxorg-input-kobomultitouch-8dff8642c43a473713d48533974d9c7883bbc5c1.tar.gz
xorg-input-kobomultitouch-8dff8642c43a473713d48533974d9c7883bbc5c1.tar.bz2
xorg-input-kobomultitouch-8dff8642c43a473713d48533974d9c7883bbc5c1.zip
refactor: Replace hwdata by mtdev
This patch makes the switch, from using hwdata and the associated type A parser, to using mtdev and the associated type B parser. A command-line gesture test program is included. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'include')
-rw-r--r--include/gestures.h1
-rw-r--r--include/hwdata.h75
-rw-r--r--include/hwstate.h33
-rw-r--r--include/mtdev-caps.h1
-rw-r--r--include/mtouch.h11
-rw-r--r--include/mtstate.h16
6 files changed, 32 insertions, 105 deletions
diff --git a/include/gestures.h b/include/gestures.h
index 2bd4a55..1d70a25 100644
--- a/include/gestures.h
+++ b/include/gestures.h
@@ -39,5 +39,6 @@ struct Gestures {
};
void extract_gestures(struct Gestures *gs, struct MTouch* mt);
+void output_gesture(const struct Gestures *gs);
#endif
diff --git a/include/hwdata.h b/include/hwdata.h
deleted file mode 100644
index 21864dc..0000000
--- a/include/hwdata.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/***************************************************************************
- *
- * Multitouch X driver
- * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- **************************************************************************/
-
-#ifndef HWDATA_H
-#define HWDATA_H
-
-#include "common.h"
-#include "button.h"
-
-#define BIT_MT_TOUCH_MAJOR 0
-#define BIT_MT_TOUCH_MINOR 1
-#define BIT_MT_WIDTH_MAJOR 2
-#define BIT_MT_WIDTH_MINOR 3
-#define BIT_MT_ORIENTATION 4
-#define BIT_MT_PRESSURE 5
-#define BIT_MT_POSITION_X 6
-#define BIT_MT_POSITION_Y 7
-#define BIT_MT_CNT 8
-
-struct FingerData {
- int touch_major, touch_minor;
- int width_major, width_minor;
- int orientation, pressure;
- int position_x, position_y;
-};
-
-/**
- * struct HWData - hardware reads
- *
- * @finger: finger data
- * @mask: bits corresponding to data actually read (readonly)
- * @mread: bits corresponding to data in progress (writeonly)
- * @button: bitmask of buttons
- * @nfinger: number of fingers actually read (readonly)
- * @nread: number of fingers in progress (writeonly)
- *
- */
-struct HWData {
- struct FingerData finger[DIM_FINGER];
- unsigned mask[DIM_FINGER], mread[DIM_FINGER];
- unsigned button;
- int nfinger, mtread, nread;
- mstime_t evtime;
-};
-
-void init_hwdata(struct HWData *hw);
-int read_hwdata(struct HWData *hw, const struct input_event* ev);
-void output_hwdata(const struct HWData *hw);
-
-static inline int finger_dist2(const struct FingerData *a,
- const struct FingerData *b)
-{
- return dist2(a->position_x - b->position_x,
- a->position_y - b->position_y);
-}
-
-#endif
diff --git a/include/hwstate.h b/include/hwstate.h
index 07d4ed6..4243292 100644
--- a/include/hwstate.h
+++ b/include/hwstate.h
@@ -22,26 +22,35 @@
#ifndef HWSTATE_H
#define HWSTATE_H
-#include "mtdev-caps.h"
-#include "hwdata.h"
+#include "mtdev.h"
-/* zero id means not mapped (not touching) */
struct FingerState {
- struct FingerData hw;
- int id;
+ int touch_major, touch_minor;
+ int width_major, width_minor;
+ int orientation, pressure;
+ int position_x, position_y;
+ int tracking_id;
};
struct HWState {
- struct FingerState finger[DIM_FINGER];
+ struct FingerState data[DIM_FINGER];
+ bitmask_t used;
+ bitmask_t slot;
bitmask_t button;
- int nfinger;
mstime_t evtime;
- int lastid;
};
-void init_hwstate(struct HWState *s);
-void modify_hwstate(struct HWState *s,
- const struct HWData *hw,
- const struct Capabilities *caps);
+void init_hwstate(struct HWState *s,
+ const struct Capabilities *caps);
+int modify_hwstate(struct HWState *s, struct MTDev *dev,
+ const struct Capabilities *caps);
+void output_hwstate(const struct HWState *s);
+
+static inline int finger_dist2(const struct FingerState *a,
+ const struct FingerState *b)
+{
+ return dist2(a->position_x - b->position_x,
+ a->position_y - b->position_y);
+}
#endif
diff --git a/include/mtdev-caps.h b/include/mtdev-caps.h
index 4460eca..727cd11 100644
--- a/include/mtdev-caps.h
+++ b/include/mtdev-caps.h
@@ -23,6 +23,7 @@
#define MTDEV_CAPS_H
#include "common.h"
+#include "button.h"
#include "abs2mt.h"
#include "mtbit.h"
diff --git a/include/mtouch.h b/include/mtouch.h
index a495960..2b76652 100644
--- a/include/mtouch.h
+++ b/include/mtouch.h
@@ -22,16 +22,13 @@
#ifndef MTOUCH_H
#define MTOUCH_H
-#include "mtdev-iobuf.h"
-#include "hwdata.h"
-#include "hwstate.h"
-#include "mtstate.h"
#include "memory.h"
+#include "mtdev-iobuf.h"
struct MTouch {
struct Capabilities caps;
+ struct MTDev dev;
struct IOBuffer buf;
- struct HWData hw;
struct HWState hs;
struct MTState prev_state, state;
struct Memory mem;
@@ -41,9 +38,7 @@ int configure_mtouch(struct MTouch *mt, int fd);
int open_mtouch(struct MTouch *mt, int fd);
int close_mtouch(struct MTouch *mt, int fd);
-int read_synchronized_event(struct MTouch *mt, int fd);
-void parse_event(struct MTouch *mt);
-
+int parse_event(struct MTouch *mt, const struct input_event *ev);
static inline void mt_delay_movement(struct MTouch *mt, int t)
{
diff --git a/include/mtstate.h b/include/mtstate.h
index b6b8e8d..a474114 100644
--- a/include/mtstate.h
+++ b/include/mtstate.h
@@ -24,14 +24,10 @@
#include "hwstate.h"
-struct MTFinger {
- struct FingerData hw;
- int id, thumb;
-};
-
struct MTState {
- struct MTFinger finger[DIM_FINGER];
+ struct FingerState finger[DIM_FINGER];
int nfinger;
+ bitmask_t thumb;
bitmask_t button;
mstime_t evtime;
};
@@ -42,14 +38,14 @@ void extract_mtstate(struct MTState *s,
const struct Capabilities *caps);
void output_mtstate(const struct MTState *s);
-const struct MTFinger *find_finger(const struct MTState *s, int id);
+const struct FingerState *find_finger(const struct MTState *s, int id);
-static inline int center_dist2(const struct MTFinger *a,
+static inline int center_dist2(const struct FingerState *a,
const struct Capabilities *caps)
{
- return dist2(a->hw.position_x - get_cap_xmid(caps),
- a->hw.position_y - get_cap_ymid(caps));
+ return dist2(a->position_x - get_cap_xmid(caps),
+ a->position_y - get_cap_ymid(caps));
}
static inline int center_maxdist2(const struct Capabilities *caps)