filter: add a "filter_constant" hook to the filter interface
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 17 Aug 2015 06:32:20 +0000 (16:32 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 19 Aug 2015 21:57:14 +0000 (07:57 +1000)
For when we need to apply some transformation to the data but it shouldn't be
acceleration. Example use are touchpad coordinates, even when not
accelerating, we still want to apply the magic slowdown.

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

index f5e8b7f7128bea08304ed0ff734c325ebc7f1e5b..eaf84edad2588511731eadee51347f9365799667 100644 (file)
@@ -33,6 +33,10 @@ struct motion_filter_interface {
                           struct motion_filter *filter,
                           const struct normalized_coords *unaccelerated,
                           void *data, uint64_t time);
+       struct normalized_coords (*filter_constant)(
+                          struct motion_filter *filter,
+                          const struct normalized_coords *unaccelerated,
+                          void *data, uint64_t time);
        void (*restart)(struct motion_filter *filter,
                        void *data,
                        uint64_t time);
index f92b9fdc8961f44a2b190cf4c030781b91ebc071..674b439bc6a6d73fd47b83f62c306a7994abf339 100644 (file)
@@ -64,6 +64,14 @@ filter_dispatch(struct motion_filter *filter,
        return filter->interface->filter(filter, unaccelerated, data, time);
 }
 
+struct normalized_coords
+filter_dispatch_constant(struct motion_filter *filter,
+                        const struct normalized_coords *unaccelerated,
+                        void *data, uint64_t time)
+{
+       return filter->interface->filter_constant(filter, unaccelerated, data, time);
+}
+
 void
 filter_restart(struct motion_filter *filter,
               void *data, uint64_t time)
@@ -319,6 +327,14 @@ accelerator_filter(struct motion_filter *filter,
        return accelerated;
 }
 
+static struct normalized_coords
+accelerator_filter_noop(struct motion_filter *filter,
+                       const struct normalized_coords *unaccelerated,
+                       void *data, uint64_t time)
+{
+       return *unaccelerated;
+}
+
 static struct normalized_coords
 accelerator_filter_low_dpi(struct motion_filter *filter,
                           const struct normalized_coords *unaccelerated,
@@ -673,6 +689,7 @@ trackpoint_accel_profile(struct motion_filter *filter,
 
 struct motion_filter_interface accelerator_interface = {
        .filter = accelerator_filter,
+       .filter_constant = accelerator_filter_noop,
        .restart = accelerator_restart,
        .destroy = accelerator_destroy,
        .set_speed = accelerator_set_speed,
@@ -719,6 +736,7 @@ create_pointer_accelerator_filter_linear(int dpi)
 
 struct motion_filter_interface accelerator_interface_low_dpi = {
        .filter = accelerator_filter_low_dpi,
+       .filter_constant = accelerator_filter_noop,
        .restart = accelerator_restart,
        .destroy = accelerator_destroy,
        .set_speed = accelerator_set_speed,
@@ -756,6 +774,7 @@ create_pointer_accelerator_filter_touchpad(int dpi)
 
 struct motion_filter_interface accelerator_interface_x230 = {
        .filter = accelerator_filter_x230,
+       .filter_constant = accelerator_filter_noop,
        .restart = accelerator_restart,
        .destroy = accelerator_destroy,
        .set_speed = accelerator_set_speed,
@@ -793,6 +812,7 @@ create_pointer_accelerator_filter_lenovo_x230(int dpi)
 
 struct motion_filter_interface accelerator_interface_trackpoint = {
        .filter = accelerator_filter_trackpoint,
+       .filter_constant = accelerator_filter_noop,
        .restart = accelerator_restart,
        .destroy = accelerator_destroy,
        .set_speed = accelerator_set_speed,
index fd36da49f2151aced490918e37c1dd5456ad8607..c8ade07d6c51aaafe350a9264a06aa24379a43ae 100644 (file)
 
 struct motion_filter;
 
+/**
+ * Accelerate the given coordinates.
+ * Takes a set of unaccelerated deltas and accelerates them based on the
+ * current and previous motion.
+ *
+ * This is a superset of filter_dispatch_constant()
+ *
+ * @see filter_dispatch_constant
+ */
 struct normalized_coords
 filter_dispatch(struct motion_filter *filter,
                const struct normalized_coords *unaccelerated,
                void *data, uint64_t time);
 
+/**
+ * Apply constant motion filters, but no acceleration.
+ *
+ * Takes a set of unaccelerated deltas and applies any constant filters to
+ * it but does not accelerate the delta in the conventional sense.
+ *
+ * @see filter_dispatch
+ */
+struct normalized_coords
+filter_dispatch_constant(struct motion_filter *filter,
+                        const struct normalized_coords *unaccelerated,
+                        void *data, uint64_t time);
+
 void
 filter_restart(struct motion_filter *filter,
               void *data, uint64_t time);