1.1 --- a/Win32RawInput.cs Sun Feb 15 13:30:54 2015 +0100
1.2 +++ b/Win32RawInput.cs Sun Feb 15 18:15:41 2015 +0100
1.3 @@ -13,7 +13,14 @@
1.4 public extern static uint GetRawInputData(IntPtr hRawInput, uint uiCommand, IntPtr pData, ref uint pcbSize, uint cbSizeHeader);
1.5
1.6 [DllImport("User32.dll", SetLastError=true)]
1.7 - public extern static int GetRawInputDeviceInfo(IntPtr hDevice, uint uiCommand, IntPtr pData, ref uint pcbSize);
1.8 + public extern static int GetRawInputDeviceInfo(IntPtr hDevice, RawInputDeviceInfoType uiCommand, IntPtr pData, ref uint pcbSize);
1.9 +
1.10 + [DllImport("user32.dll", SetLastError = true)]
1.11 + public static extern int GetRawInputDeviceList(
1.12 + [In, Out] RAWINPUTDEVICELIST[] InputdeviceList,
1.13 + [In, Out] ref uint puiNumDevices,
1.14 + [In] uint cbSize);
1.15 +
1.16 }
1.17
1.18
1.19 @@ -64,33 +71,8 @@
1.20 public const int WM_KEYDOWN = 0x0100;
1.21 public const int WM_INPUT = 0x00FF;
1.22
1.23 - /// <summary>
1.24 - /// GetRawInputDeviceInfo pData points to a string that contains the device name.
1.25 - /// </summary>
1.26 - public const uint RIDI_DEVICENAME = 0x20000007;
1.27 - /// <summary>
1.28 - /// GetRawInputDeviceInfo For this uiCommand only, the value in pcbSize is the character count (not the byte count).
1.29 - /// </summary>
1.30 - public const uint RIDI_DEVICEINFO = 0x2000000b;
1.31 - /// <summary>
1.32 - /// GetRawInputDeviceInfo pData points to an RID_DEVICE_INFO structure.
1.33 - /// </summary>
1.34 - public const uint RIDI_PREPARSEDDATA = 0x20000005;
1.35
1.36 -
1.37 - /// <summary>
1.38 - /// Data comes from a mouse.
1.39 - /// </summary>
1.40 - public const uint RIM_TYPEMOUSE = 0;
1.41 - /// <summary>
1.42 - /// Data comes from a keyboard.
1.43 - /// </summary>
1.44 - public const uint RIM_TYPEKEYBOARD = 1;
1.45 - /// <summary>
1.46 - /// Data comes from an HID that is not a keyboard or a mouse.
1.47 - /// </summary>
1.48 - public const uint RIM_TYPEHID = 2;
1.49 -
1.50 + //
1.51 public const int RID_INPUT = 0x10000003;
1.52 public const int RID_HEADER = 0x10000005;
1.53
1.54 @@ -181,12 +163,52 @@
1.55 public const int FAPPCOMMAND_OEM = 0x1000;
1.56 }
1.57
1.58 + /// <summary>
1.59 + /// Introduced this enum for consistency and easy of use.
1.60 + /// Naming of the Win32 constants were preserved.
1.61 + /// </summary>
1.62 + public enum RawInputDeviceType : uint
1.63 + {
1.64 + /// <summary>
1.65 + /// Data comes from a mouse.
1.66 + /// </summary>
1.67 + RIM_TYPEMOUSE = 0,
1.68 + /// <summary>
1.69 + /// Data comes from a keyboard.
1.70 + /// </summary>
1.71 + RIM_TYPEKEYBOARD = 1,
1.72 + /// <summary>
1.73 + /// Data comes from an HID that is not a keyboard or a mouse.
1.74 + /// </summary>
1.75 + RIM_TYPEHID = 2
1.76 + }
1.77 +
1.78 + /// <summary>
1.79 + /// Introduced this enum for consistency and easy of use.
1.80 + /// Naming of the Win32 constants were preserved.
1.81 + /// </summary>
1.82 + public enum RawInputDeviceInfoType : uint
1.83 + {
1.84 + /// <summary>
1.85 + /// GetRawInputDeviceInfo pData points to a string that contains the device name.
1.86 + /// </summary>
1.87 + RIDI_DEVICENAME = 0x20000007,
1.88 + /// <summary>
1.89 + /// GetRawInputDeviceInfo For this uiCommand only, the value in pcbSize is the character count (not the byte count).
1.90 + /// </summary>
1.91 + RIDI_DEVICEINFO = 0x2000000b,
1.92 + /// <summary>
1.93 + /// GetRawInputDeviceInfo pData points to an RID_DEVICE_INFO structure.
1.94 + /// </summary>
1.95 + RIDI_PREPARSEDDATA = 0x20000005
1.96 + }
1.97 +
1.98
1.99 [StructLayout(LayoutKind.Sequential, Pack = 1)]
1.100 public struct RAWINPUTDEVICELIST
1.101 {
1.102 public IntPtr hDevice;
1.103 - public uint dwType;
1.104 + public RawInputDeviceType dwType;
1.105 }
1.106
1.107 [StructLayout(LayoutKind.Sequential, Pack = 1)]
1.108 @@ -206,7 +228,7 @@
1.109 public struct RAWINPUTHEADER
1.110 {
1.111 [MarshalAs(UnmanagedType.U4)]
1.112 - public int dwType;
1.113 + public RawInputDeviceType dwType;
1.114 [MarshalAs(UnmanagedType.U4)]
1.115 public int dwSize;
1.116 public IntPtr hDevice;
1.117 @@ -331,7 +353,8 @@
1.118 [FieldOffset(0)]
1.119 public uint cbSize;
1.120 [FieldOffset(4)]
1.121 - public uint dwType;
1.122 + [MarshalAsAttribute(UnmanagedType.U4)]
1.123 + public RawInputDeviceType dwType;
1.124 [FieldOffset(8)]
1.125 public RID_DEVICE_INFO_MOUSE mouse;
1.126 [FieldOffset(8)]