[PATCH libinput 07/13] filter: drop the now-generic trackpoint and low-dpi filter functions

Peter Hutterer peter.hutterer at who-t.net
Mon Dec 19 05:20:58 UTC 2016


The profile is what is still special about those two, the filter itself does
the same as the default filter (calculate velocity, calculate accel factor,
apply to delta).

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/filter.c | 80 ++++++------------------------------------------------------
 1 file changed, 7 insertions(+), 73 deletions(-)

diff --git a/src/filter.c b/src/filter.c
index 5da8136..abbfb48 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -403,9 +403,9 @@ calculate_acceleration_factor(struct pointer_accelerator *accel,
  * motion
  */
 static struct normalized_coords
-accelerator_filter(struct motion_filter *filter,
-		   const struct device_float_coords *unaccelerated,
-		   void *data, uint64_t time)
+accelerator_filter_generic(struct motion_filter *filter,
+			   const struct device_float_coords *unaccelerated,
+			   void *data, uint64_t time)
 {
 	struct pointer_accelerator *accel =
 		(struct pointer_accelerator *) filter;
@@ -446,72 +446,6 @@ accelerator_filter_noop(struct motion_filter *filter,
 	return normalize_for_dpi(unaccelerated, accel->dpi);
 }
 
-/**
- * Low-dpi filter that handles events from devices with less than the
- * default dpi.
- *
- * @param filter The acceleration filter
- * @param unaccelerated The raw delta in the device's dpi
- * @param data Caller-specific data
- * @param time Current time in µs
- *
- * @return An accelerated tuple of coordinates representing normalized
- * motion
- */
-static struct normalized_coords
-accelerator_filter_low_dpi(struct motion_filter *filter,
-			   const struct device_float_coords *unaccelerated,
-			   void *data, uint64_t time)
-{
-	struct pointer_accelerator *accel =
-		(struct pointer_accelerator *) filter;
-	double accel_value; /* unitless factor */
-	struct normalized_coords accelerated;
-
-	/* Input is already in device-native DPI, nothing else needed */
-	accel_value = calculate_acceleration_factor(accel,
-						    unaccelerated,
-						    data,
-						    time);
-	accelerated.x = accel_value * unaccelerated->x;
-	accelerated.y = accel_value * unaccelerated->y;
-
-	return accelerated;
-}
-
-/**
- * Custom filter that applies the trackpoint's constant acceleration, if any.
- *
- * @param filter The acceleration filter
- * @param unaccelerated The raw delta in the device's dpi
- * @param data Caller-specific data
- * @param time Current time in µs
- *
- * @return An accelerated tuple of coordinates representing normalized
- * motion
- */
-static struct normalized_coords
-accelerator_filter_trackpoint(struct motion_filter *filter,
-			      const struct device_float_coords *unaccelerated,
-			      void *data, uint64_t time)
-{
-	struct pointer_accelerator *accel =
-		(struct pointer_accelerator *) filter;
-	double accel_value; /* unitless factor */
-	struct normalized_coords accelerated;
-
-	/* Nothing special to do here, data is already in device dpi */
-	accel_value = calculate_acceleration_factor(accel,
-						    unaccelerated,
-						    data,
-						    time);
-
-	accelerated.x = accel_value * unaccelerated->x;
-	accelerated.y = accel_value * unaccelerated->y;
-
-	return accelerated;
-}
-
 static struct normalized_coords
 accelerator_filter_x230(struct motion_filter *filter,
 			const struct device_float_coords *raw,
@@ -943,7 +877,7 @@ trackpoint_accel_profile(struct motion_filter *filter,
 
 struct motion_filter_interface accelerator_interface = {
 	.type = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE,
-	.filter = accelerator_filter,
+	.filter = accelerator_filter_generic,
 	.filter_constant = accelerator_filter_noop,
 	.restart = accelerator_restart,
 	.destroy = accelerator_destroy,
@@ -990,7 +924,7 @@ create_pointer_accelerator_filter_linear(int dpi)
 
 struct motion_filter_interface accelerator_interface_low_dpi = {
 	.type = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE,
-	.filter = accelerator_filter_low_dpi,
+	.filter = accelerator_filter_generic,
 	.filter_constant = accelerator_filter_noop,
 	.restart = accelerator_restart,
 	.destroy = accelerator_destroy,
@@ -1014,7 +948,7 @@ create_pointer_accelerator_filter_linear_low_dpi(int dpi)
 
 struct motion_filter_interface accelerator_interface_touchpad = {
 	.type = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE,
-	.filter = accelerator_filter,
+	.filter = accelerator_filter_generic,
 	.filter_constant = touchpad_constant_filter,
 	.restart = accelerator_restart,
 	.destroy = accelerator_destroy,
@@ -1076,7 +1010,7 @@ create_pointer_accelerator_filter_lenovo_x230(int dpi)
 
 struct motion_filter_interface accelerator_interface_trackpoint = {
 	.type = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE,
-	.filter = accelerator_filter_trackpoint,
+	.filter = accelerator_filter_generic,
 	.filter_constant = accelerator_filter_noop,
 	.restart = accelerator_restart,
 	.destroy = accelerator_destroy,
-- 
2.9.3



More information about the wayland-devel mailing list