summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-19 21:24:59 -0700
committerJacob Palecki <[email protected]>2020-09-19 21:24:59 -0700
commit7622f542daa27db332334d0af25faa9651a1c831 (patch)
treea10bce066ea6454ccec60309c5af2adec0a9aa4e /common
parentFix chart scaling for DPIs < 1200 (diff)
downloadrawaccel-7622f542daa27db332334d0af25faa9651a1c831.tar.xz
rawaccel-7622f542daa27db332334d0af25faa9651a1c831.zip
log sigmoid sens done
Diffstat (limited to 'common')
-rw-r--r--common/accel-experimentone.hpp33
-rw-r--r--common/common.vcxitems1
-rw-r--r--common/rawaccel-settings.h2
-rw-r--r--common/rawaccel.hpp3
4 files changed, 38 insertions, 1 deletions
diff --git a/common/accel-experimentone.hpp b/common/accel-experimentone.hpp
new file mode 100644
index 0000000..7d21b58
--- /dev/null
+++ b/common/accel-experimentone.hpp
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <math.h>
+
+#include "accel-base.hpp"
+
+namespace rawaccel {
+
+ /// <summary> Struct to hold sigmoid (s-shaped) gain implementation. </summary>
+ struct experimentone_impl {
+ double rate;
+ double limit;
+ double midpoint;
+ double subtractive_constant;
+
+ experimentone_impl(const accel_args& args) :
+ rate(pow(10,args.rate)), limit(2*log10(args.limit)), midpoint(log10(args.midpoint))
+ {
+ subtractive_constant = limit / 2;
+ }
+
+ inline double operator()(double speed) const {
+ double log_speed = log10(speed);
+ return pow(10, limit / (exp(-rate * (log_speed - midpoint)) + 1) - subtractive_constant);
+
+ }
+
+ inline double legacy_offset(double speed) const { return operator()(speed); }
+ };
+
+ using accel_experimentone = nonadditive_accel<experimentone_impl>;
+
+}
diff --git a/common/common.vcxitems b/common/common.vcxitems
index fcd3ae8..21a58aa 100644
--- a/common/common.vcxitems
+++ b/common/common.vcxitems
@@ -16,6 +16,7 @@
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)accel-base.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)accel-classic.hpp" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)accel-experimentone.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)accel-linear.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)accel-logarithm.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)accel-natural.hpp" />
diff --git a/common/rawaccel-settings.h b/common/rawaccel-settings.h
index 8c483eb..db5e192 100644
--- a/common/rawaccel-settings.h
+++ b/common/rawaccel-settings.h
@@ -6,7 +6,7 @@
namespace rawaccel {
enum class accel_mode {
- linear, classic, natural, naturalgain, sigmoidgain, power, logarithm, noaccel
+ linear, classic, natural, naturalgain, sigmoidgain, power, logarithm, experimentone, noaccel
};
struct settings {
diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp
index 8819302..2914225 100644
--- a/common/rawaccel.hpp
+++ b/common/rawaccel.hpp
@@ -13,6 +13,7 @@
#include "accel-naturalgain.hpp"
#include "accel-power.hpp"
#include "accel-sigmoidgain.hpp"
+#include "accel-experimentone.hpp"
#include "accel-noaccel.hpp"
namespace rawaccel {
@@ -86,6 +87,7 @@ namespace rawaccel {
case accel_mode::sigmoidgain: return vis(var.u.sigmoidgain);
case accel_mode::power: return vis(var.u.power);
case accel_mode::logarithm: return vis(var.u.logarithm);
+ case accel_mode::experimentone: return vis(var.u.experimentone);
default: return vis(var.u.noaccel);
}
}
@@ -101,6 +103,7 @@ namespace rawaccel {
accel_sigmoidgain sigmoidgain;
accel_power power;
accel_logarithm logarithm;
+ accel_experimentone experimentone;
accel_noaccel noaccel = {};
} u = {};