summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-07-23 00:01:47 -0400
committerGitHub <[email protected]>2020-07-23 00:01:47 -0400
commit15db796e717c38875dc8061f357e53bfa4ee7b20 (patch)
tree51f94b33c7beba43b379124c45516563497cebe8
parentadd a license (diff)
parentAdded source-style power acceleration option (diff)
downloadrawaccel-15db796e717c38875dc8061f357e53bfa4ee7b20.tar.xz
rawaccel-15db796e717c38875dc8061f357e53bfa4ee7b20.zip
Merge pull request #1 from JacobPalecki/PowerStyle
Added source-style power acceleration option
-rw-r--r--common/rawaccel-userspace.hpp6
-rw-r--r--common/rawaccel.hpp4
2 files changed, 8 insertions, 2 deletions
diff --git a/common/rawaccel-userspace.hpp b/common/rawaccel-userspace.hpp
index 80fcecc..862c55d 100644
--- a/common/rawaccel-userspace.hpp
+++ b/common/rawaccel-userspace.hpp
@@ -82,8 +82,12 @@ variables parse(int argc, char** argv) {
limit_var,
(clipp::required("midpoint") & clipp::number("speed", accel_args.midpoint)) % "midpoint"
);
+ auto pow_mode = "power accel mode:" % (
+ clipp::command("power").set(accel_args.accel_mode, mode::power),
+ accel_var
+ );
- auto accel_mode_exclusive = (lin_mode | classic_mode | nat_mode | log_mode | sig_mode);
+ auto accel_mode_exclusive = (lin_mode | classic_mode | nat_mode | log_mode | sig_mode | pow_mode);
auto accel_opts = "mode-independent accel options:" % (opt_offset, opt_cap, opt_weight, opt_tmin);
bool help = false;
diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp
index 1483e67..a40b85b 100644
--- a/common/rawaccel.hpp
+++ b/common/rawaccel.hpp
@@ -8,7 +8,7 @@
namespace rawaccel {
-enum class mode { noaccel, linear, classic, natural, logarithmic, sigmoid };
+enum class mode { noaccel, linear, classic, natural, logarithmic, sigmoid, power };
struct rotator {
vec2d rot_vec = { 1, 0 };
@@ -98,6 +98,8 @@ 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;
+ break;
default:
break;
}