# HG changeset patch # User StephaneLenclud # Date 1425546757 -3600 # Node ID c28dd93b94c5be1ce8144e9871f59042650abc09 # Parent e0a7b35f90dd2c461eb714802b8a859d82931171 Imrpoved HID device friendly name. diff -r e0a7b35f90dd -r c28dd93b94c5 HidDevice.cs --- a/HidDevice.cs Wed Mar 04 20:52:24 2015 +0100 +++ b/HidDevice.cs Thu Mar 05 10:12:37 2015 +0100 @@ -243,9 +243,20 @@ FriendlyName = Product + suffix; } else - { - //No proper name just use the device ID instead - FriendlyName = "0x" + ProductId.ToString("X4") + suffix; + { + //Extract friendly name from name + char[] delimiterChars = { '#', '&'}; + string[] words = Name.Split(delimiterChars); + if (words.Length >= 2) + { + //Use our name sub-string to describe this device + FriendlyName = words[1] + " - 0x" + ProductId.ToString("X4") + suffix; + } + else + { + //No proper name just use the device ID instead + FriendlyName = "0x" + ProductId.ToString("X4") + suffix; + } } } diff -r e0a7b35f90dd -r c28dd93b94c5 RawInput.cs --- a/RawInput.cs Wed Mar 04 20:52:24 2015 +0100 +++ b/RawInput.cs Thu Mar 05 10:12:37 2015 +0100 @@ -104,7 +104,7 @@ int result = Win32.Function.GetRawInputDeviceInfo(hDevice, RawInputDeviceInfoType.RIDI_PREPARSEDDATA, IntPtr.Zero, ref ppDataSize); if (result != 0) { - Debug.WriteLine("Failed to get raw input pre-parsed data size" + result + Marshal.GetLastWin32Error()); + Debug.WriteLine("Failed to get raw input pre-parsed data size: " + result + " : " + Marshal.GetLastWin32Error()); return IntPtr.Zero; } @@ -112,7 +112,7 @@ result = Win32.Function.GetRawInputDeviceInfo(hDevice, RawInputDeviceInfoType.RIDI_PREPARSEDDATA, ppData, ref ppDataSize); if (result <= 0) { - Debug.WriteLine("Failed to get raw input pre-parsed data" + result + Marshal.GetLastWin32Error()); + Debug.WriteLine("Failed to get raw input pre-parsed data: " + result + " : " + Marshal.GetLastWin32Error()); return IntPtr.Zero; } return ppData;