From 75c5f80cad2b671df2d20c4b0395b5aec1bc10af Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Tue, 22 Sep 2020 03:01:34 -0400 Subject: add lut exp to driver --- driver/driver.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'driver/driver.cpp') 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 lookups = {}; } global; VOID @@ -168,8 +170,14 @@ Return Value: return; } - global.args = *reinterpret_cast(buffer); - global.modifier = { global.args }; + ra::settings new_settings = *reinterpret_cast(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(pool); + }; + + global.lookups = { make_lut(), make_lut() }; + CreateControlDevice(driver); } else { -- cgit v1.2.3