summaryrefslogtreecommitdiff
path: root/src/test.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-06-21 18:56:49 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-06-21 18:56:49 +0200
commit7380af2c93dc83f4f09e293717d46eadf7799e89 (patch)
tree2eb11199ef87e3181411bb848252bb5d6fed0be6 /src/test.c
parent71168e1fb794f4a24e97177508bb1d54ae24b266 (diff)
Simplify event reading
This patch puts the reading code more in line with the upcoming mtdev library, and should remove some spurious input behavior. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/test.c')
-rw-r--r--src/test.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/test.c b/src/test.c
index ce2fdf5..e4247d2 100644
--- a/src/test.c
+++ b/src/test.c
@@ -27,8 +27,6 @@ static void loop_device(int fd)
27{ 27{
28 struct Gestures gs; 28 struct Gestures gs;
29 struct MTouch mt; 29 struct MTouch mt;
30 const struct input_event *ev;
31 struct input_event event;
32 if (configure_mtouch(&mt, fd)) { 30 if (configure_mtouch(&mt, fd)) {
33 fprintf(stderr, "error: could not configure device\n"); 31 fprintf(stderr, "error: could not configure device\n");
34 return; 32 return;
@@ -37,12 +35,12 @@ static void loop_device(int fd)
37 fprintf(stderr, "error: could not open device\n"); 35 fprintf(stderr, "error: could not open device\n");
38 return; 36 return;
39 } 37 }
40 while (ev = get_iobuf_event(&mt.buf, fd)) { 38 while (poll_iobuf(&mt.buf, fd, 5000)) {
41 if (parse_event(&mt, ev)) { 39 while (read_packet(&mt, fd) > 0) {
42 extract_gestures(&gs, &mt); 40 extract_gestures(&gs, &mt);
43 output_gesture(&gs); 41 output_gesture(&gs);
44 } 42 }
45 if (mt_is_idle(&mt, fd)) { 43 if (has_delayed_gestures(&mt, fd)) {
46 extract_delayed_gestures(&gs, &mt); 44 extract_delayed_gestures(&gs, &mt);
47 output_gesture(&gs); 45 output_gesture(&gs);
48 } 46 }
@@ -56,7 +54,7 @@ int main(int argc, char *argv[])
56 fprintf(stderr, "Usage: test <mtdev>\n"); 54 fprintf(stderr, "Usage: test <mtdev>\n");
57 return -1; 55 return -1;
58 } 56 }
59 int fd = open(argv[1], O_RDONLY); 57 int fd = open(argv[1], O_RDONLY | O_NONBLOCK);
60 if (fd < 0) { 58 if (fd < 0) {
61 fprintf(stderr, "error: could not open file\n"); 59 fprintf(stderr, "error: could not open file\n");
62 return -1; 60 return -1;