From 8dff8642c43a473713d48533974d9c7883bbc5c1 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 16 Jun 2010 02:30:41 +0200 Subject: 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 --- src/test.c | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'src/test.c') 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 @@ * **************************************************************************/ -#include +#include +#include #include -#include -#include -static void print_bitfield(unsigned m) +static void loop_device(int fd) { - int i; - - printf("%d\n", m); - foreach_bit(i, m) - printf("%d %d\n", i, 1 << i); + struct Gestures gs; + struct MTouch mt; + const struct input_event *ev; + struct input_event event; + if (configure_mtouch(&mt, fd)) { + fprintf(stderr, "error: could not configure device\n"); + return; + } + if (open_mtouch(&mt, fd)) { + fprintf(stderr, "error: could not open device\n"); + return; + } + while (ev = get_iobuf_event(&mt.buf, fd)) { + if (parse_event(&mt, ev)) { + extract_gestures(&gs, &mt); + output_gesture(&gs); + } + } + close_mtouch(&mt, fd); } int main(int argc, char *argv[]) { - print_bitfield(5); - print_bitfield(126); - print_bitfield(0); + if (argc < 2) { + fprintf(stderr, "Usage: test \n"); + return -1; + } + int fd = open(argv[1], O_RDONLY); + if (fd < 0) { + fprintf(stderr, "error: could not open file\n"); + return -1; + } + loop_device(fd); + close(fd); return 0; } -- cgit v1.2.3