summaryrefslogtreecommitdiff
path: root/src
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 /src
parent3734c2c5dc65f41aa727d9d69201d604eab6e77d (diff)
state added, now do the matching
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src')
-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
7 files changed, 84 insertions, 10 deletions
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)
22 case EV_KEY: 22 case EV_KEY:
23 switch (ev->code) { 23 switch (ev->code) {
24 case BTN_LEFT: 24 case BTN_LEFT:
25 hw->left = on; 25 hw->button[MT_BUTTON_LEFT] = on;
26 break; 26 break;
27 case BTN_MIDDLE: 27 case BTN_MIDDLE:
28 hw->middle = on; 28 hw->button[MT_BUTTON_MIDDLE] = on;
29 break; 29 break;
30 case BTN_RIGHT: 30 case BTN_RIGHT:
31 hw->right = on; 31 hw->button[MT_BUTTON_RIGHT] = on;
32 break; 32 break;
33 case BTN_MT_REPORT_PACKET: 33 case BTN_MT_REPORT_PACKET:
34 if (on) 34 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 @@
4#include "common.h" 4#include "common.h"
5 5
6#define DIM_FINGER 16 6#define DIM_FINGER 16
7#define DIM_BUTTON 3
8
9#define MT_BUTTON_LEFT 0
10#define MT_BUTTON_MIDDLE 1
11#define MT_BUTTON_RIGHT 2
7 12
8//////////////////////////////////////////////////////// 13////////////////////////////////////////////////////////
9 14
@@ -18,8 +23,7 @@ struct FingerData {
18 23
19struct HWData { 24struct HWData {
20 struct FingerData finger[DIM_FINGER]; 25 struct FingerData finger[DIM_FINGER];
21 int nfinger; 26 int nfinger, button[DIM_BUTTON];
22 bool left, middle, right;
23}; 27};
24 28
25//////////////////////////////////////////////////////// 29////////////////////////////////////////////////////////
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)
18 int rc; 18 int rc;
19 init_iobuf(&mt->buf); 19 init_iobuf(&mt->buf);
20 init_hwdata(&mt->hw); 20 init_hwdata(&mt->hw);
21 init_state(&mt->os);
22 init_state(&mt->ns);
21 if (mt->grabbed) 23 if (mt->grabbed)
22 return 0; 24 return 0;
23 SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)1)); 25 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 @@
4#include "capabilities.h" 4#include "capabilities.h"
5#include "iobuffer.h" 5#include "iobuffer.h"
6#include "hwdata.h" 6#include "hwdata.h"
7#include "state.h"
7 8
8//////////////////////////////////////////////////////// 9////////////////////////////////////////////////////////
9 10
@@ -11,6 +12,7 @@ struct MTouch {
11 struct Capabilities caps; 12 struct Capabilities caps;
12 struct IOBuffer buf; 13 struct IOBuffer buf;
13 struct HWData hw; 14 struct HWData hw;
15 struct State os, ns;
14 bool grabbed; 16 bool grabbed;
15}; 17};
16 18
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)
79static void read_input(LocalDevicePtr local) 79static void read_input(LocalDevicePtr local)
80{ 80{
81 struct MTouch *mt = local->private; 81 struct MTouch *mt = local->private;
82
83 xf86Msg(X_INFO, "read_input called\n");
84
85 if (local->fd >= 0) { 82 if (local->fd >= 0) {
86 while (read_synchronized_event(mt, local->fd)) { 83 while (read_synchronized_event(mt, local->fd)) {
87 xf86Msg(X_INFO, "synced event\n"); 84 modify_state(&mt->ns, &mt->hw);
88 // do all the good stuff here 85 // and something in between here
86 mt->os = mt->ns;
89 } 87 }
90 } 88 }
91} 89}
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 @@
1#include "state.h"
2
3/******************************************************/
4
5void init_state(struct State *s)
6{
7 memset(s, 0, sizeof(struct State));
8}
9
10/******************************************************/
11
12void modify_state(struct State *s, const struct HWData* hw)
13{
14 int i;
15 if (s->button[0] != hw->button[0])
16 xf86Msg(X_INFO, "multitouch: button changed\n");
17 for (i = 0; i < DIM_BUTTON; i++)
18 s->button[i] = hw->button[i];
19}
20
21/******************************************************/
22
23const struct FingerState *find_finger(const struct State *s, int id)
24{
25 int i;
26 for (i = 0; i < s->nfinger; i++)
27 if (s->finger[i].id == id)
28 return s->finger+i;
29 return NULL;
30}
31
32/******************************************************/
33
34void output_state(const struct State *s)
35{
36}
37
38/******************************************************/
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 @@
1#ifndef MTEVENT_H
2#define MTEVENT_H
3
4#include "hwdata.h"
5
6////////////////////////////////////////////////////////
7
8struct FingerState {
9 struct FingerData hw;
10 int id;
11};
12
13////////////////////////////////////////////////////////
14
15struct State {
16 struct FingerState finger[DIM_FINGER];
17 int nfinger, button[DIM_BUTTON];
18};
19
20////////////////////////////////////////////////////////
21
22void init_state(struct State *s);
23void modify_state(struct State *s, const struct HWData* hw);
24void output_state(const struct State *s);
25
26const struct FingerState *find_finger(const struct State *s, int id);
27
28////////////////////////////////////////////////////////
29
30#endif