# HG changeset patch
# User StephaneLenclud
# Date 1426607188 -3600
# Node ID e13ea80016a1d61e653669b78349717db1db1481
# Parent 2d5955694057865e75856f638bd406c4537c6572
Making our repeat feature a lot safer.
DebugWrites now only compiled for debug builds.
diff -r 2d5955694057 -r e13ea80016a1 Hid/HidDevice.cs
--- a/Hid/HidDevice.cs Tue Mar 17 15:35:58 2015 +0100
+++ b/Hid/HidDevice.cs Tue Mar 17 16:46:28 2015 +0100
@@ -355,6 +355,7 @@
///
/// Print information about this device to our debug output.
///
+ [Conditional("DEBUG")]
public void DebugWrite()
{
Debug.WriteLine("================ HID =========================================================================================");
diff -r 2d5955694057 -r e13ea80016a1 Hid/HidEvent.cs
--- a/Hid/HidEvent.cs Tue Mar 17 15:35:58 2015 +0100
+++ b/Hid/HidEvent.cs Tue Mar 17 16:46:28 2015 +0100
@@ -464,6 +464,7 @@
///
/// Print information about this device to our debug output.
///
+ [Conditional("DEBUG")]
public void DebugWrite()
{
if (!IsValid)
diff -r 2d5955694057 -r e13ea80016a1 Hid/HidHandler.cs
--- a/Hid/HidHandler.cs Tue Mar 17 15:35:58 2015 +0100
+++ b/Hid/HidHandler.cs Tue Mar 17 16:46:28 2015 +0100
@@ -90,27 +90,19 @@
return;
}
- //
+ //We want to repeat only a single event at a time.
+ //Any other event will interrupt the current repeat.
if (ManageRepeats)
{
- if (hidEvent.IsButtonUp)
+ //Discard all outstanding repeats, though we should only ever have only one
+ for (int i = (iHidEvents.Count - 1); i >= 0; i--)
{
- //This is a key up event
- //We need to discard any events belonging to the same page and collection
- for (int i = (iHidEvents.Count - 1); i >= 0; i--)
- {
- if (iHidEvents[i].UsageId == hidEvent.UsageId)
- {
- iHidEvents[i].Dispose();
- iHidEvents.RemoveAt(i);
- }
- }
+ iHidEvents[i].Dispose();
+ iHidEvents.RemoveAt(i);
}
- else
- {
- //Keep that event until we get a key up message
- iHidEvents.Add(hidEvent);
- }
+ //Add our newly created event in our repeat list
+ //TODO: instead of a list we could now have a single event since we only support one repeat at a time
+ iHidEvents.Add(hidEvent);
}
//Broadcast our events