diff options
| -rw-r--r-- | include/grail.h | 3 | ||||
| -rw-r--r-- | src/grail-api.c | 15 | ||||
| -rw-r--r-- | src/grail-gestures.c | 8 | ||||
| -rw-r--r-- | src/grail-gestures.h | 3 | ||||
| -rw-r--r-- | src/grail-recognizer.c | 4 | ||||
| -rw-r--r-- | src/grail-recognizer.h | 2 |
6 files changed, 25 insertions, 10 deletions
diff --git a/include/grail.h b/include/grail.h index a100b36..0fa4473 100644 --- a/include/grail.h +++ b/include/grail.h | |||
| @@ -88,4 +88,7 @@ int grail_idle(struct grail *ge, int fd, int ms); | |||
| 88 | int grail_pull(struct grail *ge, int fd); | 88 | int grail_pull(struct grail *ge, int fd); |
| 89 | void grail_close(struct grail *ge, int fd); | 89 | void grail_close(struct grail *ge, int fd); |
| 90 | 90 | ||
| 91 | void grail_get_units(struct grail_coord *min, struct grail_coord *max, | ||
| 92 | const struct grail *ge); | ||
| 93 | |||
| 91 | #endif | 94 | #endif |
diff --git a/src/grail-api.c b/src/grail-api.c index c4a88df..2c6c438 100644 --- a/src/grail-api.c +++ b/src/grail-api.c | |||
| @@ -95,13 +95,14 @@ int grail_open(struct grail *ge, int fd) | |||
| 95 | x = calloc(1, sizeof(*x)); | 95 | x = calloc(1, sizeof(*x)); |
| 96 | if (!x) | 96 | if (!x) |
| 97 | return -ENOMEM; | 97 | return -ENOMEM; |
| 98 | ge->impl = x; | ||
| 98 | ret = gin_init(ge); | 99 | ret = gin_init(ge); |
| 99 | if (ret) | 100 | if (ret) |
| 100 | goto freemem; | 101 | goto freemem; |
| 101 | ret = touch_dev_open(&x->dev, fd); | 102 | ret = touch_dev_open(&x->dev, fd); |
| 102 | if (ret) | 103 | if (ret) |
| 103 | goto freegin; | 104 | goto freegin; |
| 104 | ret = gru_init(ge, &x->dev.caps); | 105 | ret = gru_init(ge); |
| 105 | if (ret) | 106 | if (ret) |
| 106 | goto freedev; | 107 | goto freedev; |
| 107 | x->fd = fd; | 108 | x->fd = fd; |
| @@ -110,7 +111,6 @@ int grail_open(struct grail *ge, int fd) | |||
| 110 | ret = pthread_create(&x->thread, NULL, grail_thread, x); | 111 | ret = pthread_create(&x->thread, NULL, grail_thread, x); |
| 111 | if (ret) | 112 | if (ret) |
| 112 | goto freegru; | 113 | goto freegru; |
| 113 | ge->impl = x; | ||
| 114 | touch_engine_init(&x->engine, tp_event, tp_sync, ge); | 114 | touch_engine_init(&x->engine, tp_event, tp_sync, ge); |
| 115 | touch_engine_attach(&x->engine, &x->dev); | 115 | touch_engine_attach(&x->engine, &x->dev); |
| 116 | return 0; | 116 | return 0; |
| @@ -122,6 +122,7 @@ int grail_open(struct grail *ge, int fd) | |||
| 122 | gin_destroy(ge); | 122 | gin_destroy(ge); |
| 123 | freemem: | 123 | freemem: |
| 124 | free(x); | 124 | free(x); |
| 125 | ge->impl = 0; | ||
| 125 | return ret; | 126 | return ret; |
| 126 | } | 127 | } |
| 127 | 128 | ||
| @@ -168,3 +169,13 @@ int grail_pull(struct grail *ge, int fd) | |||
| 168 | pthread_mutex_unlock(&x->mutex); | 169 | pthread_mutex_unlock(&x->mutex); |
| 169 | return 1; | 170 | return 1; |
| 170 | } | 171 | } |
| 172 | |||
| 173 | void grail_get_units(struct grail_coord *min, struct grail_coord *max, | ||
| 174 | const struct grail *ge) | ||
| 175 | { | ||
| 176 | const struct touch_dev_caps *caps = &ge->impl->dev.caps; | ||
| 177 | min->x = caps->info[TP_POS_X].minimum; | ||
| 178 | min->y = caps->info[TP_POS_Y].minimum; | ||
| 179 | max->x = caps->info[TP_POS_X].maximum; | ||
| 180 | max->y = caps->info[TP_POS_Y].maximum; | ||
| 181 | } | ||
diff --git a/src/grail-gestures.c b/src/grail-gestures.c index 5ab12a8..e1bf622 100644 --- a/src/grail-gestures.c +++ b/src/grail-gestures.c | |||
| @@ -119,12 +119,14 @@ static int move_update(struct filter_model *m, float val) | |||
| 119 | return m->active; | 119 | return m->active; |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | void gru_init_motion(struct grail *ge, const struct touch_dev_caps *caps) | 122 | void gru_init_motion(struct grail *ge) |
| 123 | { | 123 | { |
| 124 | struct gesture_recognizer *gru = ge->gru; | 124 | struct gesture_recognizer *gru = ge->gru; |
| 125 | struct move_model *state = &gru->move; | 125 | struct move_model *state = &gru->move; |
| 126 | float x = caps->info[TP_POS_X].maximum - caps->info[TP_POS_X].minimum; | 126 | struct grail_coord min, max; |
| 127 | float y = caps->info[TP_POS_Y].maximum - caps->info[TP_POS_Y].minimum; | 127 | grail_get_units(&min, &max, ge); |
| 128 | float x = max.x - min.x; | ||
| 129 | float y = max.y - min.y; | ||
| 128 | float r = sqrt(x * x + y * y); | 130 | float r = sqrt(x * x + y * y); |
| 129 | state->x.fuzz = x / SN_MOVE; | 131 | state->x.fuzz = x / SN_MOVE; |
| 130 | state->y.fuzz = y / SN_MOVE; | 132 | state->y.fuzz = y / SN_MOVE; |
diff --git a/src/grail-gestures.h b/src/grail-gestures.h index 57204ad..663d357 100644 --- a/src/grail-gestures.h +++ b/src/grail-gestures.h | |||
| @@ -43,8 +43,7 @@ struct move_model { | |||
| 43 | grail_time_t time; | 43 | grail_time_t time; |
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | void gru_init_motion(struct grail *ge, | 46 | void gru_init_motion(struct grail *ge); |
| 47 | const struct touch_dev_caps *caps); | ||
| 48 | void gru_motion(struct grail *ge, | 47 | void gru_motion(struct grail *ge, |
| 49 | const struct touch_frame *frame); | 48 | const struct touch_frame *frame); |
| 50 | void gru_event(struct grail *ge, int gid, | 49 | void gru_event(struct grail *ge, int gid, |
diff --git a/src/grail-recognizer.c b/src/grail-recognizer.c index bed704e..587a12a 100644 --- a/src/grail-recognizer.c +++ b/src/grail-recognizer.c | |||
| @@ -27,14 +27,14 @@ | |||
| 27 | #include <malloc.h> | 27 | #include <malloc.h> |
| 28 | #include <errno.h> | 28 | #include <errno.h> |
| 29 | 29 | ||
| 30 | int gru_init(struct grail *ge, const struct touch_dev_caps *caps) | 30 | int gru_init(struct grail *ge) |
| 31 | { | 31 | { |
| 32 | struct gesture_recognizer *gru; | 32 | struct gesture_recognizer *gru; |
| 33 | gru = calloc(1, sizeof(struct gesture_recognizer)); | 33 | gru = calloc(1, sizeof(struct gesture_recognizer)); |
| 34 | if (!gru) | 34 | if (!gru) |
| 35 | return -ENOMEM; | 35 | return -ENOMEM; |
| 36 | ge->gru = gru; | 36 | ge->gru = gru; |
| 37 | gru_init_motion(ge, caps); | 37 | gru_init_motion(ge); |
| 38 | return 0; | 38 | return 0; |
| 39 | } | 39 | } |
| 40 | 40 | ||
diff --git a/src/grail-recognizer.h b/src/grail-recognizer.h index d3b24b3..8a5ac80 100644 --- a/src/grail-recognizer.h +++ b/src/grail-recognizer.h | |||
| @@ -37,7 +37,7 @@ struct gesture_recognizer { | |||
| 37 | struct tapping_model tapping; | 37 | struct tapping_model tapping; |
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | int gru_init(struct grail *ge, const struct touch_dev_caps *caps); | 40 | int gru_init(struct grail *ge); |
| 41 | void gru_recognize(struct grail *ge, const struct touch_frame *frame); | 41 | void gru_recognize(struct grail *ge, const struct touch_frame *frame); |
| 42 | void gru_destroy(struct grail *ge); | 42 | void gru_destroy(struct grail *ge); |
| 43 | 43 | ||
