diff options
| -rw-r--r-- | common/rawaccel-settings.h | 1 | ||||
| -rw-r--r-- | driver/driver.cpp | 47 | ||||
| -rw-r--r-- | driver/driver.h | 1 | ||||
| -rw-r--r-- | grapher/Models/AccelGUI.cs | 3 | ||||
| -rw-r--r-- | wrapper/wrapper.cpp | 6 |
5 files changed, 40 insertions, 18 deletions
diff --git a/common/rawaccel-settings.h b/common/rawaccel-settings.h index 649c936..c9bd247 100644 --- a/common/rawaccel-settings.h +++ b/common/rawaccel-settings.h @@ -23,6 +23,7 @@ namespace rawaccel { vec2d sens = { 1, 1 }; vec2d dir_multipliers = {}; milliseconds time_min = DEFAULT_TIME_MIN; + wchar_t device_hw_id[512] = {0}; }; } diff --git a/driver/driver.cpp b/driver/driver.cpp index a99a70b..2c234ba 100644 --- a/driver/driver.cpp +++ b/driver/driver.cpp @@ -54,6 +54,11 @@ Arguments: WDFDEVICE hDevice = WdfWdmDeviceGetWdfDeviceHandle(DeviceObject); PDEVICE_EXTENSION devExt = FilterGetData(hDevice); + bool devMatch = true; + if (wcsncmp(L"", global.args.device_hw_id, sizeof(global.args.device_hw_id)) != 0) { + devMatch = wcsncmp(devExt->hwid, global.args.device_hw_id, sizeof(global.args.device_hw_id)) == 0; + } + if (!(InputDataStart->Flags & MOUSE_MOVE_ABSOLUTE)) { auto num_packets = InputDataEnd - InputDataStart; @@ -63,28 +68,29 @@ Arguments: vec2d carry = devExt->carry; - auto it = InputDataStart; - do { + for (auto it = InputDataStart; it != InputDataEnd; ++it) { vec2d input = { static_cast<double>(it->LastX), static_cast<double>(it->LastY) }; - global.modifier.apply_rotation(input); + if (devMatch) { + global.modifier.apply_rotation(input); - if (enable_accel) { - auto time_supplier = [=] { - counter_t now = KeQueryPerformanceCounter(NULL).QuadPart; - counter_t ticks = now - devExt->counter; - devExt->counter = now; - milliseconds time = ticks * global.tick_interval; - return clampsd(time, global.args.time_min, 100); - }; + if (enable_accel) { + auto time_supplier = [=] { + counter_t now = KeQueryPerformanceCounter(NULL).QuadPart; + counter_t ticks = now - devExt->counter; + devExt->counter = now; + milliseconds time = ticks * global.tick_interval; + return clampsd(time, global.args.time_min, 100); + }; - global.modifier.apply_acceleration(input, time_supplier); - } + global.modifier.apply_acceleration(input, time_supplier); + } - global.modifier.apply_sensitivity(input); + global.modifier.apply_sensitivity(input); + } double carried_result_x = input.x + carry.x; double carried_result_y = input.y + carry.y; @@ -98,7 +104,7 @@ Arguments: it->LastX = out_x; it->LastY = out_y; - } while (++it != InputDataEnd); + } devExt->carry = carry; } @@ -581,7 +587,16 @@ Routine Description: DebugPrint(("WdfRequestRetrieveInputBuffer failed %x\n", status)); break; } - + + ULONG resultLen; + status = WdfDeviceQueryProperty(hDevice, DevicePropertyHardwareID, + sizeof(devExt->hwid), devExt->hwid, &resultLen); + + if (!NT_SUCCESS(status)) { + DebugPrint(("WdfDeviceQueryProperty failed: 0x%x\n", status)); + break; + } + devExt->counter = 0; devExt->carry = {}; devExt->UpperConnectData = *connectData; diff --git a/driver/driver.h b/driver/driver.h index 8554f8c..de677ce 100644 --- a/driver/driver.h +++ b/driver/driver.h @@ -20,6 +20,7 @@ using counter_t = long long; typedef struct _DEVICE_EXTENSION { counter_t counter; vec2d carry; + WCHAR hwid[512]; CONNECT_DATA UpperConnectData; } DEVICE_EXTENSION, *PDEVICE_EXTENSION; diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index c6a2dcc..5c25813 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -141,7 +141,8 @@ namespace grapher modes = ApplyOptions.GetModes(), args = newArgs, minimumTime = driverSettings.minimumTime, - directionalMultipliers = driverSettings.directionalMultipliers + directionalMultipliers = driverSettings.directionalMultipliers, + deviceHardwareID = driverSettings.deviceHardwareID }; ButtonDelay(WriteButton); diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp index fcbf2e8..7ac3a8d 100644 --- a/wrapper/wrapper.cpp +++ b/wrapper/wrapper.cpp @@ -51,7 +51,7 @@ public value struct Vec2 }; [JsonObject(ItemRequired = Required::Always)] -[StructLayout(LayoutKind::Sequential)] +[StructLayout(LayoutKind::Sequential, CharSet = CharSet::Unicode)] public ref struct DriverSettings { literal String^ Key = "Driver settings"; @@ -78,6 +78,10 @@ public ref struct DriverSettings [JsonProperty(Required = Required::Default)] double minimumTime; + [JsonProperty("Device Hardware ID", Required = Required::Default)] + [MarshalAs(UnmanagedType::ByValTStr, SizeConst = 512)] + String^ deviceHardwareID; + bool ShouldSerializeminimumTime() { return minimumTime > 0 && minimumTime != DEFAULT_TIME_MIN; |