1.1 --- a/HidDevice.cs Sat Feb 14 23:23:41 2015 +0100
1.2 +++ b/HidDevice.cs Sat Feb 14 23:41:12 2015 +0100
1.3 @@ -4,6 +4,7 @@
1.4 using System.Diagnostics;
1.5 using System.Text;
1.6 using Microsoft.Win32.SafeHandles;
1.7 +using Win32;
1.8
1.9 namespace Hid
1.10 {
1.11 @@ -19,6 +20,8 @@
1.12 public ushort ProductId { get; private set; }
1.13 public ushort Version { get; private set; }
1.14 public IntPtr PreParsedData {get; private set;}
1.15 + public RID_DEVICE_INFO Info { get {return iInfo;} }
1.16 + private RID_DEVICE_INFO iInfo;
1.17
1.18 /// <summary>
1.19 /// Class constructor will fetch this object properties from HID sub system.
1.20 @@ -32,6 +35,17 @@
1.21
1.22 //Get our HID descriptor pre-parsed data
1.23 PreParsedData = Win32.Utils.RawInput.GetPreParsedData(hRawInputDevice);
1.24 + if (PreParsedData == IntPtr.Zero)
1.25 + {
1.26 + throw new Exception("HidDevice: GetPreParsedData failed!");
1.27 + }
1.28 +
1.29 + //Fetch device info
1.30 + iInfo = new RID_DEVICE_INFO();
1.31 + if (!Win32.Utils.RawInput.GetDeviceInfo(hRawInputDevice, ref iInfo))
1.32 + {
1.33 + throw new Exception("HidDevice: GetDeviceInfo failed!");
1.34 + }
1.35
1.36 //Open our device from the device name/path
1.37 SafeFileHandle handle=Win32.Function.CreateFile(Name,
1.38 @@ -43,6 +57,7 @@
1.39 IntPtr.Zero
1.40 );
1.41
1.42 + //TODO: should we throw instead?
1.43 if (handle.IsInvalid)
1.44 {
1.45 Debug.WriteLine("Failed to CreateFile from device name " + Marshal.GetLastWin32Error().ToString());