summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-09-27 23:04:29 -0400
committera1xd <[email protected]>2020-09-27 23:04:29 -0400
commit85aefb4ba131521595e48fe1a25f4db9a69e71e6 (patch)
treef1c73a42b369f362a40ea251281d98ee02bf0a98 /common
parentadd os detection to installer (diff)
downloadrawaccel-85aefb4ba131521595e48fe1a25f4db9a69e71e6.tar.xz
rawaccel-85aefb4ba131521595e48fe1a25f4db9a69e71e6.zip
add arg checks in wrapper
minor changes to settings shape, requires driver reinstall add error handling to writer grapher changes: add prettier serialization + comments add elements for scale and separated limit/exp reset irrelevant (invisible) arg input before checks/write
Diffstat (limited to 'common')
-rw-r--r--common/accel-base.hpp16
-rw-r--r--common/accel-motivity.hpp2
-rw-r--r--common/accel-power.hpp2
-rw-r--r--common/rawaccel-settings.h3
-rw-r--r--common/rawaccel.hpp2
5 files changed, 12 insertions, 13 deletions
diff --git a/common/accel-base.hpp b/common/accel-base.hpp
index d536923..5106268 100644
--- a/common/accel-base.hpp
+++ b/common/accel-base.hpp
@@ -5,15 +5,13 @@ namespace rawaccel {
/// <summary> Struct to hold arguments for an acceleration function. </summary>
struct accel_args {
double offset = 0;
- double legacy_offset = 0;
+ bool legacy_offset = false;
double accel = 0;
+ double scale = 1;
double limit = 2;
double exponent = 2;
- double midpoint = 0;
- double power_scale = 1;
- double power_exp = 0.05;
+ double midpoint = 10;
double weight = 1;
- double rate = 0;
double scale_cap = 0;
double gain_cap = 0;
};
@@ -33,14 +31,16 @@ namespace rawaccel {
struct additive_accel : accel_val_base<Func> {
additive_accel(const accel_args& args) : accel_val_base(args) {
- legacy_offset = args.offset <= 0 && args.legacy_offset > 0;
- offset = legacy_offset ? args.legacy_offset : args.offset;
+ legacy_offset = args.legacy_offset;
+ offset = args.offset;
weight = args.weight;
}
inline double operator()(double speed) const {
double offset_speed = speed - offset;
- return offset_speed > 0 ? ( legacy_offset ? 1 + fn.legacy_offset(offset_speed) * weight : 1 + fn(offset_speed) * weight) : 1;
+ if (offset_speed <= 0) return 1;
+ if (legacy_offset) return 1 + fn.legacy_offset(offset_speed) * weight;
+ return 1 + fn(offset_speed) * weight;
}
};
diff --git a/common/accel-motivity.hpp b/common/accel-motivity.hpp
index a37d1ce..f88320b 100644
--- a/common/accel-motivity.hpp
+++ b/common/accel-motivity.hpp
@@ -23,7 +23,7 @@ namespace rawaccel {
double subtractive_constant;
motivity_impl(const accel_args& args) :
- rate(pow(10,args.rate)), limit(2*log10(args.limit)), midpoint(log10(args.midpoint))
+ rate(pow(10,args.accel)), limit(2*log10(args.limit)), midpoint(log10(args.midpoint))
{
subtractive_constant = limit / 2;
}
diff --git a/common/accel-power.hpp b/common/accel-power.hpp
index 1abfdd1..5d0c451 100644
--- a/common/accel-power.hpp
+++ b/common/accel-power.hpp
@@ -12,7 +12,7 @@ namespace rawaccel {
double exponent;
power_impl(const accel_args& args) :
- scale(args.power_scale), exponent(args.power_exp)
+ scale(args.scale), exponent(args.exponent)
{}
inline double operator()(double speed) const {
diff --git a/common/rawaccel-settings.h b/common/rawaccel-settings.h
index 1a513ac..aeb89e8 100644
--- a/common/rawaccel-settings.h
+++ b/common/rawaccel-settings.h
@@ -7,6 +7,7 @@ namespace rawaccel {
using milliseconds = double;
inline constexpr milliseconds WRITE_DELAY = 1000;
+ inline constexpr milliseconds DEFAULT_TIME_MIN = 0.4;
enum class accel_mode {
linear, classic, natural, naturalgain, power, motivity, noaccel
@@ -18,7 +19,7 @@ namespace rawaccel {
vec2<accel_mode> modes = { accel_mode::noaccel, accel_mode::noaccel };
vec2<accel_args> argsv;
vec2d sens = { 1, 1 };
- milliseconds time_min = 0.4;
+ milliseconds time_min = DEFAULT_TIME_MIN;
};
}
diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp
index 14db883..d325abe 100644
--- a/common/rawaccel.hpp
+++ b/common/rawaccel.hpp
@@ -16,8 +16,6 @@
namespace rawaccel {
- using milliseconds = double;
-
/// <summary> Struct to hold vector rotation details. </summary>
struct rotator {