[PATCH libinput 1/3] filter: pass last_velocity as argument

Peter Hutterer peter.hutterer at who-t.net
Sun May 31 23:13:21 PDT 2015


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>
---
 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;
-- 
2.4.1



More information about the wayland-devel mailing list