# HG changeset patch
# User sl
# Date 1419427876 -3600
# Node ID 5c7f34c627b917ff212cf642e08bfc44154963cb
# Parent 219e9a4184563e0d3e51b993dd7d15067ee32b31
Fixing repeat delay and speed computation.
diff -r 219e9a418456 -r 5c7f34c627b9 HidEvent.cs
--- a/HidEvent.cs Wed Dec 24 11:17:45 2014 +0100
+++ b/HidEvent.cs Wed Dec 24 14:31:16 2014 +0100
@@ -37,17 +37,24 @@
private System.Timers.Timer Timer { get; set; }
+ //Compute repeat delay and speed based on system settings
+ //Those computations were taken from the Petzold here: ftp://ftp.charlespetzold.com/ProgWinForms/4%20Custom%20Controls/NumericScan/NumericScan/ClickmaticButton.cs
+ private int iRepeatDelay = 250 * (1 + SystemInformation.KeyboardDelay);
+ private int iRepeatSpeed = 405 - 12 * SystemInformation.KeyboardSpeed;
+
///
/// Tells whether this event has already been disposed of.
///
public bool IsStray { get { return Timer == null; } }
-
-
+ ///
+ /// We typically dispose of events as soon as we get the corresponding key up signal.
+ ///
public void Dispose()
{
Timer.Enabled = false;
Timer.Dispose();
+ //Mark this event as a stray
Timer = null;
}
@@ -199,7 +206,7 @@
if (Usages[0]!=0)
{
- StartRepeatTimer(SystemInformation.KeyboardDelay*250+250);
+ StartRepeatTimer(iRepeatDelay);
}
IsValid = true;
@@ -249,7 +256,7 @@
return;
}
aHidEvent.IsRepeat = true;
- StartRepeatTimer(1000/(SystemInformation.KeyboardSpeed+2.5));
+ StartRepeatTimer(iRepeatSpeed);
OnHidEventRepeat(aHidEvent);
}