diff options
| author | Jacob Palecki <[email protected]> | 2020-07-29 01:10:29 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-07-29 01:10:29 -0700 |
| commit | 7963edee802d5a7b51f1867a5133857c403c8ef6 (patch) | |
| tree | 42995f07946acffefbf8adc22676e52f11b8faea | |
| parent | Separate accel implementations into files (diff) | |
| download | rawaccel-7963edee802d5a7b51f1867a5133857c403c8ef6.tar.xz rawaccel-7963edee802d5a7b51f1867a5133857c403c8ef6.zip | |
Inline methods for linking, and fix sens application bug
| -rw-r--r-- | common/accel_classic.cpp | 6 | ||||
| -rw-r--r-- | common/accel_linear.cpp | 6 | ||||
| -rw-r--r-- | common/accel_logarithmic.cpp | 6 | ||||
| -rw-r--r-- | common/accel_natural.cpp | 6 | ||||
| -rw-r--r-- | common/accel_noaccel.cpp | 6 | ||||
| -rw-r--r-- | common/accel_power.cpp | 6 | ||||
| -rw-r--r-- | common/accel_sigmoid.cpp | 6 | ||||
| -rw-r--r-- | common/accel_types.hpp | 2 | ||||
| -rw-r--r-- | common/rawaccel.hpp | 10 |
9 files changed, 29 insertions, 25 deletions
diff --git a/common/accel_classic.cpp b/common/accel_classic.cpp index e4e7ab9..323cd3b 100644 --- a/common/accel_classic.cpp +++ b/common/accel_classic.cpp @@ -6,15 +6,15 @@ #include "accel_types.hpp" namespace rawaccel { - accel_classic::accel_classic(accel_args args) + inline accel_classic::accel_classic(accel_args args) : accel_implentation(args) {} - double accel_classic::accelerate(double speed) { + inline double accel_classic::accelerate(double speed) { //f(x) = (mx)^k return pow(curve_constant_one * speed, curve_constant_two); } - void accel_classic::verify(accel_args args) { + inline void accel_classic::verify(accel_args args) { accel_implentation::verify(args); if (args.lim_exp <= 1) error("exponent must be greater than 1"); } diff --git a/common/accel_linear.cpp b/common/accel_linear.cpp index d12e798..307e33e 100644 --- a/common/accel_linear.cpp +++ b/common/accel_linear.cpp @@ -6,15 +6,15 @@ #include "accel_types.hpp" namespace rawaccel { - accel_linear::accel_linear(accel_args args) + inline accel_linear::accel_linear(accel_args args) : accel_implentation(args) {} - double accel_linear::accelerate(double speed) { + inline double accel_linear::accelerate(double speed) { //f(x) = mx return curve_constant_one * speed; } - void accel_linear::verify(accel_args args) { + inline void accel_linear::verify(accel_args args) { accel_implentation::verify(args); if (args.lim_exp <= 1) error("limit must be greater than 1"); } diff --git a/common/accel_logarithmic.cpp b/common/accel_logarithmic.cpp index c127bcb..64808a1 100644 --- a/common/accel_logarithmic.cpp +++ b/common/accel_logarithmic.cpp @@ -6,15 +6,15 @@ #include "accel_types.hpp" namespace rawaccel { - accel_logarithmic::accel_logarithmic(accel_args args) + inline accel_logarithmic::accel_logarithmic(accel_args args) : accel_implentation(args) {} - double accel_logarithmic::accelerate(double speed) { + inline double accel_logarithmic::accelerate(double speed) { //f(x) = log(m*x+1) return log(speed * curve_constant_one + 1); } - void accel_logarithmic::verify(accel_args args) { + inline void accel_logarithmic::verify(accel_args args) { accel_implentation::verify(args); if (args.lim_exp <= 1) error("exponent must be greater than 1"); } diff --git a/common/accel_natural.cpp b/common/accel_natural.cpp index ba9bc02..c6f14b4 100644 --- a/common/accel_natural.cpp +++ b/common/accel_natural.cpp @@ -7,16 +7,16 @@ #include "accel_types.hpp" namespace rawaccel { - accel_natural::accel_natural(accel_args args) + inline accel_natural::accel_natural(accel_args args) : accel_implentation(args) { curve_constant_one /= curve_constant_two; } - double accel_natural::accelerate(double speed) { + inline double accel_natural::accelerate(double speed) { // f(x) = k(1-e^(-mx)) return curve_constant_two - (curve_constant_two * exp(-curve_constant_one * speed));; } - void accel_natural::verify(accel_args args) { + inline void accel_natural::verify(accel_args args) { accel_implentation::verify(args); if (args.lim_exp <= 1) error("exponent must be greater than 1"); } diff --git a/common/accel_noaccel.cpp b/common/accel_noaccel.cpp index 50506a7..fce5dd4 100644 --- a/common/accel_noaccel.cpp +++ b/common/accel_noaccel.cpp @@ -6,10 +6,10 @@ #include "accel_types.hpp" namespace rawaccel { - accel_noaccel::accel_noaccel(accel_args args) + inline accel_noaccel::accel_noaccel(accel_args args) : accel_implentation(args) {} - double accel_noaccel::accelerate(double speed) { return 0; } + inline double accel_noaccel::accelerate(double speed) { return 0; } - void accel_noaccel::verify(accel_args args) { } + inline void accel_noaccel::verify(accel_args args) { } } diff --git a/common/accel_power.cpp b/common/accel_power.cpp index 26f800d..f104554 100644 --- a/common/accel_power.cpp +++ b/common/accel_power.cpp @@ -6,18 +6,18 @@ #include "accel_types.hpp" namespace rawaccel { - accel_power::accel_power(accel_args args) + inline accel_power::accel_power(accel_args args) : accel_implentation(args) { curve_constant_two++; } - double accel_power::accelerate(double speed) { + inline double accel_power::accelerate(double speed) { // f(x) = (mx)^k - 1 // The subtraction of 1 occurs with later addition of 1 in mind, // so that the input vector is directly multiplied by (mx)^k (if unweighted) return (offset > 0 && speed < 1) ? 0 : pow(speed * curve_constant_one, curve_constant_two) - 1; } - void accel_power::verify(accel_args args) { + inline void accel_power::verify(accel_args args) { accel_implentation::verify(args); if (args.lim_exp <= 0) error("exponent must be greater than 0"); } diff --git a/common/accel_sigmoid.cpp b/common/accel_sigmoid.cpp index c5280bc..d3b8ab7 100644 --- a/common/accel_sigmoid.cpp +++ b/common/accel_sigmoid.cpp @@ -6,15 +6,15 @@ #include "accel_types.hpp" namespace rawaccel { - accel_sigmoid::accel_sigmoid(accel_args args) + inline accel_sigmoid::accel_sigmoid(accel_args args) : accel_implentation(args) {} - double accel_sigmoid::accelerate(double speed) { + inline double accel_sigmoid::accelerate(double speed) { //f(x) = k/(1+e^(-m(c-x))) return curve_constant_two / (exp(-curve_constant_one * (speed - curve_constant_three)) + 1); } - void accel_sigmoid::verify(accel_args args) { + inline void accel_sigmoid::verify(accel_args args) { accel_implentation::verify(args); if (args.lim_exp <= 1) error("exponent must be greater than 1"); } diff --git a/common/accel_types.hpp b/common/accel_types.hpp index c931097..15f5a50 100644 --- a/common/accel_types.hpp +++ b/common/accel_types.hpp @@ -7,7 +7,7 @@ namespace rawaccel { // Error throwing calls std libraries which are unavailable in kernel mode. #ifdef _KERNEL_MODE - void error(const char*) {} + inline void error(const char*) {} #else void error(const char* s); #endif diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp index d0c1b66..6f737da 100644 --- a/common/rawaccel.hpp +++ b/common/rawaccel.hpp @@ -204,7 +204,7 @@ namespace rawaccel { { if (apply_rotate) { - return rotate(input); + input = rotate(input); } input.x *= sensitivity.x; @@ -223,10 +223,14 @@ namespace rawaccel { { if (apply_rotate) { - return rotate(input); + input = rotate(input); + } + + if (apply_accel) + { + input = accel_fn(input, time); } - input = accel_fn(input, time); input.x *= sensitivity.x; input.y *= sensitivity.y; |