summaryrefslogtreecommitdiff
path: root/driver/driver.cpp
diff options
context:
space:
mode:
authorJacobPalecki <[email protected]>2020-09-22 19:59:47 -0700
committerGitHub <[email protected]>2020-09-22 19:59:47 -0700
commit77f420cf45a1a0bee00602965e687097367e2a70 (patch)
treefa088af8f2feb54df5bcb6a036715fd32d0511e8 /driver/driver.cpp
parentMerge pull request #21 from JacobPalecki/GUI (diff)
parentUpdate credits (diff)
downloadrawaccel-77f420cf45a1a0bee00602965e687097367e2a70.tar.xz
rawaccel-77f420cf45a1a0bee00602965e687097367e2a70.zip
Merge pull request #22 from JacobPalecki/GUI
Replace SigmoidGain with Motivity & Cleanup
Diffstat (limited to 'driver/driver.cpp')
-rw-r--r--driver/driver.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/driver/driver.cpp b/driver/driver.cpp
index fb47477..4dd3d62 100644
--- a/driver/driver.cpp
+++ b/driver/driver.cpp
@@ -12,11 +12,13 @@
namespace ra = rawaccel;
using milliseconds = double;
+using lut_value_t = ra::si_pair;
struct {
ra::settings args;
milliseconds tick_interval = 0; // set in DriverEntry
ra::mouse_modifier modifier;
+ vec2<lut_value_t*> lookups = {};
} global;
VOID
@@ -168,8 +170,14 @@ Return Value:
return;
}
- global.args = *reinterpret_cast<ra::settings*>(buffer);
- global.modifier = { global.args };
+ ra::settings new_settings = *reinterpret_cast<ra::settings*>(buffer);
+
+ if (new_settings.time_min <= 0 || _isnanf(new_settings.time_min)) {
+ new_settings.time_min = ra::settings{}.time_min;
+ }
+
+ global.args = new_settings;
+ global.modifier = { global.args, global.lookups };
WdfRequestComplete(Request, STATUS_SUCCESS);
}
@@ -251,6 +259,23 @@ Routine Description:
KeQueryPerformanceCounter(&freq);
global.tick_interval = 1e3 / freq.QuadPart;
+ auto make_lut = [] {
+ const size_t POOL_SIZE = sizeof(lut_value_t) * ra::LUT_SIZE;
+
+ auto pool = ExAllocatePoolWithTag(NonPagedPool, POOL_SIZE, 'AR');
+
+ if (!pool) {
+ DebugPrint(("RA - failed to allocate LUT\n"));
+ }
+ else {
+ RtlZeroMemory(pool, POOL_SIZE);
+ }
+
+ return reinterpret_cast<lut_value_t*>(pool);
+ };
+
+ global.lookups = { make_lut(), make_lut() };
+
CreateControlDevice(driver);
}
else {