mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-27 12:40:12 +01:00
filter: add a "filter_constant" hook to the filter interface
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>
This commit is contained in:
parent
e4fd60ce5e
commit
d8c37a94c0
3 changed files with 46 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
20
src/filter.c
20
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,
|
||||
|
|
|
|||
22
src/filter.h
22
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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue