summaryrefslogtreecommitdiff
path: root/common/accel-logarithm.hpp
diff options
context:
space:
mode:
authorJacobPalecki <[email protected]>2020-09-21 14:20:18 -0700
committerGitHub <[email protected]>2020-09-21 14:20:18 -0700
commit4ec16a2ff35e0e910a13f92713d56d317b24e790 (patch)
treec4aead24d52e3002cfd3282ddd697a3766de405a /common/accel-logarithm.hpp
parentMerge pull request #20 from JacobPalecki/GUI (diff)
parentx/y diff sens works (diff)
downloadrawaccel-4ec16a2ff35e0e910a13f92713d56d317b24e790.tar.xz
rawaccel-4ec16a2ff35e0e910a13f92713d56d317b24e790.zip
Merge pull request #21 from JacobPalecki/GUI
GUI: Icon, Separate X/Y sens mode, some fixes
Diffstat (limited to 'common/accel-logarithm.hpp')
-rw-r--r--common/accel-logarithm.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/common/accel-logarithm.hpp b/common/accel-logarithm.hpp
new file mode 100644
index 0000000..044d23c
--- /dev/null
+++ b/common/accel-logarithm.hpp
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <math.h>
+
+#include "accel-base.hpp"
+
+namespace rawaccel {
+
+ /// <summary> Struct to hold sigmoid (s-shaped) gain implementation. </summary>
+ struct logarithm_impl {
+ double rate;
+ double offset;
+ double additive_const;
+
+ logarithm_impl (const accel_args& args) :
+ rate(args.rate), offset (args.offset) {
+ additive_const = offset * rate;
+ }
+
+ inline double operator()(double speed) const {
+ double scaled_speed = rate * speed + 1;
+ double base_speed = speed + offset;
+
+ return (scaled_speed * log(scaled_speed) + additive_const ) / ( rate * base_speed) - 1;
+ }
+
+ inline double legacy_offset(double speed) const { return operator()(speed); }
+ };
+
+ using accel_logarithm = additive_accel<logarithm_impl>;
+
+}