aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2008-11-06 17:18:16 +0100
committerHenrik Rydberg <rydberg@euromail.se>2008-11-06 17:18:16 +0100
commit63de72d8d810e3692c96c7385b497bb4d68ef54a (patch)
treecaa3ecce7c826553d611193f6f1363d76ebd906f
parent3734c2c5dc65f41aa727d9d69201d604eab6e77d (diff)
downloadxorg-input-kobomultitouch-63de72d8d810e3692c96c7385b497bb4d68ef54a.tar.gz
xorg-input-kobomultitouch-63de72d8d810e3692c96c7385b497bb4d68ef54a.tar.bz2
xorg-input-kobomultitouch-63de72d8d810e3692c96c7385b497bb4d68ef54a.zip
state added, now do the matching
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--Makefile1
-rw-r--r--src/hwdata.c6
-rw-r--r--src/hwdata.h8
-rw-r--r--src/mtouch.c2
-rw-r--r--src/mtouch.h2
-rw-r--r--src/multitouch.c8
-rw-r--r--src/state.c38
-rw-r--r--src/state.h30
8 files changed, 85 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 59b0aba..bc5cc02 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ MODULES = src
o_src = capabilities \
iobuffer \
hwdata \
+ state \
mtouch \
multitouch
diff --git a/src/hwdata.c b/src/hwdata.c
index 17b9a46..029d68a 100644
--- a/src/hwdata.c
+++ b/src/hwdata.c
@@ -22,13 +22,13 @@ bool read_hwdata(struct HWData *hw, const struct input_event* ev)
case EV_KEY:
switch (ev->code) {
case BTN_LEFT:
- hw->left = on;
+ hw->button[MT_BUTTON_LEFT] = on;
break;
case BTN_MIDDLE:
- hw->middle = on;
+ hw->button[MT_BUTTON_MIDDLE] = on;
break;
case BTN_RIGHT:
- hw->right = on;
+ hw->button[MT_BUTTON_RIGHT] = on;
break;
case BTN_MT_REPORT_PACKET:
if (on)
diff --git a/src/hwdata.h b/src/hwdata.h
index b9316db..239e022 100644
--- a/src/hwdata.h
+++ b/src/hwdata.h
@@ -4,6 +4,11 @@
#include "common.h"
#define DIM_FINGER 16
+#define DIM_BUTTON 3
+
+#define MT_BUTTON_LEFT 0
+#define MT_BUTTON_MIDDLE 1
+#define MT_BUTTON_RIGHT 2
////////////////////////////////////////////////////////
@@ -18,8 +23,7 @@ struct FingerData {
struct HWData {
struct FingerData finger[DIM_FINGER];
- int nfinger;
- bool left, middle, right;
+ int nfinger, button[DIM_BUTTON];
};
////////////////////////////////////////////////////////
diff --git a/src/mtouch.c b/src/mtouch.c
index e469d2e..cb1c44c 100644
--- a/src/mtouch.c
+++ b/src/mtouch.c
@@ -18,6 +18,8 @@ int open_mtouch(struct MTouch *mt, int fd)
int rc;
init_iobuf(&mt->buf);
init_hwdata(&mt->hw);
+ init_state(&mt->os);
+ init_state(&mt->ns);
if (mt->grabbed)
return 0;
SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)1));
diff --git a/src/mtouch.h b/src/mtouch.h
index 8324e9e..a131b40 100644
--- a/src/mtouch.h
+++ b/src/mtouch.h
@@ -4,6 +4,7 @@
#include "capabilities.h"
#include "iobuffer.h"
#include "hwdata.h"
+#include "state.h"
////////////////////////////////////////////////////////
@@ -11,6 +12,7 @@ struct MTouch {
struct Capabilities caps;
struct IOBuffer buf;
struct HWData hw;
+ struct State os, ns;
bool grabbed;
};
diff --git a/src/multitouch.c b/src/multitouch.c
index 40895c9..f6e3d05 100644
--- a/src/multitouch.c
+++ b/src/multitouch.c
@@ -79,13 +79,11 @@ static void device_close(LocalDevicePtr local)
static void read_input(LocalDevicePtr local)
{
struct MTouch *mt = local->private;
-
- xf86Msg(X_INFO, "read_input called\n");
-
if (local->fd >= 0) {
while (read_synchronized_event(mt, local->fd)) {
- xf86Msg(X_INFO, "synced event\n");
- // do all the good stuff here
+ modify_state(&mt->ns, &mt->hw);
+ // and something in between here
+ mt->os = mt->ns;
}
}
}
diff --git a/src/state.c b/src/state.c
new file mode 100644
index 0000000..46b7fef
--- /dev/null
+++ b/src/state.c
@@ -0,0 +1,38 @@
+#include "state.h"
+
+/******************************************************/
+
+void init_state(struct State *s)
+{
+ memset(s, 0, sizeof(struct State));
+}
+
+/******************************************************/
+
+void modify_state(struct State *s, const struct HWData* hw)
+{
+ int i;
+ if (s->button[0] != hw->button[0])
+ xf86Msg(X_INFO, "multitouch: button changed\n");
+ for (i = 0; i < DIM_BUTTON; i++)
+ s->button[i] = hw->button[i];
+}
+
+/******************************************************/
+
+const struct FingerState *find_finger(const struct State *s, int id)
+{
+ int i;
+ for (i = 0; i < s->nfinger; i++)
+ if (s->finger[i].id == id)
+ return s->finger+i;
+ return NULL;
+}
+
+/******************************************************/
+
+void output_state(const struct State *s)
+{
+}
+
+/******************************************************/
diff --git a/src/state.h b/src/state.h
new file mode 100644
index 0000000..9c36617
--- /dev/null
+++ b/src/state.h
@@ -0,0 +1,30 @@
+#ifndef MTEVENT_H
+#define MTEVENT_H
+
+#include "hwdata.h"
+
+////////////////////////////////////////////////////////
+
+struct FingerState {
+ struct FingerData hw;
+ int id;
+};
+
+////////////////////////////////////////////////////////
+
+struct State {
+ struct FingerState finger[DIM_FINGER];
+ int nfinger, button[DIM_BUTTON];
+};
+
+////////////////////////////////////////////////////////
+
+void init_state(struct State *s);
+void modify_state(struct State *s, const struct HWData* hw);
+void output_state(const struct State *s);
+
+const struct FingerState *find_finger(const struct State *s, int id);
+
+////////////////////////////////////////////////////////
+
+#endif