summaryrefslogtreecommitdiff
path: root/common/accel-base.hpp
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-07-30 17:07:35 -0400
committera1xd <[email protected]>2020-07-30 17:07:35 -0400
commite8417a29fb2153ea035a757f36bfa300cf8b480d (patch)
tree802905bbf262196678e140463150e66d0a674b01 /common/accel-base.hpp
parentMerge remote-tracking branch 'downstream/Inheritance' into st-refactor (diff)
downloadrawaccel-e8417a29fb2153ea035a757f36bfa300cf8b480d.tar.xz
rawaccel-e8417a29fb2153ea035a757f36bfa300cf8b480d.zip
add tweaks for st-refactor
Diffstat (limited to 'common/accel-base.hpp')
-rw-r--r--common/accel-base.hpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/common/accel-base.hpp b/common/accel-base.hpp
new file mode 100644
index 0000000..ed79bdb
--- /dev/null
+++ b/common/accel-base.hpp
@@ -0,0 +1,50 @@
+#pragma once
+
+namespace rawaccel {
+
+ // Error throwing calls std libraries which are unavailable in kernel mode.
+ void error(const char* s);
+
+ using milliseconds = double;
+
+ /// <summary> Struct to hold arguments for an acceleration function. </summary>
+ struct accel_args {
+ double offset = 0;
+ double accel = 0;
+ double limit = 2;
+ double exponent = 2;
+ double midpoint = 0;
+ double power_scale = 1;
+ };
+
+ /// <summary>
+ /// Struct to hold common acceleration curve implementation details.
+ /// </summary>
+ struct accel_base {
+
+ /// <summary> Generally, the acceleration ramp rate.</summary>
+ double speed_coeff = 0;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="accel_base"/> struct.
+ /// </summary>
+ /// <param name="args"></param>
+ /// <returns></returns>
+ accel_base(accel_args args) {
+ verify(args);
+
+ speed_coeff = args.accel;
+ }
+
+ /// <summary>
+ /// Verifies arguments as valid. Errors if not.
+ /// </summary>
+ /// <param name="args">Arguments to verified.</param>
+ void verify(accel_args args) const {
+ if (args.accel < 0) error("accel can not be negative, use a negative weight to compensate");
+ }
+
+ accel_base() = default;
+ };
+
+}