From 16dc4df3d438142ae378c9c6983585d06e0c6a33 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Mon, 29 Mar 2021 17:14:49 -0400 Subject: refactor common/settings only driver compiles remove accel-base types merge linear + classic move gain cap logic into classic impl, cap is now set in terms of output use cap/limit to determine negation remove weight, add replacement for power mode only remove legacy offset option remove naturalgain mode add legacy mode flag naturalgain -> natural natural -> natural + legacy flag add dpi setting and more accel args + defaults (prep for ips mode) replace output speed cap with input cap --- common/accel-natural.hpp | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'common/accel-natural.hpp') diff --git a/common/accel-natural.hpp b/common/accel-natural.hpp index 03700c1..2939dbd 100644 --- a/common/accel-natural.hpp +++ b/common/accel-natural.hpp @@ -2,34 +2,52 @@ #include -#include "accel-base.hpp" +#include "rawaccel-settings.h" namespace rawaccel { /// Struct to hold "natural" (vanishing difference) acceleration implementation. - struct natural_impl { - double rate; - double limit; + struct natural_base { double offset; + double accel; + double limit; - natural_impl(const accel_args& args) : - rate(args.accel), limit(args.limit - 1), offset(args.offset) + natural_base(const accel_args& args) : + offset(args.offset), + limit(args.limit - 1) { - rate /= limit; + accel = args.accel_natural / fabs(limit); } + }; - inline double operator()(double speed) const { - // f(x) = k(1-e^(-mx)) - double base_speed = speed + offset; - return limit * (1 - ((exp(-rate * speed) * speed + offset) / base_speed)); - } + struct natural_legacy : natural_base { + + double operator()(double x) const { + if (x <= offset) return 1; - inline double legacy_offset(double speed) const { - return limit - (limit * exp(-rate * speed)); + double offset_x = x - offset; + double decay = exp(-accel * offset_x); + return limit * (1 - (decay * offset_x + offset) / x) + 1; } + using natural_base::natural_base; }; - using accel_natural = additive_accel; + struct natural : natural_base { + double constant; + + double operator()(double x) const { + if (x <= offset) return 1; + + double offset_x = x - offset; + double decay = exp(-accel * offset_x); + double output = limit * (offset_x + decay / accel) + constant; + return output / x + 1; + } + + natural(const accel_args& args) : + natural_base(args), + constant(-limit / accel) {} + }; } -- cgit v1.2.3 From ed0bbc22681681a16b7d45b05133c38a0b82006f Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Mon, 29 Mar 2021 18:01:20 -0400 Subject: formatting + file renames --- common/accel-natural.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'common/accel-natural.hpp') diff --git a/common/accel-natural.hpp b/common/accel-natural.hpp index 2939dbd..31ed190 100644 --- a/common/accel-natural.hpp +++ b/common/accel-natural.hpp @@ -1,8 +1,8 @@ #pragma once -#include +#include "rawaccel-base.hpp" -#include "rawaccel-settings.h" +#include namespace rawaccel { @@ -22,7 +22,8 @@ namespace rawaccel { struct natural_legacy : natural_base { - double operator()(double x) const { + double operator()(double x) const + { if (x <= offset) return 1; double offset_x = x - offset; @@ -36,7 +37,8 @@ namespace rawaccel { struct natural : natural_base { double constant; - double operator()(double x) const { + double operator()(double x) const + { if (x <= offset) return 1; double offset_x = x - offset; -- cgit v1.2.3 From 258fcd3bd236a787f07d7dac2049be524d86cb75 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 6 Apr 2021 23:11:20 -0700 Subject: Fix natural legacy algorithm, rename accelNatural to decayRate --- common/accel-natural.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/accel-natural.hpp') diff --git a/common/accel-natural.hpp b/common/accel-natural.hpp index 31ed190..1f18e0d 100644 --- a/common/accel-natural.hpp +++ b/common/accel-natural.hpp @@ -16,7 +16,7 @@ namespace rawaccel { offset(args.offset), limit(args.limit - 1) { - accel = args.accel_natural / fabs(limit); + accel = args.decay_rate / fabs(limit); } }; @@ -28,7 +28,7 @@ namespace rawaccel { double offset_x = x - offset; double decay = exp(-accel * offset_x); - return limit * (1 - (decay * offset_x + offset) / x) + 1; + return limit * (1 - (decay)) + 1; } using natural_base::natural_base; -- cgit v1.2.3 From c06d88e602983b650d4a61b8fb248be3e15d822b Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Tue, 6 Apr 2021 23:34:13 -0700 Subject: natural legacy algorithm was correct, leave as it was --- common/accel-natural.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/accel-natural.hpp') diff --git a/common/accel-natural.hpp b/common/accel-natural.hpp index 1f18e0d..28e17c2 100644 --- a/common/accel-natural.hpp +++ b/common/accel-natural.hpp @@ -28,7 +28,7 @@ namespace rawaccel { double offset_x = x - offset; double decay = exp(-accel * offset_x); - return limit * (1 - (decay)) + 1; + return limit * (1 - (decay * offset_x + offset) / x) + 1; } using natural_base::natural_base; -- cgit v1.2.3 From c55d1bfd01147fa014ac07d4b03ef3cad8427ae6 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Thu, 8 Apr 2021 02:30:01 -0400 Subject: optimize a bit/refactor modify --- common/accel-natural.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common/accel-natural.hpp') diff --git a/common/accel-natural.hpp b/common/accel-natural.hpp index 28e17c2..8d25351 100644 --- a/common/accel-natural.hpp +++ b/common/accel-natural.hpp @@ -26,8 +26,8 @@ namespace rawaccel { { if (x <= offset) return 1; - double offset_x = x - offset; - double decay = exp(-accel * offset_x); + double offset_x = offset - x; + double decay = exp(accel * offset_x); return limit * (1 - (decay * offset_x + offset) / x) + 1; } @@ -41,8 +41,8 @@ namespace rawaccel { { if (x <= offset) return 1; - double offset_x = x - offset; - double decay = exp(-accel * offset_x); + double offset_x = offset - x; + double decay = exp(accel * offset_x); double output = limit * (offset_x + decay / accel) + constant; return output / x + 1; } -- cgit v1.2.3 From e3fe51dde5afed99a393e3b1b1f611fde011d9f3 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Thu, 8 Apr 2021 12:38:08 -0400 Subject: fix some things --- common/accel-natural.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/accel-natural.hpp') diff --git a/common/accel-natural.hpp b/common/accel-natural.hpp index 8d25351..9f76d1a 100644 --- a/common/accel-natural.hpp +++ b/common/accel-natural.hpp @@ -28,7 +28,7 @@ namespace rawaccel { double offset_x = offset - x; double decay = exp(accel * offset_x); - return limit * (1 - (decay * offset_x + offset) / x) + 1; + return limit * (1 - (offset - decay * offset_x) / x) + 1; } using natural_base::natural_base; @@ -43,7 +43,7 @@ namespace rawaccel { double offset_x = offset - x; double decay = exp(accel * offset_x); - double output = limit * (offset_x + decay / accel) + constant; + double output = limit * (decay / accel - offset_x) + constant; return output / x + 1; } -- cgit v1.2.3