summaryrefslogtreecommitdiff
path: root/common/accel-base.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/accel-base.hpp')
-rw-r--r--common/accel-base.hpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/common/accel-base.hpp b/common/accel-base.hpp
index 560c0b5..714162f 100644
--- a/common/accel-base.hpp
+++ b/common/accel-base.hpp
@@ -5,6 +5,7 @@ namespace rawaccel {
/// <summary> Struct to hold arguments for an acceleration function. </summary>
struct accel_args {
double offset = 0;
+ double legacy_offset = 0;
double accel = 0;
double limit = 2;
double exponent = 2;
@@ -19,6 +20,7 @@ namespace rawaccel {
template <typename Func>
struct accel_val_base {
+ bool legacy_offset = false;
double offset = 0;
double weight = 1;
Func fn;
@@ -31,14 +33,15 @@ namespace rawaccel {
struct additive_accel : accel_val_base<Func> {
additive_accel(const accel_args& args) : accel_val_base(args) {
- offset = args.offset;
+ legacy_offset = args.offset <= 0 && args.legacy_offset > 0;
+ offset = legacy_offset ? args.legacy_offset : args.offset;
weight = args.weight;
}
inline double operator()(double speed) const {
- return 1 + fn(maxsd(speed - offset, 0)) * weight;
+ double offset_speed = speed - offset;
+ return offset_speed > 0 ? ( legacy_offset ? 1 + fn.legacy_offset(offset_speed) * weight : 1 + fn(offset_speed) ) : 1;
}
-
};
template <typename Func>