summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}
}