Fixing repeat delay and speed computation.
1.1 --- a/HidEvent.cs Wed Dec 24 11:17:45 2014 +0100
1.2 +++ b/HidEvent.cs Wed Dec 24 14:31:16 2014 +0100
1.3 @@ -37,17 +37,24 @@
1.4
1.5 private System.Timers.Timer Timer { get; set; }
1.6
1.7 + //Compute repeat delay and speed based on system settings
1.8 + //Those computations were taken from the Petzold here: ftp://ftp.charlespetzold.com/ProgWinForms/4%20Custom%20Controls/NumericScan/NumericScan/ClickmaticButton.cs
1.9 + private int iRepeatDelay = 250 * (1 + SystemInformation.KeyboardDelay);
1.10 + private int iRepeatSpeed = 405 - 12 * SystemInformation.KeyboardSpeed;
1.11 +
1.12 /// <summary>
1.13 /// Tells whether this event has already been disposed of.
1.14 /// </summary>
1.15 public bool IsStray { get { return Timer == null; } }
1.16
1.17 -
1.18 -
1.19 + /// <summary>
1.20 + /// We typically dispose of events as soon as we get the corresponding key up signal.
1.21 + /// </summary>
1.22 public void Dispose()
1.23 {
1.24 Timer.Enabled = false;
1.25 Timer.Dispose();
1.26 + //Mark this event as a stray
1.27 Timer = null;
1.28 }
1.29
1.30 @@ -199,7 +206,7 @@
1.31
1.32 if (Usages[0]!=0)
1.33 {
1.34 - StartRepeatTimer(SystemInformation.KeyboardDelay*250+250);
1.35 + StartRepeatTimer(iRepeatDelay);
1.36 }
1.37
1.38 IsValid = true;
1.39 @@ -249,7 +256,7 @@
1.40 return;
1.41 }
1.42 aHidEvent.IsRepeat = true;
1.43 - StartRepeatTimer(1000/(SystemInformation.KeyboardSpeed+2.5));
1.44 + StartRepeatTimer(iRepeatSpeed);
1.45 OnHidEventRepeat(aHidEvent);
1.46 }
1.47