filter: pass last_velocity as argument
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 30 Apr 2015 05:23:34 +0000 (15:23 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 1 Jun 2015 23:03:07 +0000 (09:03 +1000)
Let the caller set the various fields, here we just calculate stuff.
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
src/filter.c

index 0cdcb63e87029a4bfa176e18d9cf989e43653a0c..fe862155386adac80002d96b5423898592ccc799 100644 (file)
@@ -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;