summaryrefslogtreecommitdiff
path: root/src/mtouch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mtouch.c')
-rw-r--r--src/mtouch.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/mtouch.c b/src/mtouch.c
index 14c0fd9..f7a2710 100644
--- a/src/mtouch.c
+++ b/src/mtouch.c
@@ -48,6 +48,23 @@ int open_mtouch(struct MTouch *mt, int fd)
48 return 0; 48 return 0;
49} 49}
50 50
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
51int close_mtouch(struct MTouch *mt, int fd) 68int close_mtouch(struct MTouch *mt, int fd)
52{ 69{
53 if (use_grab) { 70 if (use_grab) {
@@ -58,11 +75,15 @@ int close_mtouch(struct MTouch *mt, int fd)
58 return 0; 75 return 0;
59} 76}
60 77
61int parse_event(struct MTouch *mt, const struct input_event *ev) 78int read_packet(struct MTouch *mt, int fd)
62{ 79{
63 mtdev_put(&mt->dev, &mt->caps, ev); 80 struct input_event ev;
64 if (!modify_hwstate(&mt->hs, &mt->dev, &mt->caps)) 81 int ret;
65 return 0; 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)
86 return ret;
66 extract_mtstate(&mt->state, &mt->hs, &mt->caps); 87 extract_mtstate(&mt->state, &mt->hs, &mt->caps);
67#if 0 88#if 0
68 output_mtstate(&mt->state); 89 output_mtstate(&mt->state);
@@ -74,10 +95,9 @@ int parse_event(struct MTouch *mt, const struct input_event *ev)
74 return 1; 95 return 1;
75} 96}
76 97
77int mt_is_idle(struct MTouch *mt, int fd) 98int has_delayed_gestures(struct MTouch *mt, int fd)
78{ 99{
79 return mt->mem.wait && 100 return mt->mem.wait &&
80 evbuf_empty(&mt->dev.outbuf) && 101 mtdev_empty(&mt->dev) &&
81 evbuf_empty(&mt->dev.inbuf) &&
82 poll_iobuf(&mt->buf, fd, mt->mem.wait) == 0; 102 poll_iobuf(&mt->buf, fd, mt->mem.wait) == 0;
83} 103}