mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-26 01:40:08 +01:00
accel_profile_smooth_simple: Cleanup
Cleanup the code a bit, and make sure accel is at least 1.0 . Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
f2dfbc0b82
commit
4da6dd52a4
1 changed files with 12 additions and 9 deletions
21
src/filter.c
21
src/filter.c
|
|
@ -336,20 +336,23 @@ pointer_accel_profile_smooth_simple(struct motion_filter *filter,
|
|||
double accel = DEFAULT_ACCELERATION;
|
||||
double smooth_accel_coefficient;
|
||||
|
||||
if (threshold < 1.0)
|
||||
threshold = 1.0;
|
||||
if (accel < 1.0)
|
||||
accel = 1.0;
|
||||
|
||||
velocity *= DEFAULT_CONSTANT_ACCELERATION;
|
||||
|
||||
if (velocity < 1.0)
|
||||
return calc_penumbral_gradient(0.5 + velocity * 0.5) * 2.0 - 1.0;
|
||||
if (threshold < 1.0)
|
||||
threshold = 1.0;
|
||||
|
||||
if (velocity <= threshold)
|
||||
return 1;
|
||||
return 1.0;
|
||||
|
||||
velocity /= threshold;
|
||||
if (velocity >= accel) {
|
||||
if (velocity >= accel)
|
||||
return accel;
|
||||
} else {
|
||||
smooth_accel_coefficient =
|
||||
calc_penumbral_gradient(velocity / accel);
|
||||
return 1.0 + (smooth_accel_coefficient * (accel - 1.0));
|
||||
}
|
||||
|
||||
smooth_accel_coefficient = calc_penumbral_gradient(velocity / accel);
|
||||
return 1.0 + (smooth_accel_coefficient * (accel - 1.0));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue