From 697b5b5c7d2b1c46387061fcbed24cbee51d98ce Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 4 Aug 2010 16:47:43 +0200 Subject: Introduce tapping Simplify some common parts of the recognizer code and add tapping to the gesture suite. Signed-off-by: Henrik Rydberg --- test/grail.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'test/grail.c') diff --git a/test/grail.c b/test/grail.c index 795e88f..eeaa088 100644 --- a/test/grail.c +++ b/test/grail.c @@ -28,6 +28,8 @@ #include #include +static grail_mask_t flag_mask[DIM_GRAIL_TYPE_BYTES]; + static int tp_get_clients(struct grail *ge, struct grail_client_info *clients, int max_clients, const struct grail_coord *coords, int num_coords, @@ -38,22 +40,24 @@ static int tp_get_clients(struct grail *ge, clients[0].id.root = 1; clients[0].id.event = 2; clients[0].id.child = 3; - clients[0].mask[0] = 0xff; + memcpy(clients[0].mask, flag_mask, sizeof(flag_mask)); return 1; } static void tp_event(struct grail *ge, const struct input_event *ev) { + if (!grail_mask_get(flag_mask, GRAIL_TYPE_MOVE)) + return; fprintf(stderr, "event %d 0x%x %d\n", ev->type, ev->code, ev->value); } static void tp_gesture(struct grail *ge, const struct grail_event *ev) { int i; - fprintf(stderr, "gesture %d %d %d %d %f %f %d:\n", - ev->type, ev->id, - ev->client_id.client, ev->client_id.event, - ev->pos.x, ev->pos.y, ev->ntouch); + fprintf(stderr, "gesture %d %d %d %d - %f %f %d - %d\n", + ev->type, ev->id, ev->client_id.client, ev->client_id.event, + ev->pos.x, ev->pos.y, ev->ntouch, + ev->status); for (i = 0; i < ev->nprop; i++) fprintf(stderr, "\t%d: %f\n", i, ev->prop[i]); } @@ -62,7 +66,7 @@ static void loop_device(struct grail *ge, int fd) { while (!grail_idle(ge, fd, 5000)) { grail_pull(ge, fd); - fprintf(stderr, "launched\n"); + fprintf(stderr, "\r"); } } @@ -71,8 +75,8 @@ int main(int argc, char *argv[]) struct grail ge; int fd; - if (argc < 2) { - fprintf(stderr, "Usage: %s \n", argv[0]); + if (argc < 3) { + fprintf(stderr, "Usage: %s \n", argv[0]); return -1; } @@ -81,7 +85,13 @@ int main(int argc, char *argv[]) ge.event = tp_event; ge.gesture = tp_gesture; - fd = open(argv[1], O_RDONLY | O_NONBLOCK); + unsigned mask = atoi(argv[1]); + flag_mask[0] = (mask >> 0) & 255; + flag_mask[1] = (mask >> 8) & 255; + flag_mask[2] = (mask >> 16) & 255; + flag_mask[3] = (mask >> 24) & 255; + + fd = open(argv[2], O_RDONLY | O_NONBLOCK); if (fd < 0) { fprintf(stderr, "error: could not open device\n"); return -1; -- cgit v1.2.3