summaryrefslogtreecommitdiff
path: root/common/accel-base.hpp
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-07-30 22:04:44 -0400
committera1xd <[email protected]>2020-07-30 22:04:44 -0400
commitb59cf98c2f326abeb6b993d8ecc5759d23096253 (patch)
tree4ac15ce9945e46e135e8a2f1cc1bad619e94856d /common/accel-base.hpp
parentadd tweaks for st-refactor (diff)
downloadrawaccel-b59cf98c2f326abeb6b993d8ecc5759d23096253.tar.xz
rawaccel-b59cf98c2f326abeb6b993d8ecc5759d23096253.zip
Make weight a member of accel_base
This exposes weight to derived accel types, which now supply a method to transform acceleration into scale.
Diffstat (limited to 'common/accel-base.hpp')
-rw-r--r--common/accel-base.hpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/common/accel-base.hpp b/common/accel-base.hpp
index ed79bdb..e87b463 100644
--- a/common/accel-base.hpp
+++ b/common/accel-base.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "vec2.h"
+
namespace rawaccel {
// Error throwing calls std libraries which are unavailable in kernel mode.
@@ -15,14 +17,18 @@ namespace rawaccel {
double exponent = 2;
double midpoint = 0;
double power_scale = 1;
+ vec2d weight = { 1, 1 };
};
/// <summary>
/// Struct to hold common acceleration curve implementation details.
/// </summary>
struct accel_base {
-
- /// <summary> Generally, the acceleration ramp rate.</summary>
+
+ /// <summary> Coefficients applied to acceleration per axis.</summary>
+ vec2d weight = { 1, 1 };
+
+ /// <summary> Generally, the acceleration ramp rate.
double speed_coeff = 0;
/// <summary>
@@ -34,6 +40,17 @@ namespace rawaccel {
verify(args);
speed_coeff = args.accel;
+ weight = args.weight;
+ }
+
+ /// <summary>
+ /// Default transformation of acceleration -> mouse input multipliers.
+ /// </summary>
+ inline vec2d scale(double accel_val) const {
+ return {
+ weight.x * accel_val + 1,
+ weight.y * accel_val + 1
+ };
}
/// <summary>