mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 14:40:26 +01:00
Push the touchpad magic slowdown to the touchpad accel code
This way the unaccelerated deltas returned by libinput are correct. To maintain the current behavior we slow down the input speed by the magic factor and likewise the accelerated output speed. This produces virtually the same accelerated deltas as the previous code. The magic factor is applied to the default denominator for guessing a resolution based on the touchpad diagonal. We can't really get around this without having a resolution from the touchpad; meanwhile this produces virtually the same coordinates before/after. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
99d0c743f4
commit
522a42e9b4
6 changed files with 42 additions and 23 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
11
src/evdev.c
11
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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
21
src/filter.c
21
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue