[PATCH v3 1/4] filter: break out accel_profile_linear from pointer_accel_profile_linear

Benjamin Tissoires benjamin.tissoires at gmail.com
Thu Apr 16 11:41:33 PDT 2015


No functional code. Allows to reuse the linear filtering in other
acceleration profiles.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires at gmail.com>
---
no changes since v1

 src/filter.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/filter.c b/src/filter.c
index 962d74d..f7ff426 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -305,6 +305,20 @@ create_pointer_accelerator_filter(accel_profile_func_t profile)
 	return &filter->base;
 }
 
+static double
+accel_profile_linear(double speed_in,
+		     const double max_accel,
+		     const double threshold,
+		     const double incline)
+{
+	double s1, s2;
+
+	s1 = min(1, speed_in * 5);
+	s2 = 1 + (speed_in - threshold) * incline;
+
+	return min(max_accel, s2 > 1 ? s2 : s1);
+}
+
 double
 pointer_accel_profile_linear(struct motion_filter *filter,
 			     void *data,
@@ -314,15 +328,11 @@ pointer_accel_profile_linear(struct motion_filter *filter,
 	struct pointer_accelerator *accel_filter =
 		(struct pointer_accelerator *)filter;
 
-	double s1, s2;
 	const double max_accel = accel_filter->accel; /* unitless factor */
 	const double threshold = accel_filter->threshold; /* units/ms */
 	const double incline = accel_filter->incline;
 
-	s1 = min(1, speed_in * 5);
-	s2 = 1 + (speed_in - threshold) * incline;
-
-	return min(max_accel, s2 > 1 ? s2 : s1);
+	return accel_profile_linear(speed_in, max_accel, threshold, incline);
 }
 
 double
-- 
1.7.1



More information about the wayland-devel mailing list