summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-08-19 20:03:15 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-08-19 20:03:15 +0200
commita704984e03d28b4be40e12c43be1b163bc9e09e2 (patch)
treec4720a59aa77918ffef742d7ec7ef2a7e2eda16e /test
parentcb2cad3b8c506a08a6bdad548a10ff47f85ef38b (diff)
Simplify touch machinery
To be able to model touch information uniformly across all supported devices, the semantics of the touch attributes has to be treated explicitly. Drop the generic touch property array and replace it by an actual structure. In addition, the touch-engine abstraction turned out to not be needed, so drop it as well. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'test')
-rw-r--r--test/grail-touch.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/test/grail-touch.c b/test/grail-touch.c
index bed31c3..c5ecae3 100644
--- a/test/grail-touch.c
+++ b/test/grail-touch.c
@@ -28,22 +28,33 @@
28#include <unistd.h> 28#include <unistd.h>
29#include <fcntl.h> 29#include <fcntl.h>
30 30
31static void tp_event(struct touch_engine *engine, 31static void tp_event(struct touch_dev *dev,
32 const struct input_event *ev) 32 const struct input_event *ev)
33{ 33{
34 fprintf(stderr, "event %d 0x%x %d\n", ev->type, ev->code, ev->value); 34 fprintf(stderr, "event %d 0x%x %d\n", ev->type, ev->code, ev->value);
35} 35}
36 36
37static void tp_sync(struct touch_engine *engine, 37static void tp_sync(struct touch_dev *dev,
38 const struct input_event *syn) 38 const struct input_event *syn)
39{ 39{
40 struct touch_frame *frame = &engine->frame; 40 struct touch_frame *frame = &dev->frame;
41 int i, j; 41 int i, j;
42 for (i = 0; i < frame->nactive; i++) { 42 for (i = 0; i < frame->nactive; i++) {
43 struct touch *t = frame->active[i]; 43 struct touch *t = frame->active[i];
44 fprintf(stderr, "touch %d %d\n", i, t->slot); 44 fprintf(stderr, "touch %d\n", i);
45 for (j = 0; j < DIM_TOUCH_PROP; j++) 45 fprintf(stderr, " slot: %d\n", t->slot);
46 fprintf(stderr, " %d\n", t->prop[j]); 46 fprintf(stderr, " id: %d\n", t->id);
47 fprintf(stderr, " tool_type: %d\n", t->tool_type);
48 fprintf(stderr, " x: %d\n", t->x);
49 fprintf(stderr, " y: %d\n", t->y);
50 fprintf(stderr, " touch_major: %d\n", t->touch_major);
51 fprintf(stderr, " touch_minor: %d\n", t->touch_minor);
52 fprintf(stderr, " width_major: %d\n", t->width_major);
53 fprintf(stderr, " width_minor: %d\n", t->width_minor);
54 fprintf(stderr, " angle: %f\n",
55 touch_angle(dev, t->orientation));
56 fprintf(stderr, " pressure: %f\n",
57 touch_pressure(dev, t->pressure));
47 } 58 }
48 fprintf(stderr, "sync %d %lld %d %d\n", 59 fprintf(stderr, "sync %d %lld %d %d\n",
49 frame->nactive, frame->time, frame->ncreate, frame->ndestroy); 60 frame->nactive, frame->time, frame->ncreate, frame->ndestroy);
@@ -51,12 +62,10 @@ static void tp_sync(struct touch_engine *engine,
51 62
52static void loop_device(struct touch_dev *dev, int fd) 63static void loop_device(struct touch_dev *dev, int fd)
53{ 64{
54 struct touch_engine engine; 65 dev->event = tp_event;
55 touch_engine_init(&engine, tp_event, tp_sync, 0); 66 dev->sync = tp_sync;
56 touch_engine_attach(&engine, dev);
57 while (!touch_dev_idle(dev, fd, 5000)) 67 while (!touch_dev_idle(dev, fd, 5000))
58 touch_dev_pull(dev, fd); 68 touch_dev_pull(dev, fd);
59 touch_engine_detach(&engine, dev);
60} 69}
61 70
62int main(int argc, char *argv[]) 71int main(int argc, char *argv[])