Making our repeat feature a lot safer.
DebugWrites now only compiled for debug builds.
1.1 --- a/Hid/HidDevice.cs Tue Mar 17 15:35:58 2015 +0100
1.2 +++ b/Hid/HidDevice.cs Tue Mar 17 16:46:28 2015 +0100
1.3 @@ -355,6 +355,7 @@
1.4 /// <summary>
1.5 /// Print information about this device to our debug output.
1.6 /// </summary>
1.7 + [Conditional("DEBUG")]
1.8 public void DebugWrite()
1.9 {
1.10 Debug.WriteLine("================ HID =========================================================================================");
2.1 --- a/Hid/HidEvent.cs Tue Mar 17 15:35:58 2015 +0100
2.2 +++ b/Hid/HidEvent.cs Tue Mar 17 16:46:28 2015 +0100
2.3 @@ -464,6 +464,7 @@
2.4 /// <summary>
2.5 /// Print information about this device to our debug output.
2.6 /// </summary>
2.7 + [Conditional("DEBUG")]
2.8 public void DebugWrite()
2.9 {
2.10 if (!IsValid)
3.1 --- a/Hid/HidHandler.cs Tue Mar 17 15:35:58 2015 +0100
3.2 +++ b/Hid/HidHandler.cs Tue Mar 17 16:46:28 2015 +0100
3.3 @@ -90,27 +90,19 @@
3.4 return;
3.5 }
3.6
3.7 - //
3.8 + //We want to repeat only a single event at a time.
3.9 + //Any other event will interrupt the current repeat.
3.10 if (ManageRepeats)
3.11 {
3.12 - if (hidEvent.IsButtonUp)
3.13 + //Discard all outstanding repeats, though we should only ever have only one
3.14 + for (int i = (iHidEvents.Count - 1); i >= 0; i--)
3.15 {
3.16 - //This is a key up event
3.17 - //We need to discard any events belonging to the same page and collection
3.18 - for (int i = (iHidEvents.Count - 1); i >= 0; i--)
3.19 - {
3.20 - if (iHidEvents[i].UsageId == hidEvent.UsageId)
3.21 - {
3.22 - iHidEvents[i].Dispose();
3.23 - iHidEvents.RemoveAt(i);
3.24 - }
3.25 - }
3.26 + iHidEvents[i].Dispose();
3.27 + iHidEvents.RemoveAt(i);
3.28 }
3.29 - else
3.30 - {
3.31 - //Keep that event until we get a key up message
3.32 - iHidEvents.Add(hidEvent);
3.33 - }
3.34 + //Add our newly created event in our repeat list
3.35 + //TODO: instead of a list we could now have a single event since we only support one repeat at a time
3.36 + iHidEvents.Add(hidEvent);
3.37 }
3.38
3.39 //Broadcast our events