filter: calculate the time delta correctly

If the delta is 0, the distance is the number of units (within this ms). Delta
1 means velocity across 2 ms, etc.

Bonus: this doesn't return infinite speed anymore if we get more than one
event per ms. This can happen on any device approaching 1000Hz poll rate, but
definitely got triggered by the test suite.

Actual effect was limited, since we cap out acceleration at max_accel we just
hit this earlier and it stayed there.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Peter Hutterer 2015-03-19 11:33:55 +10:00
parent cea13bb494
commit 5f123a1dbb

View file

@ -138,9 +138,10 @@ static double
calculate_tracker_velocity(struct pointer_tracker *tracker, uint64_t time)
{
double distance;
double tdelta = time - tracker->time + 1;
distance = hypot(tracker->delta.x, tracker->delta.y);
return distance / (double)(time - tracker->time); /* units/ms */
return distance / tdelta; /* units/ms */
}
static double