filter-touchpad: normalize for dpi on the touchpad-specific flat profile
authorsatrmb <10471-satrmb_true-email-is-private_contact-via-web@gitlab.freedesktop.org>
Sun, 29 May 2022 09:29:49 +0000 (11:29 +0200)
committersatrmb <10471-satrmb_true-email-is-private_contact-via-web@gitlab.freedesktop.org>
Sun, 29 May 2022 10:50:37 +0000 (12:50 +0200)
On mice, switching the acceleration profile to flat disables dpi normalization,
because high or even switchable dpi are generally major features of a
high-end mouse, and switching to flat acceleration indicates that the user
wants to reduce the effects of any cursor acceleration to a minimum.
Therefore we skip normalization there and let the user take full advantage
of their expensive hardware.

On touchpads, particularly those built into a laptop, users have to deal with
whatever hardware they have; touchpad dpi is an afterthought at best, or
a disaster at worst. Switching to the flat profile is more likely to be
about avoiding the non-linear acceleration curve of the adaptive profile.

Hence the flat profile for touchpads shouldn't copy what the one for mice does,
but rather use dpi normalization like the adaptive profile. This keeps flat
acceleration on low-resolution touchpads from dropping to unusably slow speeds.

Signed-off-by: satrmb <10471-satrmb@users.noreply.gitlab.freedesktop.org>
src/filter-touchpad-flat.c

index 658d5b5..e69e7af 100644 (file)
@@ -49,18 +49,19 @@ accelerator_filter_touchpad_flat(struct motion_filter *filter,
                        const struct device_float_coords *unaccelerated,
                        void *data, uint64_t time)
 {
-       struct touchpad_accelerator_flat *accel_filter =
+       struct touchpad_accelerator_flat *accel =
                (struct touchpad_accelerator_flat *)filter;
        double factor; /* unitless factor */
-       struct normalized_coords accelerated;
+       struct normalized_coords normalized;
 
        /* You want flat acceleration, you get flat acceleration for the
         * device */
-       factor = accel_filter->factor;
-       accelerated.x = TP_MAGIC_SLOWDOWN_FLAT * factor * unaccelerated->x;
-       accelerated.y = TP_MAGIC_SLOWDOWN_FLAT * factor * unaccelerated->y;
+       factor = accel->factor;
+       normalized = normalize_for_dpi(unaccelerated, accel->dpi);
+       normalized.x = TP_MAGIC_SLOWDOWN_FLAT * factor * normalized.x;
+       normalized.y = TP_MAGIC_SLOWDOWN_FLAT * factor * normalized.y;
 
-       return accelerated;
+       return normalized;
 }
 
 static struct normalized_coords