diff --git a/src/filter-private.h b/src/filter-private.h index f5e8b7f7..eaf84eda 100644 --- a/src/filter-private.h +++ b/src/filter-private.h @@ -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); diff --git a/src/filter.c b/src/filter.c index f92b9fdc..674b439b 100644 --- a/src/filter.c +++ b/src/filter.c @@ -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, diff --git a/src/filter.h b/src/filter.h index fd36da49..c8ade07d 100644 --- a/src/filter.h +++ b/src/filter.h @@ -34,11 +34,33 @@ 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);