summaryrefslogtreecommitdiff
path: root/common/rawaccel.hpp
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-07-28 17:21:39 -0700
committerJacob Palecki <[email protected]>2020-07-28 17:21:39 -0700
commitcdd82efdfdd7c2e9b4c2ed9777792f9921eedb9e (patch)
tree64620804479337358e5c5d2dfd1e54407a032de2 /common/rawaccel.hpp
parentRename acceleration constants, arguments (diff)
downloadrawaccel-cdd82efdfdd7c2e9b4c2ed9777792f9921eedb9e.tar.xz
rawaccel-cdd82efdfdd7c2e9b4c2ed9777792f9921eedb9e.zip
Get rid of enum and use types\tags directly
Diffstat (limited to 'common/rawaccel.hpp')
-rw-r--r--common/rawaccel.hpp24
1 files changed, 5 insertions, 19 deletions
diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp
index e904350..08829dd 100644
--- a/common/rawaccel.hpp
+++ b/common/rawaccel.hpp
@@ -9,9 +9,6 @@
namespace rawaccel {
- /// <summary> Enum to hold acceleration implementation types (i.e. types of curves.) </summary>
- enum class mode { noaccel, linear, classic, natural, logarithmic, sigmoid, power };
-
/// <summary> Struct to hold vector rotation details. </summary>
struct rotator {
@@ -80,7 +77,7 @@ namespace rawaccel {
/// <summary> Struct to hold arguments for an acceleration function. </summary>
struct accel_args {
- mode accel_mode = mode::noaccel;
+ int accel_mode = 0;
milliseconds time_min = 0.4;
double offset = 0;
double accel = 0;
@@ -282,20 +279,8 @@ namespace rawaccel {
vec2<accel_scale_clamp> clamp;
accel_function(accel_args args) {
- switch (args.accel_mode)
- {
- case mode::linear: accel = accel_linear(args);
- break;
- case mode::classic: accel = accel_classic(args);
- break;
- case mode::natural: accel = accel_natural(args);
- break;
- case mode::logarithmic: accel = accel_logarithmic(args);
- break;
- case mode::sigmoid: accel = accel_sigmoid(args);
- break;
- case mode::power: accel = accel_power(args);
- }
+ accel.tag = args.accel_mode;
+ accel.visit([&](auto& a){ a = {args}; });
// Verification is performed by the accel_implementation object
// and therefore must occur after the object has been instantiated
@@ -365,7 +350,8 @@ namespace rawaccel {
if (apply_rotate) rotate = rotator(degrees);
else rotate = rotator();
- apply_accel = accel_args.accel_mode != mode::noaccel;
+ apply_accel = (accel_args.accel_mode != 0 &&
+ accel_args.accel_mode != accel_implementation_t::id<accel_noaccel>);
if (sens.x == 0) sens.x = 1;
if (sens.y == 0) sens.y = 1;