[PATCH libinput 05/23] filter: pass trackers to calculate_velocity
Peter Hutterer
peter.hutterer at who-t.net
Thu Apr 12 06:34:31 UTC 2018
So the function to calculate the velocity is easier to call from other sites.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/filter-private.h | 3 +++
src/filter.c | 11 +++++------
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/filter-private.h b/src/filter-private.h
index afe17c2c..ec87a849 100644
--- a/src/filter-private.h
+++ b/src/filter-private.h
@@ -81,6 +81,9 @@ feed_trackers(struct pointer_trackers *trackers,
struct pointer_tracker *
tracker_by_offset(struct pointer_trackers *trackers, unsigned int offset);
+double
+calculate_velocity(struct pointer_trackers *trackers, uint64_t time);
+
/* Convert speed/velocity from units/us to units/ms */
static inline double
v_us2ms(double units_per_us)
diff --git a/src/filter.c b/src/filter.c
index 5700128b..3670c38f 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -262,10 +262,9 @@ calculate_velocity_after_timeout(struct pointer_tracker *tracker,
* past, moving into a different direction or having too much of a velocity
* change between events.
*/
-static double
-calculate_velocity(struct pointer_accelerator *accel, uint64_t time)
+double
+calculate_velocity(struct pointer_trackers *trackers, uint64_t time)
{
- struct pointer_trackers *trackers = &accel->trackers;
struct pointer_tracker *tracker;
double velocity;
double result = 0.0;
@@ -277,7 +276,7 @@ calculate_velocity(struct pointer_accelerator *accel, uint64_t time)
/* Find least recent vector within a timelimit, maximum velocity diff
* and direction threshold. */
- for (offset = 1; offset < accel->trackers.ntrackers; offset++) {
+ for (offset = 1; offset < trackers->ntrackers; offset++) {
tracker = tracker_by_offset(trackers, offset);
/* Bug: time running backwards */
@@ -394,7 +393,7 @@ calculate_acceleration_factor(struct pointer_accelerator *accel,
double accel_factor;
feed_trackers(&accel->trackers, unaccelerated, time);
- velocity = calculate_velocity(accel, time);
+ velocity = calculate_velocity(&accel->trackers, time);
accel_factor = calculate_acceleration(accel,
data,
velocity,
@@ -546,7 +545,7 @@ accelerator_filter_x230(struct motion_filter *filter,
delta_normalized.y = unaccelerated.y;
feed_trackers(&accel->trackers, &delta_normalized, time);
- velocity = calculate_velocity(accel, time);
+ velocity = calculate_velocity(&accel->trackers, time);
accel_factor = calculate_acceleration(accel,
data,
velocity,
--
2.14.3
More information about the wayland-devel
mailing list