summaryrefslogtreecommitdiff
path: root/src/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test.c')
-rw-r--r--src/test.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/test.c b/src/test.c
index 7d983a0..0088cdd 100644
--- a/src/test.c
+++ b/src/test.c
@@ -19,24 +19,45 @@
19 * 19 *
20 **************************************************************************/ 20 **************************************************************************/
21 21
22#include <common.h> 22#include <gestures.h>
23#include <fcntl.h>
23#include <xbypass.h> 24#include <xbypass.h>
24#include <stdio.h>
25#include <time.h>
26 25
27static void print_bitfield(unsigned m) 26static void loop_device(int fd)
28{ 27{
29 int i; 28 struct Gestures gs;
30 29 struct MTouch mt;
31 printf("%d\n", m); 30 const struct input_event *ev;
32 foreach_bit(i, m) 31 struct input_event event;
33 printf("%d %d\n", i, 1 << i); 32 if (configure_mtouch(&mt, fd)) {
33 fprintf(stderr, "error: could not configure device\n");
34 return;
35 }
36 if (open_mtouch(&mt, fd)) {
37 fprintf(stderr, "error: could not open device\n");
38 return;
39 }
40 while (ev = get_iobuf_event(&mt.buf, fd)) {
41 if (parse_event(&mt, ev)) {
42 extract_gestures(&gs, &mt);
43 output_gesture(&gs);
44 }
45 }
46 close_mtouch(&mt, fd);
34} 47}
35 48
36int main(int argc, char *argv[]) 49int main(int argc, char *argv[])
37{ 50{
38 print_bitfield(5); 51 if (argc < 2) {
39 print_bitfield(126); 52 fprintf(stderr, "Usage: test <mtdev>\n");
40 print_bitfield(0); 53 return -1;
54 }
55 int fd = open(argv[1], O_RDONLY);
56 if (fd < 0) {
57 fprintf(stderr, "error: could not open file\n");
58 return -1;
59 }
60 loop_device(fd);
61 close(fd);
41 return 0; 62 return 0;
42} 63}