From 34e37fc3bcb136063cd25bc3ab124cb78644e39b Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 31 Aug 2010 09:41:10 +0200 Subject: Do not compute velocity until enough data is available The first few ticks since a configuration change are not really suited for velocity computation, so move the speed computation over to the periodic sampling point. Signed-off-by: Henrik Rydberg --- src/grail-gestures.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/grail-gestures.c b/src/grail-gestures.c index a50ddca..4bd83b3 100644 --- a/src/grail-gestures.c +++ b/src/grail-gestures.c @@ -120,9 +120,9 @@ static void move_update(struct move_model *m, int i, float x, grail_time_t t) float dt = t - fm->sample_ms; fm->raw_delta = x - fm->value; fm->action_delta = fm->raw_delta; - fm->velocity = dt > EPS ? (x - fm->sample) / dt : 0; fm->value = x; if (dt > SAMPLE_MS) { + fm->velocity = (x - fm->sample) / dt; fm->sample = x; fm->sample_ms = t; } -- cgit v1.2.3