summaryrefslogtreecommitdiff
path: root/src/test.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-06-16 02:30:41 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-06-16 02:30:41 +0200
commit8dff8642c43a473713d48533974d9c7883bbc5c1 (patch)
treeea8513c76d38f2612a1202d30abf0f2e768f204c /src/test.c
parent1c73d171b2814bf2809aa48c2d4b683a064a4f7e (diff)
refactor: Replace hwdata by mtdev
This patch makes the switch, from using hwdata and the associated type A parser, to using mtdev and the associated type B parser. A command-line gesture test program is included. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
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}