diff options
| -rw-r--r-- | src/grail-gestures.c | 8 | ||||
| -rw-r--r-- | src/grail-inserter.c | 20 |
2 files changed, 16 insertions, 12 deletions
diff --git a/src/grail-gestures.c b/src/grail-gestures.c index 95c1b57..1e89074 100644 --- a/src/grail-gestures.c +++ b/src/grail-gestures.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | ****************************************************************************/ | 21 | ****************************************************************************/ |
| 22 | 22 | ||
| 23 | #include "grail-recognizer.h" | 23 | #include "grail-recognizer.h" |
| 24 | #include "grail-impl.h" | ||
| 24 | #include <math.h> | 25 | #include <math.h> |
| 25 | 26 | ||
| 26 | static const float FM_SN[DIM_FM] = { 1000, 1000, 200, 1000 }; | 27 | static const float FM_SN[DIM_FM] = { 1000, 1000, 200, 1000 }; |
| @@ -141,14 +142,13 @@ static void move_update(struct move_model *m, int i, float x, grail_time_t t) | |||
| 141 | 142 | ||
| 142 | void gru_init_motion(struct grail *ge) | 143 | void gru_init_motion(struct grail *ge) |
| 143 | { | 144 | { |
| 145 | struct touch_caps *caps = &ge->impl->dev.caps; | ||
| 144 | struct gesture_recognizer *gru = ge->gru; | 146 | struct gesture_recognizer *gru = ge->gru; |
| 145 | struct move_model *m = &gru->move; | 147 | struct move_model *m = &gru->move; |
| 146 | struct grail_coord min, max; | ||
| 147 | float D[DIM_FM]; | 148 | float D[DIM_FM]; |
| 148 | int i; | 149 | int i; |
| 149 | grail_get_units(ge, &min, &max); | 150 | D[FM_X] = caps->max_x - caps->min_x; |
| 150 | D[FM_X] = max.x - min.x; | 151 | D[FM_Y] = caps->max_y - caps->min_y; |
| 151 | D[FM_Y] = max.y - min.y; | ||
| 152 | D[FM_R] = sqrt(D[FM_X] * D[FM_X] + D[FM_Y] * D[FM_Y]); | 152 | D[FM_R] = sqrt(D[FM_X] * D[FM_X] + D[FM_Y] * D[FM_Y]); |
| 153 | D[FM_A] = 2 * M_PI; | 153 | D[FM_A] = 2 * M_PI; |
| 154 | for (i = 0; i < DIM_FM; i++) { | 154 | for (i = 0; i < DIM_FM; i++) { |
diff --git a/src/grail-inserter.c b/src/grail-inserter.c index 36ab570..2e5e7af 100644 --- a/src/grail-inserter.c +++ b/src/grail-inserter.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | ****************************************************************************/ | 21 | ****************************************************************************/ |
| 22 | 22 | ||
| 23 | #include "grail-inserter.h" | 23 | #include "grail-inserter.h" |
| 24 | #include "grail-impl.h" | ||
| 24 | #include <malloc.h> | 25 | #include <malloc.h> |
| 25 | #include <string.h> | 26 | #include <string.h> |
| 26 | #include <errno.h> | 27 | #include <errno.h> |
| @@ -373,15 +374,18 @@ void grail_set_bbox(struct grail *ge, | |||
| 373 | const struct grail_coord *tmin, | 374 | const struct grail_coord *tmin, |
| 374 | const struct grail_coord *tmax) | 375 | const struct grail_coord *tmax) |
| 375 | { | 376 | { |
| 377 | struct touch_caps *caps = &ge->impl->dev.caps; | ||
| 376 | struct gesture_inserter *gin = ge->gin; | 378 | struct gesture_inserter *gin = ge->gin; |
| 377 | struct grail_coord dmin, dmax; | 379 | double tx, ty, dx, dy, sx, sy; |
| 378 | double sx, sy; | 380 | tx = tmax->x - tmin->x; |
| 379 | grail_get_units(ge, &dmin, &dmax); | 381 | ty = tmax->y - tmin->y; |
| 380 | sx = (tmax->x - tmin->x) / (dmax.x - dmin.x); | 382 | dx = caps->max_x - caps->min_x; |
| 381 | sy = (tmax->y - tmin->y) / (dmax.y - dmin.y); | 383 | dy = caps->max_y - caps->min_y; |
| 384 | sx = tx / dx; | ||
| 385 | sy = ty / dy; | ||
| 382 | gin->scale_x = sx; | 386 | gin->scale_x = sx; |
| 383 | gin->scale_y = sy; | 387 | gin->scale_y = sy; |
| 384 | gin->scale_r = sqrt((sx * sx + sy * sy) / 2); | 388 | gin->scale_r = sqrt((tx * tx + ty * ty) / (dx * dx + dy * dy)); |
| 385 | gin->trans_x = tmin->x - dmin.x * sx; | 389 | gin->trans_x = tmin->x - caps->min_x * sx; |
| 386 | gin->trans_y = tmin->y - dmin.y * sy; | 390 | gin->trans_y = tmin->y - caps->min_y * sy; |
| 387 | } | 391 | } |
