diff --git a/Source/OpenTK/Platform/Windows/WinRawMouse.cs b/Source/OpenTK/Platform/Windows/WinRawMouse.cs index 38e8a3714..809887a2f 100644 --- a/Source/OpenTK/Platform/Windows/WinRawMouse.cs +++ b/Source/OpenTK/Platform/Windows/WinRawMouse.cs @@ -112,24 +112,27 @@ public void RefreshDevices() RegistryKey regkey = FindRegistryKey(name); string deviceDesc = (string)regkey.GetValue("DeviceDesc"); string deviceClass = (string)regkey.GetValue("Class"); - deviceDesc = deviceDesc.Substring(deviceDesc.LastIndexOf(';') + 1); - - if (!String.IsNullOrEmpty(deviceClass) && deviceClass.ToLower().Equals("mouse")) + if (!String.IsNullOrEmpty(deviceDesc)) { - if (!rawids.ContainsKey(new ContextHandle(dev.Device))) + deviceDesc = deviceDesc.Substring(deviceDesc.LastIndexOf(';') + 1); + + if (!String.IsNullOrEmpty(deviceClass) && deviceClass.ToLower().Equals("mouse")) { - // Register the device: - RawInputDeviceInfo info = new RawInputDeviceInfo(); - int devInfoSize = API.RawInputDeviceInfoSize; - Functions.GetRawInputDeviceInfo(dev.Device, RawInputDeviceInfoEnum.DEVICEINFO, - info, ref devInfoSize); - - RegisterRawDevice(Window, deviceDesc); - MouseState state = new MouseState(); - state.IsConnected = true; - mice.Add(state); - names.Add(deviceDesc); - rawids.Add(new ContextHandle(dev.Device), mice.Count - 1); + if (!rawids.ContainsKey(new ContextHandle(dev.Device))) + { + // Register the device: + RawInputDeviceInfo info = new RawInputDeviceInfo(); + int devInfoSize = API.RawInputDeviceInfoSize; + Functions.GetRawInputDeviceInfo(dev.Device, RawInputDeviceInfoEnum.DEVICEINFO, + info, ref devInfoSize); + + RegisterRawDevice(Window, deviceDesc); + MouseState state = new MouseState(); + state.IsConnected = true; + mice.Add(state); + names.Add(deviceDesc); + rawids.Add(new ContextHandle(dev.Device), mice.Count - 1); + } } } }