diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-08-10 14:40:08 +0100 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-08-10 15:04:18 +0100 |
| commit | a9a0e2c02bdd6e9dfdff523705e7afcb47e82adb (patch) | |
| tree | 27776cdb622750ab0610322d9e17877d34e11eca | |
| parent | 1e8aa1edc281132efa485f41741193af8ee13c8e (diff) | |
Filter abs events by default in grail-gesture
Also connect the timeout for press with the timeout of tapping.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
| -rw-r--r-- | src/gestures-tapping.c | 3 | ||||
| -rw-r--r-- | src/grail-gestures.c | 6 | ||||
| -rw-r--r-- | src/grail-gestures.h | 4 | ||||
| -rw-r--r-- | test/grail-gesture.c | 1 |
4 files changed, 10 insertions, 4 deletions
diff --git a/src/gestures-tapping.c b/src/gestures-tapping.c index d8a580f..0deacf8 100644 --- a/src/gestures-tapping.c +++ b/src/gestures-tapping.c | |||
| @@ -28,7 +28,6 @@ static const int TAP_END = 1; | |||
| 28 | static const int TAP_CANCEL = 2; | 28 | static const int TAP_CANCEL = 2; |
| 29 | 29 | ||
| 30 | static const int TAP_MIN_GAP_MS = 25; | 30 | static const int TAP_MIN_GAP_MS = 25; |
| 31 | static const int TAP_MAX_GAP_MS = 300; | ||
| 32 | 31 | ||
| 33 | static const int fm_mask = 0x03; | 32 | static const int fm_mask = 0x03; |
| 34 | 33 | ||
| @@ -66,7 +65,7 @@ int gru_tapping(struct grail *ge, | |||
| 66 | } | 65 | } |
| 67 | if (state->ntouch < 1 || state->ntouch > 5) | 66 | if (state->ntouch < 1 || state->ntouch > 5) |
| 68 | state->status = TAP_CANCEL; | 67 | state->status = TAP_CANCEL; |
| 69 | if (move->time - state->start > TAP_MAX_GAP_MS) | 68 | if (move->time - state->start > move->fm[FM_X].bar_ms) |
| 70 | state->status = TAP_CANCEL; | 69 | state->status = TAP_CANCEL; |
| 71 | if (state->status == TAP_END && | 70 | if (state->status == TAP_END && |
| 72 | move->time - state->start < TAP_MIN_GAP_MS) | 71 | move->time - state->start < TAP_MIN_GAP_MS) |
diff --git a/src/grail-gestures.c b/src/grail-gestures.c index c743544..1d49765 100644 --- a/src/grail-gestures.c +++ b/src/grail-gestures.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | static const float FM_SN[DIM_FM] = { 1000, 1000, 200, 1000 }; | 26 | static const float FM_SN[DIM_FM] = { 1000, 1000, 200, 1000 }; |
| 27 | static const float FM_BAR[DIM_FM] = { 50, 50, 30, 50 }; | 27 | static const float FM_BAR[DIM_FM] = { 50, 50, 30, 50 }; |
| 28 | static const grail_time_t FM_BAR_MS[DIM_FM] = { 300, 300, 10000, 10000 }; | ||
| 28 | static const grail_time_t SAMPLE_MS = 10; | 29 | static const grail_time_t SAMPLE_MS = 10; |
| 29 | static const float EPS = 1e-5; | 30 | static const float EPS = 1e-5; |
| 30 | 31 | ||
| @@ -105,6 +106,7 @@ static void move_reset(struct move_model *m, int i, float x, grail_time_t t) | |||
| 105 | fm->velocity = 0; | 106 | fm->velocity = 0; |
| 106 | fm->value = x; | 107 | fm->value = x; |
| 107 | fm->original = x; | 108 | fm->original = x; |
| 109 | fm->original_ms = t; | ||
| 108 | fm->sample = x; | 110 | fm->sample = x; |
| 109 | fm->sample_ms = t; | 111 | fm->sample_ms = t; |
| 110 | m->tickle &= ~(1 << i); | 112 | m->tickle &= ~(1 << i); |
| @@ -130,7 +132,8 @@ static void move_update(struct move_model *m, int i, float x, grail_time_t t) | |||
| 130 | if (m->active & (1 << i)) | 132 | if (m->active & (1 << i)) |
| 131 | return; | 133 | return; |
| 132 | fm->action_delta = x - fm->original; | 134 | fm->action_delta = x - fm->original; |
| 133 | if (fabs(fm->action_delta) > fm->bar) | 135 | if (fabs(fm->action_delta) > fm->bar || |
| 136 | t - fm->original_ms > fm->bar_ms) | ||
| 134 | m->active |= (1 << i); | 137 | m->active |= (1 << i); |
| 135 | else | 138 | else |
| 136 | fm->action_delta = 0; | 139 | fm->action_delta = 0; |
| @@ -151,6 +154,7 @@ void gru_init_motion(struct grail *ge) | |||
| 151 | for (i = 0; i < DIM_FM; i++) { | 154 | for (i = 0; i < DIM_FM; i++) { |
| 152 | m->fm[i].fuzz = D[i] / FM_SN[i]; | 155 | m->fm[i].fuzz = D[i] / FM_SN[i]; |
| 153 | m->fm[i].bar = D[i] / FM_BAR[i]; | 156 | m->fm[i].bar = D[i] / FM_BAR[i]; |
| 157 | m->fm[i].bar_ms = FM_BAR_MS[i]; | ||
| 154 | } | 158 | } |
| 155 | } | 159 | } |
| 156 | 160 | ||
diff --git a/src/grail-gestures.h b/src/grail-gestures.h index 658b548..5b8f7d7 100644 --- a/src/grail-gestures.h +++ b/src/grail-gestures.h | |||
| @@ -42,10 +42,12 @@ struct filter_model { | |||
| 42 | float velocity; | 42 | float velocity; |
| 43 | float value; | 43 | float value; |
| 44 | float original; | 44 | float original; |
| 45 | float sample; | ||
| 45 | float fuzz; | 46 | float fuzz; |
| 46 | float bar; | 47 | float bar; |
| 47 | float sample; | 48 | grail_time_t original_ms; |
| 48 | grail_time_t sample_ms; | 49 | grail_time_t sample_ms; |
| 50 | grail_time_t bar_ms; | ||
| 49 | }; | 51 | }; |
| 50 | 52 | ||
| 51 | struct move_model { | 53 | struct move_model { |
diff --git a/test/grail-gesture.c b/test/grail-gesture.c index 8e34f84..c559661 100644 --- a/test/grail-gesture.c +++ b/test/grail-gesture.c | |||
| @@ -102,6 +102,7 @@ int main(int argc, char *argv[]) | |||
| 102 | fprintf(stderr, "error: could not open touch device\n"); | 102 | fprintf(stderr, "error: could not open touch device\n"); |
| 103 | return -1; | 103 | return -1; |
| 104 | } | 104 | } |
| 105 | grail_filter_abs_events(&ge, 1); | ||
| 105 | loop_device(&ge, fd); | 106 | loop_device(&ge, fd); |
| 106 | grail_close(&ge, fd); | 107 | grail_close(&ge, fd); |
| 107 | 108 | ||
