diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index d0311a4c..b7760c23 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -29,7 +29,9 @@ #include "evdev-mt-touchpad.h" -#define DEFAULT_ACCEL_NUMERATOR 1200.0 +/* Number found by trial-and error, seems to be 1200, divided by the + * TP_MAGIC_SLOWDOWN in filter.c */ +#define DEFAULT_ACCEL_NUMERATOR 3000.0 #define DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR 700.0 #define DEFAULT_TRACKPOINT_ACTIVITY_TIMEOUT 500 /* ms */ @@ -974,18 +976,6 @@ tp_init_accel(struct tp_dispatch *tp, double diagonal) if (res_x > 1 && res_y > 1) { tp->accel.x_scale_coeff = (DEFAULT_MOUSE_DPI/25.4) / res_x; tp->accel.y_scale_coeff = (DEFAULT_MOUSE_DPI/25.4) / res_y; - - /* FIXME: once normalized, touchpads see the same - acceleration as mice. that is technically correct but - subjectively wrong, we expect a touchpad to be a lot - slower than a mouse. - For now, apply a magic factor here until this is - fixed in the actual filter code. - */ - { - tp->accel.x_scale_coeff *= TP_MAGIC_SLOWDOWN; - tp->accel.y_scale_coeff *= TP_MAGIC_SLOWDOWN; - } } else { /* * For touchpads where the driver does not provide resolution, fall @@ -995,7 +985,9 @@ tp_init_accel(struct tp_dispatch *tp, double diagonal) tp->accel.y_scale_coeff = DEFAULT_ACCEL_NUMERATOR / diagonal; } - if (evdev_device_init_pointer_acceleration(tp->device) == -1) + if (evdev_device_init_pointer_acceleration( + tp->device, + touchpad_accel_profile_linear) == -1) return -1; return 0; diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 04acf214..9980f900 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -34,10 +34,8 @@ #define VENDOR_ID_APPLE 0x5ac -/* Touchpad slowdown factor, see the FIXME in tp_init_accel() */ -#define TP_MAGIC_SLOWDOWN 0.4 /* Convert mm to a distance normalized to DEFAULT_MOUSE_DPI */ -#define TP_MM_TO_DPI_NORMALIZED(mm) (DEFAULT_MOUSE_DPI/25.4 * TP_MAGIC_SLOWDOWN * mm) +#define TP_MM_TO_DPI_NORMALIZED(mm) (DEFAULT_MOUSE_DPI/25.4 * mm) enum touchpad_event { TOUCHPAD_EVENT_NONE = 0, diff --git a/src/evdev.c b/src/evdev.c index 570c4361..ff7bc371 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1266,11 +1266,10 @@ evdev_accel_config_get_default_speed(struct libinput_device *device) } int -evdev_device_init_pointer_acceleration(struct evdev_device *device) +evdev_device_init_pointer_acceleration(struct evdev_device *device, + accel_profile_func_t profile) { - device->pointer.filter = - create_pointer_accelerator_filter( - pointer_accel_profile_linear); + device->pointer.filter = create_pointer_accelerator_filter(profile); if (!device->pointer.filter) return -1; @@ -1575,7 +1574,9 @@ evdev_configure_device(struct evdev_device *device) if (udev_tags & EVDEV_UDEV_TAG_MOUSE) { if (!libevdev_has_event_code(evdev, EV_ABS, ABS_X) && !libevdev_has_event_code(evdev, EV_ABS, ABS_Y) && - evdev_device_init_pointer_acceleration(device) == -1) + evdev_device_init_pointer_acceleration( + device, + pointer_accel_profile_linear) == -1) return -1; device->seat_caps |= EVDEV_DEVICE_POINTER; diff --git a/src/evdev.h b/src/evdev.h index caafd53a..ddaab9fc 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -32,6 +32,7 @@ #include "libinput-private.h" #include "timer.h" +#include "filter.h" /* The HW DPI rate we normalize to before calculating pointer acceleration */ #define DEFAULT_MOUSE_DPI 1000 @@ -212,7 +213,8 @@ evdev_device_create(struct libinput_seat *seat, struct udev_device *device); int -evdev_device_init_pointer_acceleration(struct evdev_device *device); +evdev_device_init_pointer_acceleration(struct evdev_device *device, + accel_profile_func_t profile); struct evdev_dispatch * evdev_touchpad_create(struct evdev_device *device); diff --git a/src/filter.c b/src/filter.c index 72ef7609..306a2fe6 100644 --- a/src/filter.c +++ b/src/filter.c @@ -327,3 +327,24 @@ pointer_accel_profile_linear(struct motion_filter *filter, return min(max_accel, s2 > 1 ? s2 : s1); } + +double +touchpad_accel_profile_linear(struct motion_filter *filter, + void *data, + double speed_in, + uint64_t time) +{ + /* Once normalized, touchpads see the same + acceleration as mice. that is technically correct but + subjectively wrong, we expect a touchpad to be a lot + slower than a mouse. Apply a magic factor here and proceed + as normal. */ + const double TP_MAGIC_SLOWDOWN = 0.4; + double speed_out; + + speed_in *= TP_MAGIC_SLOWDOWN; + + speed_out = pointer_accel_profile_linear(filter, data, speed_in, time); + + return speed_out * TP_MAGIC_SLOWDOWN; +} diff --git a/src/filter.h b/src/filter.h index 9e903303..f23b691b 100644 --- a/src/filter.h +++ b/src/filter.h @@ -64,4 +64,9 @@ pointer_accel_profile_linear(struct motion_filter *filter, void *data, double speed_in, uint64_t time); +double +touchpad_accel_profile_linear(struct motion_filter *filter, + void *data, + double speed_in, + uint64_t time); #endif /* FILTER_H */