summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-07-08 12:05:36 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-07-09 12:48:44 +1000
commitb908e070e9a81e5ab6fa7840ce085a330a2c7eac (patch)
tree31ddc5d7bcdf87a19146ef62308a3360a51109eb
parent066092a04fd2a9419c392575cd1675d91c550d8c (diff)
downloadlibinput-b908e070e9a81e5ab6fa7840ce085a330a2c7eac.tar.gz
filter: use a separate variable for the final accel factor
velocity is in unit/ms, the threshold is in units/ms. Once we divide velocity/threshold, we're not in units/ms anymore but have a unitless factor. Use a separate variable to avoid confusion. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--src/filter.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/filter.c b/src/filter.c
index 7db78bae..4b2bbadd 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -335,6 +335,7 @@ pointer_accel_profile_smooth_simple(struct motion_filter *filter,
double threshold = DEFAULT_THRESHOLD; /* units/ms */
double accel = DEFAULT_ACCELERATION; /* unitless factor */
double smooth_accel_coefficient; /* unitless factor */
+ double factor; /* unitless factor */
if (threshold < 1.0)
threshold = 1.0;
@@ -349,12 +350,12 @@ pointer_accel_profile_smooth_simple(struct motion_filter *filter,
if (velocity <= threshold)
return 1.0;
- velocity /= threshold;
- if (velocity >= accel)
+ factor = velocity/threshold;
+ if (factor >= accel)
return accel;
- /* Velocity is between 1.0 and accel, scale this to 0.0 - 1.0 */
- velocity = (velocity - 1.0) / (accel - 1.0);
- smooth_accel_coefficient = calc_penumbral_gradient(velocity);
+ /* factor is between 1.0 and accel, scale this to 0.0 - 1.0 */
+ factor = (factor - 1.0) / (accel - 1.0);
+ smooth_accel_coefficient = calc_penumbral_gradient(factor);
return 1.0 + (smooth_accel_coefficient * (accel - 1.0));
}