summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-07-23 00:55:10 -0700
committerJacob Palecki <[email protected]>2020-07-23 00:55:10 -0700
commite798ac56843a8e7b383433c479c802a4fb245a4c (patch)
tree66dc866f1de4fb5e2fadaf4d433a48e754446df9
parentMerge pull request #1 from JacobPalecki/PowerStyle (diff)
downloadrawaccel-e798ac56843a8e7b383433c479c802a4fb245a4c.tar.xz
rawaccel-e798ac56843a8e7b383433c479c802a4fb245a4c.zip
Fix offset for power mode, add scale factor for power mode
-rw-r--r--common/rawaccel-userspace.hpp3
-rw-r--r--common/rawaccel.hpp6
2 files changed, 6 insertions, 3 deletions
diff --git a/common/rawaccel-userspace.hpp b/common/rawaccel-userspace.hpp
index 862c55d..259f2cb 100644
--- a/common/rawaccel-userspace.hpp
+++ b/common/rawaccel-userspace.hpp
@@ -84,7 +84,8 @@ variables parse(int argc, char** argv) {
);
auto pow_mode = "power accel mode:" % (
clipp::command("power").set(accel_args.accel_mode, mode::power),
- accel_var
+ accel_var,
+ (clipp::option("scale") & clipp::number("num", accel_args.lim_exp)) % "scale factor"
);
auto accel_mode_exclusive = (lin_mode | classic_mode | nat_mode | log_mode | sig_mode | pow_mode);
diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp
index a40b85b..52402d5 100644
--- a/common/rawaccel.hpp
+++ b/common/rawaccel.hpp
@@ -74,7 +74,8 @@ struct accel_function {
double b = 0;
// the limit for natural and sigmoid modes,
- // or the exponent for classic mode
+ // the exponent for classic mode,
+ // or the scale factor for power mode
double k = 1;
vec2d weight = { 1, 1 };
@@ -98,7 +99,7 @@ struct accel_function {
break;
case mode::sigmoid: accel_val = k / (exp(-b * (speed - m)) + 1);
break;
- case mode::power: accel_val = pow(speed, b) - 1;
+ case mode::power: accel_val = b < 1 ? 0 : pow(speed, b*k) - 1;
break;
default:
break;
@@ -131,6 +132,7 @@ struct accel_function {
if (args.time_min <= 0) error("min time must be positive");
if (args.lim_exp <= 1) {
if (args.accel_mode == mode::classic) error("exponent must be greater than 1");
+ else if (args.accel_mode == mode::power) error("scale factor must be greater than 1");
else error("limit must be greater than 1");
}