[PATCH libinput 1/3] filter: pass last_velocity as argument
Hans de Goede
hdegoede at redhat.com
Mon Jun 1 00:44:36 PDT 2015
Hi,
On 01-06-15 08:13, Peter Hutterer wrote:
> Let the caller set the various fields, here we just calculate stuff.
> No functional changes.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Tricky stuff, but the entire set LGTM:
Reviewed-by: Hans de Goede <hdegoede at redhat.com>
Regards,
Hans
> ---
> src/filter.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/src/filter.c b/src/filter.c
> index 0cdcb63..fe86215 100644
> --- a/src/filter.c
> +++ b/src/filter.c
> @@ -197,17 +197,20 @@ acceleration_profile(struct pointer_accelerator *accel,
>
> static double
> calculate_acceleration(struct pointer_accelerator *accel,
> - void *data, double velocity, uint64_t time)
> + void *data,
> + double velocity,
> + double last_velocity,
> + uint64_t time)
> {
> double factor;
>
> /* Use Simpson's rule to calculate the avarage acceleration between
> * the previous motion and the most recent. */
> factor = acceleration_profile(accel, data, velocity, time);
> - factor += acceleration_profile(accel, data, accel->last_velocity, time);
> + factor += acceleration_profile(accel, data, last_velocity, time);
> factor += 4.0 *
> acceleration_profile(accel, data,
> - (accel->last_velocity + velocity) / 2,
> + (last_velocity + velocity) / 2,
> time);
>
> factor = factor / 6.0;
> @@ -228,7 +231,11 @@ accelerator_filter(struct motion_filter *filter,
>
> feed_trackers(accel, unaccelerated, time);
> velocity = calculate_velocity(accel, time);
> - accel_value = calculate_acceleration(accel, data, velocity, time);
> + accel_value = calculate_acceleration(accel,
> + data,
> + velocity,
> + accel->last_velocity,
> + time);
>
> accelerated.x = accel_value * unaccelerated->x;
> accelerated.y = accel_value * unaccelerated->y;
>
More information about the wayland-devel
mailing list