diff options
| author | Jacob Palecki <[email protected]> | 2020-09-26 13:43:13 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-26 13:43:13 -0700 |
| commit | 0ce82f408b9c182cde407fcb0d3c98223c314ea9 (patch) | |
| tree | 050b32e2a1bf43f8bcff9e5600c50fee380a7cc0 /grapher/Models/Mouse/MouseWatcher.cs | |
| parent | FAQ has conversion instructions (diff) | |
| download | rawaccel-0ce82f408b9c182cde407fcb0d3c98223c314ea9.tar.xz rawaccel-0ce82f408b9c182cde407fcb0d3c98223c314ea9.zip | |
Scale Last Mouse Move by poll rate
Diffstat (limited to 'grapher/Models/Mouse/MouseWatcher.cs')
| -rw-r--r-- | grapher/Models/Mouse/MouseWatcher.cs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/grapher/Models/Mouse/MouseWatcher.cs b/grapher/Models/Mouse/MouseWatcher.cs index c6e85c1..6209445 100644 --- a/grapher/Models/Mouse/MouseWatcher.cs +++ b/grapher/Models/Mouse/MouseWatcher.cs @@ -677,11 +677,12 @@ namespace grapher.Models.Mouse #region Constructors - public MouseWatcher(Form containingForm, Label display, AccelCharts accelCharts) + public MouseWatcher(Form containingForm, Label display, AccelCharts accelCharts, Field pollRate) { ContainingForm = containingForm; Display = display; AccelCharts = accelCharts; + PollRateField = pollRate; MouseData = new MouseData(); RAWINPUTDEVICE device = new RAWINPUTDEVICE(); @@ -694,6 +695,7 @@ namespace grapher.Models.Mouse devices[0] = device; RegisterRawInputDevices(devices, 1, Marshal.SizeOf(typeof(RAWINPUTDEVICE))); PollTime = 1; + PollRate = 1000; } #endregion Constructors @@ -706,9 +708,13 @@ namespace grapher.Models.Mouse private AccelCharts AccelCharts { get; } + private Field PollRateField { get; set; } + private MouseData MouseData { get; } - private double PollTime { get; } + private double PollRate { get; set; } + + private double PollTime { get; set; } #endregion Properties @@ -734,6 +740,12 @@ namespace grapher.Models.Mouse outSize = GetRawInputData((IntPtr)message.LParam, RawInputCommand.Input, out rawInput, ref size, Marshal.SizeOf(typeof(RAWINPUTHEADER))); + if (PollRateField.Data != PollRate) + { + PollRate = PollRateField.Data; + PollTime = 1000 / PollRate; + } + if (rawInput.Data.Mouse.LastX != 0 || rawInput.Data.Mouse.LastY != 0) { OnMouseMove(rawInput.Data.Mouse.LastX, rawInput.Data.Mouse.LastY, PollTime); |