summaryrefslogtreecommitdiff
path: root/test/grail.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/grail.c')
-rw-r--r--test/grail.c28
1 files changed, 19 insertions, 9 deletions
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 @@
28#include <unistd.h> 28#include <unistd.h>
29#include <fcntl.h> 29#include <fcntl.h>
30 30
31static grail_mask_t flag_mask[DIM_GRAIL_TYPE_BYTES];
32
31static int tp_get_clients(struct grail *ge, 33static int tp_get_clients(struct grail *ge,
32 struct grail_client_info *clients, int max_clients, 34 struct grail_client_info *clients, int max_clients,
33 const struct grail_coord *coords, int num_coords, 35 const struct grail_coord *coords, int num_coords,
@@ -38,22 +40,24 @@ static int tp_get_clients(struct grail *ge,
38 clients[0].id.root = 1; 40 clients[0].id.root = 1;
39 clients[0].id.event = 2; 41 clients[0].id.event = 2;
40 clients[0].id.child = 3; 42 clients[0].id.child = 3;
41 clients[0].mask[0] = 0xff; 43 memcpy(clients[0].mask, flag_mask, sizeof(flag_mask));
42 return 1; 44 return 1;
43} 45}
44 46
45static void tp_event(struct grail *ge, const struct input_event *ev) 47static void tp_event(struct grail *ge, const struct input_event *ev)
46{ 48{
49 if (!grail_mask_get(flag_mask, GRAIL_TYPE_MOVE))
50 return;
47 fprintf(stderr, "event %d 0x%x %d\n", ev->type, ev->code, ev->value); 51 fprintf(stderr, "event %d 0x%x %d\n", ev->type, ev->code, ev->value);
48} 52}
49 53
50static void tp_gesture(struct grail *ge, const struct grail_event *ev) 54static void tp_gesture(struct grail *ge, const struct grail_event *ev)
51{ 55{
52 int i; 56 int i;
53 fprintf(stderr, "gesture %d %d %d %d %f %f %d:\n", 57 fprintf(stderr, "gesture %d %d %d %d - %f %f %d - %d\n",
54 ev->type, ev->id, 58 ev->type, ev->id, ev->client_id.client, ev->client_id.event,
55 ev->client_id.client, ev->client_id.event, 59 ev->pos.x, ev->pos.y, ev->ntouch,
56 ev->pos.x, ev->pos.y, ev->ntouch); 60 ev->status);
57 for (i = 0; i < ev->nprop; i++) 61 for (i = 0; i < ev->nprop; i++)
58 fprintf(stderr, "\t%d: %f\n", i, ev->prop[i]); 62 fprintf(stderr, "\t%d: %f\n", i, ev->prop[i]);
59} 63}
@@ -62,7 +66,7 @@ static void loop_device(struct grail *ge, int fd)
62{ 66{
63 while (!grail_idle(ge, fd, 5000)) { 67 while (!grail_idle(ge, fd, 5000)) {
64 grail_pull(ge, fd); 68 grail_pull(ge, fd);
65 fprintf(stderr, "launched\n"); 69 fprintf(stderr, "\r");
66 } 70 }
67} 71}
68 72
@@ -71,8 +75,8 @@ int main(int argc, char *argv[])
71 struct grail ge; 75 struct grail ge;
72 int fd; 76 int fd;
73 77
74 if (argc < 2) { 78 if (argc < 3) {
75 fprintf(stderr, "Usage: %s <device>\n", argv[0]); 79 fprintf(stderr, "Usage: %s <mask> <device>\n", argv[0]);
76 return -1; 80 return -1;
77 } 81 }
78 82
@@ -81,7 +85,13 @@ int main(int argc, char *argv[])
81 ge.event = tp_event; 85 ge.event = tp_event;
82 ge.gesture = tp_gesture; 86 ge.gesture = tp_gesture;
83 87
84 fd = open(argv[1], O_RDONLY | O_NONBLOCK); 88 unsigned mask = atoi(argv[1]);
89 flag_mask[0] = (mask >> 0) & 255;
90 flag_mask[1] = (mask >> 8) & 255;
91 flag_mask[2] = (mask >> 16) & 255;
92 flag_mask[3] = (mask >> 24) & 255;
93
94 fd = open(argv[2], O_RDONLY | O_NONBLOCK);
85 if (fd < 0) { 95 if (fd < 0) {
86 fprintf(stderr, "error: could not open device\n"); 96 fprintf(stderr, "error: could not open device\n");
87 return -1; 97 return -1;