From a9a0e2c02bdd6e9dfdff523705e7afcb47e82adb Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 10 Aug 2010 14:40:08 +0100 Subject: Filter abs events by default in grail-gesture Also connect the timeout for press with the timeout of tapping. Signed-off-by: Henrik Rydberg --- src/gestures-tapping.c | 3 +-- src/grail-gestures.c | 6 +++++- src/grail-gestures.h | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src') 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; static const int TAP_CANCEL = 2; static const int TAP_MIN_GAP_MS = 25; -static const int TAP_MAX_GAP_MS = 300; static const int fm_mask = 0x03; @@ -66,7 +65,7 @@ int gru_tapping(struct grail *ge, } if (state->ntouch < 1 || state->ntouch > 5) state->status = TAP_CANCEL; - if (move->time - state->start > TAP_MAX_GAP_MS) + if (move->time - state->start > move->fm[FM_X].bar_ms) state->status = TAP_CANCEL; if (state->status == TAP_END && 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 @@ static const float FM_SN[DIM_FM] = { 1000, 1000, 200, 1000 }; static const float FM_BAR[DIM_FM] = { 50, 50, 30, 50 }; +static const grail_time_t FM_BAR_MS[DIM_FM] = { 300, 300, 10000, 10000 }; static const grail_time_t SAMPLE_MS = 10; static const float EPS = 1e-5; @@ -105,6 +106,7 @@ static void move_reset(struct move_model *m, int i, float x, grail_time_t t) fm->velocity = 0; fm->value = x; fm->original = x; + fm->original_ms = t; fm->sample = x; fm->sample_ms = t; m->tickle &= ~(1 << i); @@ -130,7 +132,8 @@ static void move_update(struct move_model *m, int i, float x, grail_time_t t) if (m->active & (1 << i)) return; fm->action_delta = x - fm->original; - if (fabs(fm->action_delta) > fm->bar) + if (fabs(fm->action_delta) > fm->bar || + t - fm->original_ms > fm->bar_ms) m->active |= (1 << i); else fm->action_delta = 0; @@ -151,6 +154,7 @@ void gru_init_motion(struct grail *ge) for (i = 0; i < DIM_FM; i++) { m->fm[i].fuzz = D[i] / FM_SN[i]; m->fm[i].bar = D[i] / FM_BAR[i]; + m->fm[i].bar_ms = FM_BAR_MS[i]; } } 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 { float velocity; float value; float original; + float sample; float fuzz; float bar; - float sample; + grail_time_t original_ms; grail_time_t sample_ms; + grail_time_t bar_ms; }; struct move_model { -- cgit v1.2.3