summaryrefslogtreecommitdiff
path: root/src/mtouch.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-10-12 15:38:43 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-10-12 15:38:43 +0200
commitacea9df3381825a634c000a574f58b4ca5293ee8 (patch)
tree3698bd55f137bc377f1b840e4fb5bf9e446e7250 /src/mtouch.c
parent7380af2c93dc83f4f09e293717d46eadf7799e89 (diff)
Same version, but using the mtdev library.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/mtouch.c')
-rw-r--r--src/mtouch.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/src/mtouch.c b/src/mtouch.c
index f7a2710..e2d9572 100644
--- a/src/mtouch.c
+++ b/src/mtouch.c
@@ -34,8 +34,7 @@ int configure_mtouch(struct MTouch *mt, int fd)
34 34
35int open_mtouch(struct MTouch *mt, int fd) 35int open_mtouch(struct MTouch *mt, int fd)
36{ 36{
37 mtdev_init(&mt->dev, &mt->caps); 37 mtdev_open(&mt->dev, fd);
38 init_iobuf(&mt->buf);
39 init_hwstate(&mt->hs, &mt->caps); 38 init_hwstate(&mt->hs, &mt->caps);
40 init_mtstate(&mt->prev_state); 39 init_mtstate(&mt->prev_state);
41 init_mtstate(&mt->state); 40 init_mtstate(&mt->state);
@@ -48,40 +47,19 @@ int open_mtouch(struct MTouch *mt, int fd)
48 return 0; 47 return 0;
49} 48}
50 49
51
52int get_mtouch(struct MTouch *mt, int fd, struct input_event* ev, int ev_max)
53{
54 const struct input_event *kev;
55 int count = 0;
56 while (count < ev_max) {
57 while (mtdev_empty(&mt->dev)) {
58 kev = get_iobuf_event(&mt->buf, fd);
59 if (!kev)
60 return count;
61 mtdev_put(&mt->dev, &mt->caps, kev);
62 }
63 mtdev_get(&mt->dev, &ev[count++]);
64 }
65 return count;
66}
67
68int close_mtouch(struct MTouch *mt, int fd) 50int close_mtouch(struct MTouch *mt, int fd)
69{ 51{
70 if (use_grab) { 52 if (use_grab) {
71 int rc; 53 int rc;
72 SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)0)); 54 SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)0));
73 } 55 }
74 mtdev_destroy(&mt->dev); 56 mtdev_close(&mt->dev);
75 return 0; 57 return 0;
76} 58}
77 59
78int read_packet(struct MTouch *mt, int fd) 60int read_packet(struct MTouch *mt, int fd)
79{ 61{
80 struct input_event ev; 62 int ret = modify_hwstate(&mt->hs, &mt->dev, fd, &mt->caps);
81 int ret;
82 while ((ret = get_mtouch(mt, fd, &ev, 1)) > 0)
83 if (hwstate_read(&mt->hs, &mt->caps, &ev))
84 break;
85 if (ret <= 0) 63 if (ret <= 0)
86 return ret; 64 return ret;
87 extract_mtstate(&mt->state, &mt->hs, &mt->caps); 65 extract_mtstate(&mt->state, &mt->hs, &mt->caps);
@@ -97,7 +75,5 @@ int read_packet(struct MTouch *mt, int fd)
97 75
98int has_delayed_gestures(struct MTouch *mt, int fd) 76int has_delayed_gestures(struct MTouch *mt, int fd)
99{ 77{
100 return mt->mem.wait && 78 return mt->mem.wait && mtdev_idle(&mt->dev, fd, mt->mem.wait);
101 mtdev_empty(&mt->dev) &&
102 poll_iobuf(&mt->buf, fd, mt->mem.wait) == 0;
103} 79}