From: Hans de Goede Date: Fri, 4 Jul 2014 15:16:25 +0000 (+0200) Subject: accel_profile_smooth_simple: Cleanup X-Git-Tag: 0.5.0~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4da6dd52a433e8ba0a954a0e36bc653cf86651bd;p=platform%2Fupstream%2Flibinput.git 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 Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- diff --git a/src/filter.c b/src/filter.c index 1762f98a..487669c5 100644 --- a/src/filter.c +++ b/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)); }