diff options
Diffstat (limited to 'driver')
| -rw-r--r-- | driver/driver.cpp | 29 |
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 { |