From a704984e03d28b4be40e12c43be1b163bc9e09e2 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Thu, 19 Aug 2010 20:03:15 +0200 Subject: 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 --- test/grail-touch.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'test') 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 @@ #include #include -static void tp_event(struct touch_engine *engine, +static void tp_event(struct touch_dev *dev, const struct input_event *ev) { fprintf(stderr, "event %d 0x%x %d\n", ev->type, ev->code, ev->value); } -static void tp_sync(struct touch_engine *engine, +static void tp_sync(struct touch_dev *dev, const struct input_event *syn) { - struct touch_frame *frame = &engine->frame; + struct touch_frame *frame = &dev->frame; int i, j; for (i = 0; i < frame->nactive; i++) { struct touch *t = frame->active[i]; - fprintf(stderr, "touch %d %d\n", i, t->slot); - for (j = 0; j < DIM_TOUCH_PROP; j++) - fprintf(stderr, " %d\n", t->prop[j]); + fprintf(stderr, "touch %d\n", i); + fprintf(stderr, " slot: %d\n", t->slot); + fprintf(stderr, " id: %d\n", t->id); + fprintf(stderr, " tool_type: %d\n", t->tool_type); + fprintf(stderr, " x: %d\n", t->x); + fprintf(stderr, " y: %d\n", t->y); + fprintf(stderr, " touch_major: %d\n", t->touch_major); + fprintf(stderr, " touch_minor: %d\n", t->touch_minor); + fprintf(stderr, " width_major: %d\n", t->width_major); + fprintf(stderr, " width_minor: %d\n", t->width_minor); + fprintf(stderr, " angle: %f\n", + touch_angle(dev, t->orientation)); + fprintf(stderr, " pressure: %f\n", + touch_pressure(dev, t->pressure)); } fprintf(stderr, "sync %d %lld %d %d\n", frame->nactive, frame->time, frame->ncreate, frame->ndestroy); @@ -51,12 +62,10 @@ static void tp_sync(struct touch_engine *engine, static void loop_device(struct touch_dev *dev, int fd) { - struct touch_engine engine; - touch_engine_init(&engine, tp_event, tp_sync, 0); - touch_engine_attach(&engine, dev); + dev->event = tp_event; + dev->sync = tp_sync; while (!touch_dev_idle(dev, fd, 5000)) touch_dev_pull(dev, fd); - touch_engine_detach(&engine, dev); } int main(int argc, char *argv[]) -- cgit v1.2.3