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/Mouse/MouseWatcher.cs | |
| 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/Mouse/MouseWatcher.cs')
| -rw-r--r-- | grapher/Models/Mouse/MouseWatcher.cs | 29 |
1 files changed, 27 insertions, 2 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)) { |