diff options
Diffstat (limited to 'src/grail-api.c')
| -rw-r--r-- | src/grail-api.c | 46 |
1 files changed, 25 insertions, 21 deletions
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 @@ | |||
| 33 | 33 | ||
| 34 | struct grail_impl { | 34 | struct grail_impl { |
| 35 | struct touch_dev dev; | 35 | struct touch_dev dev; |
| 36 | struct touch_engine engine; | ||
| 37 | struct evbuf evbuf; | 36 | struct evbuf evbuf; |
| 38 | int filter_abs; | 37 | int filter_abs; |
| 39 | int hack_status; | 38 | int hack_status; |
| 40 | }; | 39 | }; |
| 41 | 40 | ||
| 42 | static void tp_event(struct touch_engine *engine, | 41 | static void tp_event(struct touch_dev *dev, |
| 43 | const struct input_event *ev) | 42 | const struct input_event *ev) |
| 44 | { | 43 | { |
| 45 | struct grail *ge = engine->priv; | 44 | struct grail *ge = dev->priv; |
| 46 | struct grail_impl *x = ge->impl; | 45 | struct grail_impl *x = ge->impl; |
| 47 | evbuf_put(&x->evbuf, ev); | 46 | evbuf_put(&x->evbuf, ev); |
| 48 | } | 47 | } |
| @@ -62,14 +61,14 @@ static int extra_filtered(const struct input_event *ev) | |||
| 62 | return 0; | 61 | return 0; |
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | static void tp_sync(struct touch_engine *engine, | 64 | static void tp_sync(struct touch_dev *dev, |
| 66 | const struct input_event *syn) | 65 | const struct input_event *syn) |
| 67 | { | 66 | { |
| 68 | struct input_event ev; | 67 | struct input_event ev; |
| 69 | struct grail *ge = engine->priv; | 68 | struct grail *ge = dev->priv; |
| 70 | struct grail_impl *x = ge->impl; | 69 | struct grail_impl *x = ge->impl; |
| 71 | struct gesture_recognizer *gru = ge->gru; | 70 | struct gesture_recognizer *gru = ge->gru; |
| 72 | struct touch_frame *frame = &engine->frame; | 71 | struct touch_frame *frame = &dev->frame; |
| 73 | grail_mask_t filtered[DIM_EV_TYPE_BYTES]; | 72 | grail_mask_t filtered[DIM_EV_TYPE_BYTES]; |
| 74 | int dofilt, hack, nevent = 0; | 73 | int dofilt, hack, nevent = 0; |
| 75 | gin_frame_begin(ge, frame); | 74 | gin_frame_begin(ge, frame); |
| @@ -120,22 +119,27 @@ int grail_open(struct grail *ge, int fd) | |||
| 120 | if (!x) | 119 | if (!x) |
| 121 | return -ENOMEM; | 120 | return -ENOMEM; |
| 122 | ge->impl = x; | 121 | ge->impl = x; |
| 123 | ret = gin_init(ge); | 122 | |
| 123 | ret = touch_dev_open(&x->dev, fd); | ||
| 124 | if (ret) | 124 | if (ret) |
| 125 | goto freemem; | 125 | goto freemem; |
| 126 | ret = touch_dev_open(&x->dev, fd); | 126 | x->dev.event = tp_event; |
| 127 | x->dev.sync = tp_sync; | ||
| 128 | x->dev.priv = ge; | ||
| 129 | |||
| 130 | ret = gin_init(ge); | ||
| 127 | if (ret) | 131 | if (ret) |
| 128 | goto freegin; | 132 | goto freedev; |
| 133 | |||
| 129 | ret = gru_init(ge); | 134 | ret = gru_init(ge); |
| 130 | if (ret) | 135 | if (ret) |
| 131 | goto freedev; | 136 | goto freegin; |
| 132 | touch_engine_init(&x->engine, tp_event, tp_sync, ge); | 137 | |
| 133 | touch_engine_attach(&x->engine, &x->dev); | ||
| 134 | return 0; | 138 | return 0; |
| 135 | freedev: | ||
| 136 | touch_dev_close(&x->dev, fd); | ||
| 137 | freegin: | 139 | freegin: |
| 138 | gin_destroy(ge); | 140 | gin_destroy(ge); |
| 141 | freedev: | ||
| 142 | touch_dev_close(&x->dev, fd); | ||
| 139 | freemem: | 143 | freemem: |
| 140 | free(x); | 144 | free(x); |
| 141 | ge->impl = 0; | 145 | ge->impl = 0; |
| @@ -146,10 +150,9 @@ void grail_close(struct grail *ge, int fd) | |||
| 146 | { | 150 | { |
| 147 | struct grail_impl *x = ge->impl; | 151 | struct grail_impl *x = ge->impl; |
| 148 | void *status; | 152 | void *status; |
| 149 | touch_engine_detach(&x->engine, &x->dev); | ||
| 150 | gru_destroy(ge); | 153 | gru_destroy(ge); |
| 151 | touch_dev_close(&x->dev, fd); | ||
| 152 | gin_destroy(ge); | 154 | gin_destroy(ge); |
| 155 | touch_dev_close(&x->dev, fd); | ||
| 153 | free(ge->impl); | 156 | free(ge->impl); |
| 154 | ge->impl = 0; | 157 | ge->impl = 0; |
| 155 | } | 158 | } |
| @@ -169,9 +172,10 @@ int grail_pull(struct grail *ge, int fd) | |||
| 169 | void grail_get_units(const struct grail *ge, | 172 | void grail_get_units(const struct grail *ge, |
| 170 | struct grail_coord *min, struct grail_coord *max) | 173 | struct grail_coord *min, struct grail_coord *max) |
| 171 | { | 174 | { |
| 172 | const struct touch_dev_caps *caps = &ge->impl->dev.caps; | 175 | const struct touch_caps *caps = &ge->impl->dev.caps; |
| 173 | min->x = caps->info[TP_POS_X].minimum; | 176 | min->x = caps->min_x; |
| 174 | min->y = caps->info[TP_POS_Y].minimum; | 177 | min->y = caps->min_y; |
| 175 | max->x = caps->info[TP_POS_X].maximum; | 178 | max->x = caps->max_x; |
| 176 | max->y = caps->info[TP_POS_Y].maximum; | 179 | max->y = caps->max_y; |
| 177 | } | 180 | } |
| 181 | |||
