summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2021-01-18 22:13:54 -0800
committerJacob Palecki <[email protected]>2021-01-18 22:13:54 -0800
commit8e5019e93688c318a31ed513938498e06aa2daf4 (patch)
treeca79778664e8d268cc6c3a71aed9f4fbe19240cd
parentDirectional works (diff)
downloadrawaccel-8e5019e93688c318a31ed513938498e06aa2daf4.tar.xz
rawaccel-8e5019e93688c318a31ed513938498e06aa2daf4.zip
Add timer to mousewatcher for better low-end fidelity
-rw-r--r--grapher/Models/Mouse/MouseWatcher.cs12
1 files changed, 11 insertions, 1 deletions
diff --git a/grapher/Models/Mouse/MouseWatcher.cs b/grapher/Models/Mouse/MouseWatcher.cs
index cbfc119..3cc8bd0 100644
--- a/grapher/Models/Mouse/MouseWatcher.cs
+++ b/grapher/Models/Mouse/MouseWatcher.cs
@@ -1,5 +1,6 @@
using grapher.Models.Serialized;
using System;
+using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
@@ -695,6 +696,8 @@ namespace grapher.Models.Mouse
RAWINPUTDEVICE[] devices = new RAWINPUTDEVICE[1];
devices[0] = device;
RegisterRawInputDevices(devices, 1, Marshal.SizeOf(typeof(RAWINPUTDEVICE)));
+ Stopwatch = new Stopwatch();
+ Stopwatch.Start();
}
#endregion Constructors
@@ -711,6 +714,8 @@ namespace grapher.Models.Mouse
private MouseData MouseData { get; }
+ private Stopwatch Stopwatch { get; }
+
private double PollTime
{
get => 1000 / SettingsManager.PollRateField.Data;
@@ -738,6 +743,11 @@ namespace grapher.Models.Mouse
if (relative && (rawInput.Data.Mouse.LastX != 0 || rawInput.Data.Mouse.LastY != 0))
{
+ var time = Stopwatch.Elapsed.TotalMilliseconds;
+ Stopwatch.Restart();
+ time = time > 100 ? 100 : time;
+ time = time > (PollTime * 0.8) ? time : (PollTime * 0.8);
+
double x = rawInput.Data.Mouse.LastX;
double y = rawInput.Data.Mouse.LastY;
@@ -757,7 +767,7 @@ namespace grapher.Models.Mouse
}
MouseData.Set(rawInput.Data.Mouse.LastX, rawInput.Data.Mouse.LastY);
- AccelCharts.MakeDots(x, y, PollTime);
+ AccelCharts.MakeDots(x, y, time);
}
}