-
-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Thank you for great library! It is really useful to get inputs from HID devices.
I have tested it to parse inputs from Precision TouchPad (PTP) and encountered System.ArgumentException (HResult=0x80070057
Message=An item with the same key has already been added.) at RawInputDigitizerContact constructor when a window receives WM_INPUT message. They are fired at following two Enumerable.ToDictionary methods.
rawinput-sharp/RawInput.Sharp/RawInputDigitizerContact.cs
Lines 38 to 39 in fd5c600
| var buttons = buttonStates.ToDictionary(x => x.Button.UsageAndPage, x => x.IsActive); | |
| var values = valueStates.ToDictionary(x => x.Value.UsageAndPage); |
This exception is relatively common in Enumerable.ToDictionary method when there are duplicate keys. It is not difficult to avoid this exception and I will be happy to send PR to fix this issue.
Before start working, I would like to hear your view on this issue especially whether the first value or the last value is to be preserved. I have no strong view on this selection.