diff -r 0d9f479cbbf7 -r 2044181ade12 Win32RawInput.cs
--- a/Win32RawInput.cs Mon Nov 24 16:46:26 2014 +0100
+++ b/Win32RawInput.cs Mon Nov 24 18:20:45 2014 +0100
@@ -16,9 +16,61 @@
public extern static int GetRawInputDeviceInfo(IntPtr hDevice, uint uiCommand, IntPtr pData, ref uint pcbSize);
}
+
+ static partial class Macro
+ {
+ ///
+ /// Retrieves the input code from wParam in WM_INPUT.
+ /// See RIM_INPUT and RIM_INPUTSINK.
+ ///
+ ///
+ ///
+ public static int GET_RAWINPUT_CODE_WPARAM(IntPtr wParam)
+ {
+ return (wParam.ToInt32() & 0xff);
+ }
+
+ public static int GET_APPCOMMAND_LPARAM(IntPtr lParam)
+ {
+ return ((short)HIWORD(lParam.ToInt32()) & ~Const.FAPPCOMMAND_MASK);
+ }
+
+ public static int GET_DEVICE_LPARAM(IntPtr lParam)
+ {
+ return ((ushort)(HIWORD(lParam.ToInt32()) & Const.FAPPCOMMAND_MASK));
+ }
+
+ public static int HIWORD(int val)
+ {
+ return ((val >> 16) & 0xffff);
+ }
+
+
+ //#define HIWORD(l) ((WORD)((((DWORD_PTR)(l)) >> 16) & 0xffff))
+ //#define LOWORD(l) ((WORD)(((DWORD_PTR)(l)) & 0xffff))
+ //#define LOBYTE(w) ((BYTE)(((DWORD_PTR)(w)) & 0xff))
+ //#define HIBYTE(w) ((BYTE)((((DWORD_PTR)(w)) >> 8) & 0xff))
+
+ //#define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK))
+ //#define GET_DEVICE_LPARAM(lParam) ((WORD)(HIWORD(lParam) & FAPPCOMMAND_MASK))
+ //#define GET_MOUSEORKEY_LPARAM GET_DEVICE_LPARAM
+ //#define GET_FLAGS_LPARAM(lParam) (LOWORD(lParam))
+ //#define GET_KEYSTATE_LPARAM(lParam) GET_FLAGS_LPARAM(lParam)
+
+ }
+
+
+
static partial class Const
{
///
+ /// Windows Messages
+ ///
+ public const int WM_KEYDOWN = 0x0100;
+ public const int WM_APPCOMMAND = 0x0319;
+ public const int WM_INPUT = 0x00FF;
+
+ ///
/// GetRawInputDeviceInfo pData points to a string that contains the device name.
///
public const uint RIDI_DEVICENAME = 0x20000007;
@@ -48,6 +100,91 @@
public const int RID_INPUT = 0x10000003;
public const int RID_HEADER = 0x10000005;
+ ///
+ /// Possible value taken by wParam for WM_INPUT.
+ ///
+ /// Input occurred while the application was in the foreground. The application must call DefWindowProc so the system can perform cleanup.
+ ///
+ public const int RIM_INPUT = 0;
+ ///
+ /// Possible value taken by wParam for WM_INPUT.
+ ///
+ /// Input occurred while the application was not in the foreground. The application must call DefWindowProc so the system can perform the cleanup.
+ ///
+ public const int RIM_INPUTSINK = 1;
+
+ ///
+ /// If set, the application command keys are handled. RIDEV_APPKEYS can be specified only if RIDEV_NOLEGACY is specified for a keyboard device.
+ ///
+ public const uint RIDEV_APPKEYS = 0x00000400;
+
+ ///
+ /// If set, the mouse button click does not activate the other window.
+ ///
+ public const uint RIDEV_CAPTUREMOUSE = 0x00000200;
+
+ ///
+ /// If set, this enables the caller to receive WM_INPUT_DEVICE_CHANGE notifications for device arrival and device removal.
+ /// Windows XP: This flag is not supported until Windows Vista
+ ///
+ public const uint RIDEV_DEVNOTIFY = 0x00002000;
+
+ ///
+ /// If set, this specifies the top level collections to exclude when reading a complete usage page. This flag only affects a TLC whose usage page is already specified with RIDEV_PAGEONLY.
+ ///
+ public const uint RIDEV_EXCLUDE = 0x00000010;
+
+ ///
+ /// If set, this enables the caller to receive input in the background only if the foreground application does not process it. In other words, if the foreground application is not registered for raw input, then the background application that is registered will receive the input.
+ /// Windows XP: This flag is not supported until Windows Vista
+ ///
+ public const uint RIDEV_EXINPUTSINK = 0x00001000;
+
+ ///
+ /// If set, this enables the caller to receive the input even when the caller is not in the foreground. Note that hwndTarget must be specified.
+ ///
+ public const uint RIDEV_INPUTSINK = 0x00000100;
+
+ ///
+ /// If set, the application-defined keyboard device hotkeys are not handled. However, the system hotkeys; for example, ALT+TAB and CTRL+ALT+DEL, are still handled. By default, all keyboard hotkeys are handled. RIDEV_NOHOTKEYS can be specified even if RIDEV_NOLEGACY is not specified and hwndTarget is NULL.
+ ///
+ public const uint RIDEV_NOHOTKEYS = 0x00000200;
+
+ ///
+ /// If set, this prevents any devices specified by usUsagePage or usUsage from generating legacy messages. This is only for the mouse and keyboard. See Remarks.
+ ///
+ public const uint RIDEV_NOLEGACY = 0x00000030;
+
+ ///
+ /// If set, this specifies all devices whose top level collection is from the specified usUsagePage. Note that usUsage must be zero. To exclude a particular top level collection, use RIDEV_EXCLUDE.
+ ///
+ public const uint RIDEV_PAGEONLY = 0x00000020;
+
+ ///
+ /// If set, this removes the top level collection from the inclusion list. This tells the operating system to stop reading from a device which matches the top level collection.
+ ///
+ public const uint RIDEV_REMOVE = 0x00000001;
+
+ public const int APPCOMMAND_BROWSER_BACKWARD = 1;
+ public const int APPCOMMAND_VOLUME_MUTE = 8;
+ public const int APPCOMMAND_VOLUME_DOWN = 9;
+ public const int APPCOMMAND_VOLUME_UP = 10;
+ public const int APPCOMMAND_MEDIA_NEXTTRACK = 11;
+ public const int APPCOMMAND_MEDIA_PREVIOUSTRACK = 12;
+ public const int APPCOMMAND_MEDIA_STOP = 13;
+ public const int APPCOMMAND_MEDIA_PLAY_PAUSE = 14;
+ public const int APPCOMMAND_MEDIA_PLAY = 46;
+ public const int APPCOMMAND_MEDIA_PAUSE = 47;
+ public const int APPCOMMAND_MEDIA_RECORD = 48;
+ public const int APPCOMMAND_MEDIA_FAST_FORWARD = 49;
+ public const int APPCOMMAND_MEDIA_REWIND = 50;
+ public const int APPCOMMAND_MEDIA_CHANNEL_UP = 51;
+ public const int APPCOMMAND_MEDIA_CHANNEL_DOWN = 52;
+
+ public const int FAPPCOMMAND_MASK = 0xF000;
+ public const int FAPPCOMMAND_MOUSE = 0x8000;
+ public const int FAPPCOMMAND_KEY = 0;
+ public const int FAPPCOMMAND_OEM = 0x1000;
}
@@ -60,7 +197,7 @@
[MarshalAs(UnmanagedType.U2)]
public ushort usUsage;
[MarshalAs(UnmanagedType.U4)]
- public int dwFlags;
+ public uint dwFlags;
public IntPtr hwndTarget;
}