Skip to content

ArgumentException at RawInputDigitizerContact constructor with TouchPad #13

@emoacht

Description

@emoacht

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions