[PATCH libinput 1/3] filter: break out accel_profile_linear from pointer_accel_profile_linear
Benjamin Tissoires
benjamin.tissoires at gmail.com
Thu Apr 9 10:30:37 PDT 2015
No functional change. Allows to reuse the linear filtering in other
acceleration profiles.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires at gmail.com>
---
src/filter.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/filter.c b/src/filter.c
index 033201f..92e6802 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -303,6 +303,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,
@@ -312,15 +326,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