mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-27 23:10:07 +01:00
filter: revamp the touchpad's acceleration code
The previous code had three main issues: * acceleration kicked in too early, so even slow movements were accelerated * acceleration kicked in too quickly, there was only a very narrow window where we would have less than the max acceleration factor * the max accel factor was too low for fast movements, so they still fell short of expectations This patch revamps most of the acceleration though it keeps the basic shape of the acceleration curve. * The threshold is increased significantly so that faster movement still map to the finger movement. Acceleration doesn't kick in until we get to something that's really fast like a flick. * The incline is dropped, so acceleration kicks in slower than before, i.e. the difference between the first speed that is accelerated and the speed that reaches the maximum is higher than before. * The maximum acceleration is increased so ever faster movements get ever faster. The max is effectively out of reach now, if you move fast enough to hit this speed, your cursor will end up on the moon anyway. A couple of other changes apply now too, specifically: * The incline remains the same regardless of the speed * The max accel factor remains the same regardless of the speed The caculated factor changes with the speed set so that the base speed changes with the desired speed. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
ec63ecd485
commit
ff31427e80
1 changed files with 11 additions and 14 deletions
25
src/filter.c
25
src/filter.c
|
|
@ -135,9 +135,9 @@ filter_get_type(struct motion_filter *filter)
|
|||
#define DEFAULT_INCLINE 1.1 /* unitless factor */
|
||||
|
||||
/* Touchpad acceleration */
|
||||
#define TOUCHPAD_DEFAULT_THRESHOLD 40 /* mm/s */
|
||||
#define TOUCHPAD_MINIMUM_THRESHOLD 20 /* mm/s */
|
||||
#define TOUCHPAD_ACCELERATION 2.0 /* unitless factor */
|
||||
#define TOUCHPAD_DEFAULT_THRESHOLD 254 /* mm/s */
|
||||
#define TOUCHPAD_THRESHOLD_RANGE 184 /* mm/s */
|
||||
#define TOUCHPAD_ACCELERATION 9.0 /* unitless factor */
|
||||
#define TOUCHPAD_INCLINE 0.011 /* unitless factor */
|
||||
|
||||
/* for the Lenovo x230 custom accel. do not touch */
|
||||
|
|
@ -521,19 +521,13 @@ touchpad_accelerator_set_speed(struct motion_filter *filter,
|
|||
/* Note: the numbers below are nothing but trial-and-error magic,
|
||||
don't read more into them other than "they mostly worked ok" */
|
||||
|
||||
/* delay when accel kicks in */
|
||||
/* adjust when accel kicks in */
|
||||
accel_filter->threshold = TOUCHPAD_DEFAULT_THRESHOLD -
|
||||
v_ms2us(0.25) * speed_adjustment;
|
||||
if (accel_filter->threshold < TOUCHPAD_MINIMUM_THRESHOLD)
|
||||
accel_filter->threshold = TOUCHPAD_MINIMUM_THRESHOLD;
|
||||
|
||||
/* adjust max accel factor */
|
||||
accel_filter->accel = TOUCHPAD_ACCELERATION + speed_adjustment * 1.5;
|
||||
|
||||
/* higher speed -> faster to reach max */
|
||||
accel_filter->incline = TOUCHPAD_INCLINE + speed_adjustment * 0.75;
|
||||
|
||||
TOUCHPAD_THRESHOLD_RANGE * speed_adjustment;
|
||||
accel_filter->accel = TOUCHPAD_ACCELERATION;
|
||||
accel_filter->incline = TOUCHPAD_INCLINE;
|
||||
filter->speed_adjustment = speed_adjustment;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -805,6 +799,9 @@ touchpad_accel_profile_linear(struct motion_filter *filter,
|
|||
/* Cap at the maximum acceleration factor */
|
||||
factor = min(max_accel, factor);
|
||||
|
||||
/* Scale everything depending on the acceleration set */
|
||||
factor *= 1 + 0.5 * filter->speed_adjustment;
|
||||
|
||||
return factor * TP_MAGIC_SLOWDOWN;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue