summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@bitmath.org>2010-08-04 16:47:43 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-08-05 22:48:38 +0200
commit697b5b5c7d2b1c46387061fcbed24cbee51d98ce (patch)
treeb8e8dbf02453f7c7dc31c691822a088123d21cd8 /test
parent642d7ee26f347152a106d48ddad37a8059d36fb1 (diff)
Introduce tapping
Simplify some common parts of the recognizer code and add tapping to the gesture suite. Signed-off-by: Henrik Rydberg <rydberg@bitmath.org>
Diffstat (limited to 'test')
-rw-r--r--test/grail.c28
-rw-r--r--test/touch.c3
2 files changed, 21 insertions, 10 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;
diff --git a/test/touch.c b/test/touch.c
index 9b2d38a..8893c0d 100644
--- a/test/touch.c
+++ b/test/touch.c
@@ -39,13 +39,14 @@ static void tp_sync(struct touch_engine *engine,
39{ 39{
40 struct touch_frame *frame = &engine->frame; 40 struct touch_frame *frame = &engine->frame;
41 int i, j; 41 int i, j;
42 fprintf(stderr, "sync %d %lld\n", frame->nactive, frame->time);
43 for (i = 0; i < frame->nactive; i++) { 42 for (i = 0; i < frame->nactive; i++) {
44 struct touch *t = frame->active[i]; 43 struct touch *t = frame->active[i];
45 fprintf(stderr, "touch %d %d\n", i, t->slot); 44 fprintf(stderr, "touch %d %d\n", i, t->slot);
46 for (j = 0; j < DIM_TOUCH_PROP; j++) 45 for (j = 0; j < DIM_TOUCH_PROP; j++)
47 fprintf(stderr, " %d\n", t->prop[j]); 46 fprintf(stderr, " %d\n", t->prop[j]);
48 } 47 }
48 fprintf(stderr, "sync %d %lld %d %d\n",
49 frame->nactive, frame->time, frame->ncreate, frame->ndestroy);
49} 50}
50 51
51static void loop_device(struct touch_dev *dev, int fd) 52static void loop_device(struct touch_dev *dev, int fd)