diff -r 89dfad9633b2 -r 687cace560d2 Win32RawInput.cs
--- a/Win32RawInput.cs Sun Feb 15 13:30:54 2015 +0100
+++ b/Win32RawInput.cs Sun Feb 15 18:15:41 2015 +0100
@@ -13,7 +13,14 @@
public extern static uint GetRawInputData(IntPtr hRawInput, uint uiCommand, IntPtr pData, ref uint pcbSize, uint cbSizeHeader);
[DllImport("User32.dll", SetLastError=true)]
- public extern static int GetRawInputDeviceInfo(IntPtr hDevice, uint uiCommand, IntPtr pData, ref uint pcbSize);
+ public extern static int GetRawInputDeviceInfo(IntPtr hDevice, RawInputDeviceInfoType uiCommand, IntPtr pData, ref uint pcbSize);
+
+ [DllImport("user32.dll", SetLastError = true)]
+ public static extern int GetRawInputDeviceList(
+ [In, Out] RAWINPUTDEVICELIST[] InputdeviceList,
+ [In, Out] ref uint puiNumDevices,
+ [In] uint cbSize);
+
}
@@ -64,33 +71,8 @@
public const int WM_KEYDOWN = 0x0100;
public const int WM_INPUT = 0x00FF;
- ///
- /// GetRawInputDeviceInfo pData points to a string that contains the device name.
- ///
- public const uint RIDI_DEVICENAME = 0x20000007;
- ///
- /// GetRawInputDeviceInfo For this uiCommand only, the value in pcbSize is the character count (not the byte count).
- ///
- public const uint RIDI_DEVICEINFO = 0x2000000b;
- ///
- /// GetRawInputDeviceInfo pData points to an RID_DEVICE_INFO structure.
- ///
- public const uint RIDI_PREPARSEDDATA = 0x20000005;
-
- ///
- /// Data comes from a mouse.
- ///
- public const uint RIM_TYPEMOUSE = 0;
- ///
- /// Data comes from a keyboard.
- ///
- public const uint RIM_TYPEKEYBOARD = 1;
- ///
- /// Data comes from an HID that is not a keyboard or a mouse.
- ///
- public const uint RIM_TYPEHID = 2;
-
+ //
public const int RID_INPUT = 0x10000003;
public const int RID_HEADER = 0x10000005;
@@ -181,12 +163,52 @@
public const int FAPPCOMMAND_OEM = 0x1000;
}
+ ///
+ /// Introduced this enum for consistency and easy of use.
+ /// Naming of the Win32 constants were preserved.
+ ///
+ public enum RawInputDeviceType : uint
+ {
+ ///
+ /// Data comes from a mouse.
+ ///
+ RIM_TYPEMOUSE = 0,
+ ///
+ /// Data comes from a keyboard.
+ ///
+ RIM_TYPEKEYBOARD = 1,
+ ///
+ /// Data comes from an HID that is not a keyboard or a mouse.
+ ///
+ RIM_TYPEHID = 2
+ }
+
+ ///
+ /// Introduced this enum for consistency and easy of use.
+ /// Naming of the Win32 constants were preserved.
+ ///
+ public enum RawInputDeviceInfoType : uint
+ {
+ ///
+ /// GetRawInputDeviceInfo pData points to a string that contains the device name.
+ ///
+ RIDI_DEVICENAME = 0x20000007,
+ ///
+ /// GetRawInputDeviceInfo For this uiCommand only, the value in pcbSize is the character count (not the byte count).
+ ///
+ RIDI_DEVICEINFO = 0x2000000b,
+ ///
+ /// GetRawInputDeviceInfo pData points to an RID_DEVICE_INFO structure.
+ ///
+ RIDI_PREPARSEDDATA = 0x20000005
+ }
+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct RAWINPUTDEVICELIST
{
public IntPtr hDevice;
- public uint dwType;
+ public RawInputDeviceType dwType;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -206,7 +228,7 @@
public struct RAWINPUTHEADER
{
[MarshalAs(UnmanagedType.U4)]
- public int dwType;
+ public RawInputDeviceType dwType;
[MarshalAs(UnmanagedType.U4)]
public int dwSize;
public IntPtr hDevice;
@@ -331,7 +353,8 @@
[FieldOffset(0)]
public uint cbSize;
[FieldOffset(4)]
- public uint dwType;
+ [MarshalAsAttribute(UnmanagedType.U4)]
+ public RawInputDeviceType dwType;
[FieldOffset(8)]
public RID_DEVICE_INFO_MOUSE mouse;
[FieldOffset(8)]