diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2010-06-16 02:30:41 +0200 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2010-06-16 02:30:41 +0200 |
commit | 8dff8642c43a473713d48533974d9c7883bbc5c1 (patch) | |
tree | ea8513c76d38f2612a1202d30abf0f2e768f204c /src/test.c | |
parent | 1c73d171b2814bf2809aa48c2d4b683a064a4f7e (diff) | |
download | xorg-input-kobomultitouch-8dff8642c43a473713d48533974d9c7883bbc5c1.tar.gz xorg-input-kobomultitouch-8dff8642c43a473713d48533974d9c7883bbc5c1.tar.bz2 xorg-input-kobomultitouch-8dff8642c43a473713d48533974d9c7883bbc5c1.zip |
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.c | 45 |
1 files changed, 33 insertions, 12 deletions
@@ -19,24 +19,45 @@ * **************************************************************************/ -#include <common.h> +#include <gestures.h> +#include <fcntl.h> #include <xbypass.h> -#include <stdio.h> -#include <time.h> -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 <mtdev>\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; } |