diff options
| author | a1xd <[email protected]> | 2021-03-30 18:27:02 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2021-03-30 18:27:02 -0400 |
| commit | fa3ebfb1eb054ba88824a908c996094bb98e85c5 (patch) | |
| tree | bf52cf6d5de16714dba11e96719ce1434a686779 /driver | |
| parent | put utility in namespace (diff) | |
| download | rawaccel-fa3ebfb1eb054ba88824a908c996094bb98e85c5.tar.xz rawaccel-fa3ebfb1eb054ba88824a908c996094bb98e85c5.zip | |
refactor lut/motivity
Diffstat (limited to 'driver')
| -rw-r--r-- | driver/driver.cpp | 41 | ||||
| -rw-r--r-- | driver/driver.h | 1 |
2 files changed, 12 insertions, 30 deletions
diff --git a/driver/driver.cpp b/driver/driver.cpp index 49f375d..89f09dc 100644 --- a/driver/driver.cpp +++ b/driver/driver.cpp @@ -13,13 +13,11 @@ #endif 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 @@ -164,7 +162,7 @@ Return Value: case RA_READ: status = WdfRequestRetrieveOutputBuffer( Request, - sizeof(ra::settings), + sizeof(ra::io_t), &buffer, NULL ); @@ -172,14 +170,18 @@ Return Value: DebugPrint(("RetrieveOutputBuffer failed: 0x%x\n", status)); } else { - *reinterpret_cast<ra::settings*>(buffer) = global.args; - bytes_out = sizeof(ra::settings); + ra::io_t& output = *reinterpret_cast<ra::io_t*>(buffer); + + output.args = global.args; + output.mod = global.modifier; + + bytes_out = sizeof(ra::io_t); } break; case RA_WRITE: status = WdfRequestRetrieveInputBuffer( Request, - sizeof(ra::settings), + sizeof(ra::io_t), &buffer, NULL ); @@ -191,14 +193,10 @@ Return Value: interval.QuadPart = static_cast<LONGLONG>(ra::WRITE_DELAY) * -10000; KeDelayExecutionThread(KernelMode, FALSE, &interval); - ra::settings new_settings = *reinterpret_cast<ra::settings*>(buffer); - - if (new_settings.time_min <= 0 || _isnanf(static_cast<float>(new_settings.time_min))) { - new_settings.time_min = ra::settings{}.time_min; - } + ra::io_t& input = *reinterpret_cast<ra::io_t*>(buffer); - global.args = new_settings; - global.modifier = { global.args, global.lookups }; + global.args = input.args; + global.modifier = input.mod; } break; case RA_GET_VERSION: @@ -276,23 +274,6 @@ 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 { diff --git a/driver/driver.h b/driver/driver.h index bb1ae41..56742f6 100644 --- a/driver/driver.h +++ b/driver/driver.h @@ -2,6 +2,7 @@ #include "rawaccel-base.hpp" +#define NOMINMAX #include <ntddk.h> #include <kbdmou.h> #include <wdf.h> |