[Win] Reduce duplication in device enumeration

This commit is contained in:
Stefanos A 2014-01-17 19:24:00 +01:00 committed by thefiddler
parent e38fc0dff7
commit f6b382c929
2 changed files with 15 additions and 7 deletions

View file

@ -174,6 +174,20 @@ namespace OpenTK.Platform.Windows
#endregion
#region GetDeviceList
public static RawInputDeviceList[] GetDeviceList()
{
int count = WinRawInput.DeviceCount;
RawInputDeviceList[] ridl = new RawInputDeviceList[count];
for (int i = 0; i < count; i++)
ridl[i] = new RawInputDeviceList();
Functions.GetRawInputDeviceList(ridl, ref count, API.RawInputDeviceListSize);
return ridl;
}
#endregion
public override IKeyboardDriver2 KeyboardDriver
{
get { return keyboard_driver; }

View file

@ -80,14 +80,8 @@ namespace OpenTK.Platform.Windows
mice[i] = state;
}
int count = WinRawInput.DeviceCount;
RawInputDeviceList[] ridl = new RawInputDeviceList[count];
for (int i = 0; i < count; i++)
ridl[i] = new RawInputDeviceList();
Functions.GetRawInputDeviceList(ridl, ref count, API.RawInputDeviceListSize);
// Discover mouse devices
foreach (RawInputDeviceList dev in ridl)
foreach (RawInputDeviceList dev in WinRawInput.GetDeviceList())
{
ContextHandle id = new ContextHandle(dev.Device);
if (rawids.ContainsKey(id))