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 --- src/grail-api.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'src/grail-api.c') diff --git a/src/grail-api.c b/src/grail-api.c index 7c054a9..afd97b9 100644 --- a/src/grail-api.c +++ b/src/grail-api.c @@ -33,16 +33,15 @@ struct grail_impl { struct touch_dev dev; - struct touch_engine engine; struct evbuf evbuf; int filter_abs; int hack_status; }; -static void tp_event(struct touch_engine *engine, +static void tp_event(struct touch_dev *dev, const struct input_event *ev) { - struct grail *ge = engine->priv; + struct grail *ge = dev->priv; struct grail_impl *x = ge->impl; evbuf_put(&x->evbuf, ev); } @@ -62,14 +61,14 @@ static int extra_filtered(const struct input_event *ev) return 0; } -static void tp_sync(struct touch_engine *engine, +static void tp_sync(struct touch_dev *dev, const struct input_event *syn) { struct input_event ev; - struct grail *ge = engine->priv; + struct grail *ge = dev->priv; struct grail_impl *x = ge->impl; struct gesture_recognizer *gru = ge->gru; - struct touch_frame *frame = &engine->frame; + struct touch_frame *frame = &dev->frame; grail_mask_t filtered[DIM_EV_TYPE_BYTES]; int dofilt, hack, nevent = 0; gin_frame_begin(ge, frame); @@ -120,22 +119,27 @@ int grail_open(struct grail *ge, int fd) if (!x) return -ENOMEM; ge->impl = x; - ret = gin_init(ge); + + ret = touch_dev_open(&x->dev, fd); if (ret) goto freemem; - ret = touch_dev_open(&x->dev, fd); + x->dev.event = tp_event; + x->dev.sync = tp_sync; + x->dev.priv = ge; + + ret = gin_init(ge); if (ret) - goto freegin; + goto freedev; + ret = gru_init(ge); if (ret) - goto freedev; - touch_engine_init(&x->engine, tp_event, tp_sync, ge); - touch_engine_attach(&x->engine, &x->dev); + goto freegin; + return 0; - freedev: - touch_dev_close(&x->dev, fd); freegin: gin_destroy(ge); + freedev: + touch_dev_close(&x->dev, fd); freemem: free(x); ge->impl = 0; @@ -146,10 +150,9 @@ void grail_close(struct grail *ge, int fd) { struct grail_impl *x = ge->impl; void *status; - touch_engine_detach(&x->engine, &x->dev); gru_destroy(ge); - touch_dev_close(&x->dev, fd); gin_destroy(ge); + touch_dev_close(&x->dev, fd); free(ge->impl); ge->impl = 0; } @@ -169,9 +172,10 @@ int grail_pull(struct grail *ge, int fd) void grail_get_units(const struct grail *ge, struct grail_coord *min, struct grail_coord *max) { - const struct touch_dev_caps *caps = &ge->impl->dev.caps; - min->x = caps->info[TP_POS_X].minimum; - min->y = caps->info[TP_POS_Y].minimum; - max->x = caps->info[TP_POS_X].maximum; - max->y = caps->info[TP_POS_Y].maximum; + const struct touch_caps *caps = &ge->impl->dev.caps; + min->x = caps->min_x; + min->y = caps->min_y; + max->x = caps->max_x; + max->y = caps->max_y; } + -- cgit v1.2.3