summaryrefslogtreecommitdiff
path: root/grapher/Models/Mouse
diff options
context:
space:
mode:
authorJacobPalecki <[email protected]>2021-01-20 20:13:33 -0800
committerGitHub <[email protected]>2021-01-20 20:13:33 -0800
commit5b6479013c8f35df933dd57c680063f4db1e4028 (patch)
tree60dd7c67a0f163457da2519b42553382a39a591b /grapher/Models/Mouse
parentshow custom dialog on bad input (#63) (diff)
parentGuard against bad anisotropy args (diff)
downloadrawaccel-5b6479013c8f35df933dd57c680063f4db1e4028.tar.xz
rawaccel-5b6479013c8f35df933dd57c680063f4db1e4028.zip
Merge pull request #65 from JacobPalecki/Directional
Directionality Features + Graph Fidelity
Diffstat (limited to 'grapher/Models/Mouse')
-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 151a2a2..163829f 100644
--- a/grapher/Models/Mouse/MouseWatcher.cs
+++ b/grapher/Models/Mouse/MouseWatcher.cs
@@ -1,6 +1,7 @@
using grapher.Models.Serialized;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
@@ -701,6 +702,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
@@ -717,6 +720,8 @@ namespace grapher.Models.Mouse
private MouseData MouseData { get; }
+ private Stopwatch Stopwatch { get; }
+
private List<IntPtr> DeviceHandles { get; }
private bool AnyDevice { get; set; }
@@ -757,6 +762,11 @@ namespace grapher.Models.Mouse
if (relative && deviceMatch && (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;
@@ -776,7 +786,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);
}
}