diff options
| author | a1xd <[email protected]> | 2020-07-23 18:47:20 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-07-23 18:47:20 -0400 |
| commit | b16839b35b7fa32f091e6b12baf74fbd717349c2 (patch) | |
| tree | 6fc3710de4062b724e975f314d9bd5cca066fc74 | |
| parent | Merge pull request #1 from JacobPalecki/PowerStyle (diff) | |
| parent | increment k for power style (diff) | |
| download | rawaccel-b16839b35b7fa32f091e6b12baf74fbd717349c2.tar.xz rawaccel-b16839b35b7fa32f091e6b12baf74fbd717349c2.zip | |
Merge pull request #2 from JacobPalecki/PowerStyle
Fix offset for power mode, add scale factor for power mode
| -rw-r--r-- | common/rawaccel-userspace.hpp | 3 | ||||
| -rw-r--r-- | common/rawaccel.hpp | 7 |
2 files changed, 7 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..a60fe1c 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 = (speed_offset > 0 && speed < 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"); } @@ -139,6 +141,7 @@ struct accel_function { b = args.accel; k = args.lim_exp - 1; if (args.accel_mode == mode::natural) b /= k; + if (args.accel_mode == mode::power) k++; speed_offset = args.offset; weight = args.weight; |