summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-09-28 10:02:04 -0400
committera1xd <[email protected]>2020-09-28 10:02:04 -0400
commit0d663cd6729160c610e3c6374f71097f8bb2af8b (patch)
tree92566357b0c0548d842c56287752d238dcdac805
parentupdate build config (diff)
downloadrawaccel-0d663cd6729160c610e3c6374f71097f8bb2af8b.tar.xz
rawaccel-0d663cd6729160c610e3c6374f71097f8bb2af8b.zip
disallow negative weight with non-additive types
-rw-r--r--common/accel-base.hpp2
-rw-r--r--wrapper/wrapper.cpp9
2 files changed, 7 insertions, 4 deletions
diff --git a/common/accel-base.hpp b/common/accel-base.hpp
index 5106268..67a1b8f 100644
--- a/common/accel-base.hpp
+++ b/common/accel-base.hpp
@@ -48,7 +48,7 @@ namespace rawaccel {
struct nonadditive_accel : accel_val_base<Func> {
nonadditive_accel(const accel_args& args) : accel_val_base(args) {
- if (args.weight != 0) weight = args.weight;
+ if (args.weight > 0) weight = args.weight;
}
inline double operator()(double speed) const {
diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp
index 72ebdc7..3d77fc1 100644
--- a/wrapper/wrapper.cpp
+++ b/wrapper/wrapper.cpp
@@ -137,9 +137,12 @@ error_list_t^ get_accel_errors(AccelMode mode, AccelArgs^ args)
if (args->acceleration > 1 && is_mode(am::natural, am::naturalgain))
error_list->Add("acceleration can not be greater than 1");
- else if (args->acceleration < 0)
- error_list->Add("acceleration can not be negative, use a negative weight to compensate");
-
+ else if (args->acceleration < 0) {
+ bool additive = m < am::power;
+ if (additive) error_list->Add("acceleration can not be negative, use a negative weight to compensate");
+ else error_list->Add("acceleration can not be negative");
+ }
+
if (args->scale <= 0)
error_list->Add("scale must be positive");