From 140a278b3eee917a1fcac0efa930d4f3c5bfbc80 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Fri, 3 Dec 2010 12:29:01 +0000 Subject: [PATCH] Do not try to register device when device description is empty. --- Source/OpenTK/Platform/Windows/WinRawKeyboard.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs b/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs index ecf3e0df..9b2a1989 100644 --- a/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs +++ b/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs @@ -103,7 +103,16 @@ namespace OpenTK.Platform.Windows RegistryKey regkey = GetRegistryKey(name); string deviceDesc = (string)regkey.GetValue("DeviceDesc"); string deviceClass = (string)regkey.GetValue("Class"); - deviceDesc = deviceDesc.Substring(deviceDesc.LastIndexOf(';') + 1); + + if (String.IsNullOrEmpty(deviceDesc)) + { + Debug.Print("[Warning] Failed to retrieve device description, skipping this device."); + continue; + } + else + { + deviceDesc = deviceDesc.Substring(deviceDesc.LastIndexOf(';') + 1); + } if (!String.IsNullOrEmpty(deviceClass) && deviceClass.ToLower().Equals("keyboard")) {