diff options
| author | a1xd <[email protected]> | 2021-09-23 00:21:57 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2021-09-23 22:37:03 -0400 |
| commit | 79c6a885fc732a0fff0fe694a86ed6450b00794b (patch) | |
| tree | 8eab1c13f2bc6edac1e1129561f6e27549ce4c39 /grapher/Models | |
| parent | docs - add win10 as prereq (diff) | |
| download | rawaccel-79c6a885fc732a0fff0fe694a86ed6450b00794b.tar.xz rawaccel-79c6a885fc732a0fff0fe694a86ed6450b00794b.zip | |
add indicator to last move on normalized dev read
Diffstat (limited to 'grapher/Models')
| -rw-r--r-- | grapher/Models/Mouse/MouseWatcher.cs | 29 | ||||
| -rw-r--r-- | grapher/Models/Serialized/SettingsManager.cs | 15 |
2 files changed, 37 insertions, 7 deletions
diff --git a/grapher/Models/Mouse/MouseWatcher.cs b/grapher/Models/Mouse/MouseWatcher.cs index 91eebb8..723f97b 100644 --- a/grapher/Models/Mouse/MouseWatcher.cs +++ b/grapher/Models/Mouse/MouseWatcher.cs @@ -692,6 +692,9 @@ namespace grapher.Models.Mouse SettingsManager = setMngr; MouseData = new MouseData(); + LastMoveDisplayFormat = Constants.MouseMoveDefaultFormat; + LastMoveNormalized = false; + RAWINPUTDEVICE device = new RAWINPUTDEVICE(); device.WindowHandle = ContainingForm.Handle; device.UsagePage = HIDUsagePage.Generic; @@ -721,6 +724,10 @@ namespace grapher.Models.Mouse private Stopwatch Stopwatch { get; } + private string LastMoveDisplayFormat { get; set; } + + private bool LastMoveNormalized { get; set; } + private double PollTime { get => 1000 / SettingsManager.PollRateField.Data; @@ -733,7 +740,7 @@ namespace grapher.Models.Mouse public void UpdateLastMove() { MouseData.Get(out var x, out var y); - Display.Text = $"Last (x, y): ({x}, {y})"; + Display.Text = string.Format(LastMoveDisplayFormat, x, y); } public void ReadMouseMove(Message message) @@ -743,7 +750,25 @@ namespace grapher.Models.Mouse _ = GetRawInputData(message.LParam, RawInputCommand.Input, out rawInput, ref size, Marshal.SizeOf(typeof(RAWINPUTHEADER))); bool relative = !rawInput.Data.Mouse.Flags.HasFlag(RawMouseFlags.MoveAbsolute); - bool deviceMatch = SettingsManager.ActiveHandles.Contains(rawInput.Header.Device); + + bool deviceMatch = false; + foreach (var (handle, normalized) in SettingsManager.ActiveNormTaggedHandles) + { + if (handle == rawInput.Header.Device) + { + deviceMatch = true; + + if (normalized != LastMoveNormalized) + { + LastMoveDisplayFormat = normalized ? + Constants.MouseMoveNormalizedFormat : + Constants.MouseMoveDefaultFormat; + LastMoveNormalized = normalized; + } + + break; + } + } if (relative && deviceMatch && (rawInput.Data.Mouse.LastX != 0 || rawInput.Data.Mouse.LastY != 0)) { diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs index 1c8608f..43550c5 100644 --- a/grapher/Models/Serialized/SettingsManager.cs +++ b/grapher/Models/Serialized/SettingsManager.cs @@ -31,7 +31,7 @@ namespace grapher.Models.Serialized StreamingModeMenuItem = streamingMode; SystemDevices = new List<MultiHandleDevice>(); - ActiveHandles = new List<IntPtr>(); + ActiveNormTaggedHandles = new List<(IntPtr, bool)>(); GuiSettings = GUISettings.MaybeLoad(); @@ -114,7 +114,7 @@ namespace grapher.Models.Serialized public IList<MultiHandleDevice> SystemDevices { get; private set; } - public List<IntPtr> ActiveHandles { get; } + public List<(IntPtr, bool)> ActiveNormTaggedHandles { get; } private ToolStripMenuItem AutoWriteMenuItem { get; set; } @@ -198,19 +198,24 @@ namespace grapher.Models.Serialized public void SetActiveHandles() { - ActiveHandles.Clear(); + ActiveNormTaggedHandles.Clear(); bool ActiveProfileIsFirst = ActiveProfile == ActiveConfig.profiles[0]; foreach (var sysDev in SystemDevices) { + void AddHandlesFromSysDev(bool normalized) + { + ActiveNormTaggedHandles.AddRange(sysDev.handles.Select(h => (h, normalized))); + } + var settings = ActiveConfig.devices.Find(d => d.id == sysDev.id); if (settings is null) { if (ActiveProfileIsFirst && !ActiveConfig.defaultDeviceConfig.disable) { - ActiveHandles.AddRange(sysDev.handles); + AddHandlesFromSysDev(ActiveConfig.defaultDeviceConfig.dpi > 0); } } else if (!settings.config.disable && @@ -219,7 +224,7 @@ namespace grapher.Models.Serialized !ActiveProfileNamesSet.Contains(settings.profile))) || ActiveProfile.name == settings.profile)) { - ActiveHandles.AddRange(sysDev.handles); + AddHandlesFromSysDev(settings.config.dpi > 0); } } } |