summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2022-09-02 14:23:04 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2022-09-08 09:03:15 +1000
commit87c769f3f2d7e6a542c028262e9bb23baccbf95f (patch)
tree4f6a9485f7d2e04ae301f6ff71427dffd18ed210
parent9179acd6384c3d0ec7e4c15d38e1d054a370a0ee (diff)
downloadlibinput-87c769f3f2d7e6a542c028262e9bb23baccbf95f.tar.gz
filter: fix the mix of normalized vs device coordinates
No functional changes, this is just for improving readability and a leftover when some of these functions were used by multiple filters. This filter normalizes the data first, then applies the acceleration to the normalized values. So let's keep the data in normalized_coords structs and only drop to device_float_coords when we have to to use the tracker API. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/filter-mouse.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/filter-mouse.c b/src/filter-mouse.c
index 470175f2..18bb3d43 100644
--- a/src/filter-mouse.c
+++ b/src/filter-mouse.c
@@ -72,14 +72,20 @@ struct pointer_accelerator {
*/
static inline double
calculate_acceleration_factor(struct pointer_accelerator *accel,
- const struct device_float_coords *unaccelerated,
+ const struct normalized_coords *unaccelerated,
void *data,
uint64_t time)
{
- double velocity; /* units/us in device-native dpi*/
+ double velocity; /* units/us in normalized 1000dpi units*/
double accel_factor;
- trackers_feed(&accel->trackers, unaccelerated, time);
+ /* The trackers API need device_float_coords, but note that we have
+ * normalized coordinates */
+ const struct device_float_coords unaccel = {
+ .x = unaccelerated->x,
+ .y = unaccelerated->y,
+ };
+ trackers_feed(&accel->trackers, &unaccel, time);
velocity = trackers_velocity(&accel->trackers, time);
/* This will call into our pointer_accel_profile_linear() profile func */
accel_factor = calculate_acceleration_simpsons(&accel->base,
@@ -105,15 +111,15 @@ calculate_acceleration_factor(struct pointer_accelerator *accel,
* @return An accelerated tuple of coordinates representing accelerated
* motion, still in device units.
*/
-static struct device_float_coords
+static struct normalized_coords
accelerator_filter_generic(struct motion_filter *filter,
- const struct device_float_coords *unaccelerated,
+ const struct normalized_coords *unaccelerated,
void *data, uint64_t time)
{
struct pointer_accelerator *accel =
(struct pointer_accelerator *) filter;
double accel_value; /* unitless factor */
- struct device_float_coords accelerated;
+ struct normalized_coords accelerated;
accel_value = calculate_acceleration_factor(accel,
unaccelerated,
@@ -133,22 +139,16 @@ accelerator_filter_pre_normalized(struct motion_filter *filter,
{
struct pointer_accelerator *accel =
(struct pointer_accelerator *) filter;
- struct normalized_coords normalized;
- struct device_float_coords converted, accelerated;
+ struct normalized_coords normalized, accelerated;
/* Accelerate for normalized units and return normalized units.
API requires device_floats, so we just copy the bits around */
normalized = normalize_for_dpi(unaccelerated, accel->dpi);
- converted.x = normalized.x;
- converted.y = normalized.y;
-
accelerated = accelerator_filter_generic(filter,
- &converted,
+ &normalized,
data,
time);
- normalized.x = accelerated.x;
- normalized.y = accelerated.y;
- return normalized;
+ return accelerated;
}
/**