mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-09 14:30:17 +01:00
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:
parent
cea13bb494
commit
5f123a1dbb
1 changed files with 2 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue