summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authora1xd <[email protected]>2021-09-23 00:21:57 -0400
committera1xd <[email protected]>2021-09-23 22:37:03 -0400
commit79c6a885fc732a0fff0fe694a86ed6450b00794b (patch)
tree8eab1c13f2bc6edac1e1129561f6e27549ce4c39
parentdocs - add win10 as prereq (diff)
downloadrawaccel-79c6a885fc732a0fff0fe694a86ed6450b00794b.tar.xz
rawaccel-79c6a885fc732a0fff0fe694a86ed6450b00794b.zip
add indicator to last move on normalized dev read
-rw-r--r--grapher/Constants/Constants.cs10
-rw-r--r--grapher/Models/Mouse/MouseWatcher.cs29
-rw-r--r--grapher/Models/Serialized/SettingsManager.cs15
3 files changed, 45 insertions, 9 deletions
diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs
index 0b15ce6..fa500de 100644
--- a/grapher/Constants/Constants.cs
+++ b/grapher/Constants/Constants.cs
@@ -128,12 +128,18 @@ namespace grapher
public const string GuiConfigFileName = ".config";
- /// <summary> Text to direcitonality panel title when panel is closed. </summary>
+ /// <summary> Text to directionality panel title when panel is closed. </summary>
public const string DirectionalityTitleClosed = "Anisotropy \u25BC";
- /// <summary> Text to direcitonality panel title when panel is open. </summary>
+ /// <summary> Text to directionality panel title when panel is open. </summary>
public const string DirectionalityTitleOpen = "Anisotropy \u25B2";
+ /// <summary> Default last mouse move label text format. </summary>
+ public const string MouseMoveDefaultFormat = "Last (x, y): ({0}, {1})";
+
+ /// <summary> Last mouse move label text format when last input was from a dpi normalized device. </summary>
+ public const string MouseMoveNormalizedFormat = MouseMoveDefaultFormat + "!";
+
/// <summary> Style used by System.Double.Parse </summary>
public const NumberStyles FloatStyle = NumberStyles.Float | NumberStyles.AllowThousands;
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);
}
}
}