mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-11 06:58:13 +02:00
filter: add a configurable speed interface
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
87c88d6a86
commit
198384e69f
3 changed files with 37 additions and 1 deletions
|
|
@ -32,9 +32,12 @@ struct motion_filter_interface {
|
||||||
struct motion_params *motion,
|
struct motion_params *motion,
|
||||||
void *data, uint64_t time);
|
void *data, uint64_t time);
|
||||||
void (*destroy)(struct motion_filter *filter);
|
void (*destroy)(struct motion_filter *filter);
|
||||||
|
bool (*set_speed)(struct motion_filter *filter,
|
||||||
|
double speed);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct motion_filter {
|
struct motion_filter {
|
||||||
|
double speed; /* normalized [-1, 1] */
|
||||||
struct motion_filter_interface *interface;
|
struct motion_filter_interface *interface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
28
src/filter.c
28
src/filter.c
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
@ -49,6 +50,19 @@ filter_destroy(struct motion_filter *filter)
|
||||||
filter->interface->destroy(filter);
|
filter->interface->destroy(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
filter_set_speed(struct motion_filter *filter,
|
||||||
|
double speed)
|
||||||
|
{
|
||||||
|
return filter->interface->set_speed(filter, speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
filter_get_speed(struct motion_filter *filter)
|
||||||
|
{
|
||||||
|
return filter->speed;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default parameters for pointer acceleration profiles.
|
* Default parameters for pointer acceleration profiles.
|
||||||
*/
|
*/
|
||||||
|
|
@ -237,9 +251,21 @@ accelerator_destroy(struct motion_filter *filter)
|
||||||
free(accel);
|
free(accel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
accelerator_set_speed(struct motion_filter *filter,
|
||||||
|
double speed)
|
||||||
|
{
|
||||||
|
assert(speed >= -1.0 && speed <= 1.0);
|
||||||
|
|
||||||
|
filter->speed = speed;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
struct motion_filter_interface accelerator_interface = {
|
struct motion_filter_interface accelerator_interface = {
|
||||||
accelerator_filter,
|
accelerator_filter,
|
||||||
accelerator_destroy
|
accelerator_destroy,
|
||||||
|
accelerator_set_speed,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct motion_filter *
|
struct motion_filter *
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct motion_params {
|
struct motion_params {
|
||||||
|
|
@ -40,6 +41,12 @@ filter_dispatch(struct motion_filter *filter,
|
||||||
void
|
void
|
||||||
filter_destroy(struct motion_filter *filter);
|
filter_destroy(struct motion_filter *filter);
|
||||||
|
|
||||||
|
bool
|
||||||
|
filter_set_speed(struct motion_filter *filter,
|
||||||
|
double speed);
|
||||||
|
double
|
||||||
|
filter_get_speed(struct motion_filter *filter);
|
||||||
|
|
||||||
typedef double (*accel_profile_func_t)(struct motion_filter *filter,
|
typedef double (*accel_profile_func_t)(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double velocity,
|
double velocity,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue