diff options
author | Hans de Goede <hdegoede@redhat.com> | 2014-07-07 13:54:38 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2014-07-07 13:54:38 +0200 |
commit | 110e81147d5d5b1f9fb880b1e5243e45936ec861 (patch) | |
tree | 22563c7e512a387d627cc2c00f870fcc59664bdf | |
parent | b6086853f6f48615f858e91d26499ffd63b5ab5b (diff) |
accel_profile_smooth_simple: Stretch alternative 1
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | src/filter.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/filter.c b/src/filter.c index ed965ff..991f6aa 100644 --- a/src/filter.c +++ b/src/filter.c @@ -397,8 +397,8 @@ pointer_accel_profile_smooth_simple(struct motion_filter *filter, double threshold = accel_filter->threshold; double accel = accel_filter->accel; double smooth_accel_coefficient; - /* Increasing this makes reaching max accel take longer */ - const double stretch = 2.0; + /* Increasing this makes reaching max accel take longer (min 1.0) */ + const double stretch = 3.0; if (threshold < 1.0) threshold = 1.0; @@ -414,11 +414,17 @@ pointer_accel_profile_smooth_simple(struct motion_filter *filter, return 1.0; velocity /= threshold; - if (velocity >= (accel * stretch)) + if (velocity < accel) { + /* Velocity is 1.0 - accel, scale this to 0.0 - 0.5 */ + velocity = 0.5 * (velocity - 1.0) / (accel - 1.0); + } else if (velocity < (accel * stretch)) { + /* Velocity is accel - (accel * stretch), + scale this to 0.5 - 1.0 */ + velocity = 0.5 + 0.5 * + (velocity - accel) / (accel * (stretch - 1.0)); + } else return accel; - /* Velocity is 1.0 - (accel * stretch), scale this to 0.0 - 1.0 */ - velocity = (velocity - 1.0) / (accel * stretch - 1.0); smooth_accel_coefficient = calc_penumbral_gradient(velocity); return 1.0 + (smooth_accel_coefficient * (accel - 1.0)); } |