Workaround for NRE on WinRawMouse driver

On some systems, the Windows Raw Input driver fails to find the name of
a mouse device, causing a NRE. Since the name is not vital information,
a dummy name is generated as a workaround.
This commit is contained in:
Stefanos A. 2013-09-30 18:27:13 +02:00
parent cf703aca62
commit ddd070579a

View file

@ -120,6 +120,13 @@ namespace OpenTK.Platform.Windows
RegistryKey classGUIDKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Class\" + deviceClassGUID);
deviceClass = classGUIDKey != null ? (string) classGUIDKey.GetValue("Class") : string.Empty;
}
// deviceDesc remained null on a new Win7 system - not sure why.
// Since the description is not vital information, use a dummy description
// when that happens.
if (String.IsNullOrEmpty(deviceDesc))
deviceDesc = "Windows Mouse " + mice.Count;
else
deviceDesc = deviceDesc.Substring(deviceDesc.LastIndexOf(';') + 1);
if (!String.IsNullOrEmpty(deviceClass) && deviceClass.ToLower().Equals("mouse"))