summaryrefslogtreecommitdiff
path: root/common/accel-naturalgain.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/accel-naturalgain.hpp')
-rw-r--r--common/accel-naturalgain.hpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/accel-naturalgain.hpp b/common/accel-naturalgain.hpp
index 646b2bb..03d749f 100644
--- a/common/accel-naturalgain.hpp
+++ b/common/accel-naturalgain.hpp
@@ -13,6 +13,11 @@ namespace rawaccel {
inline double operator()(double speed) const {
// f(x) = k((e^(-mx)-1)/mx + 1)
+ if (speed <= 0)
+ {
+ return 0;
+ }
+
double scaled_speed = rate * speed;
return limit * (((exp(-scaled_speed) - 1) / scaled_speed) + 1);
}