RAWINPUTDEVICE structure (Windows)

Switch View :
ScriptFree
RAWINPUTDEVICE structure

Applies to: desktop apps only

Defines information for the raw input devices.

Syntax

typedef struct tagRAWINPUTDEVICE {
  USHORT usUsagePage;
  USHORT usUsage;
  DWORD  dwFlags;
  HWND   hwndTarget;
} RAWINPUTDEVICE, *PRAWINPUTDEVICE, *LPRAWINPUTDEVICE;

Members

usUsagePage

Type: USHORT

Top level collection Usage page for the raw input device.

usUsage

Type: USHORT

Top level collection Usage for the raw input device.

dwFlags

Type: DWORD

Mode flag that specifies how to interpret the information provided by usUsagePage and usUsage. It can be zero (the default) or one of the following values. By default, the operating system sends raw input from devices with the specified top level collection (TLC) to the registered application as long as it has the window focus.

ValueMeaning
RIDEV_APPKEYS
0x00000400

If set, the application command keys are handled. RIDEV_APPKEYS can be specified only if RIDEV_NOLEGACY is specified for a keyboard device.

RIDEV_CAPTUREMOUSE
0x00000200

If set, the mouse button click does not activate the other window.

RIDEV_DEVNOTIFY
0x00002000

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
RIDEV_EXCLUDE
0x00000010

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.

RIDEV_EXINPUTSINK
0x00001000

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
RIDEV_INPUTSINK
0x00000100

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.

RIDEV_NOHOTKEYS
0x00000200

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.

RIDEV_NOLEGACY
0x00000030

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.

RIDEV_PAGEONLY
0x00000020

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.

RIDEV_REMOVE
0x00000001

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.

 

hwndTarget

Type: HWND

A handle to the target window. If NULL it follows the keyboard focus.

Remarks

If RIDEV_NOLEGACY is set for a mouse or a keyboard, the system does not generate any legacy message for that device for the application. For example, if the mouse TLC is set with RIDEV_NOLEGACY, WM_LBUTTONDOWN and related legacy mouse messages are not generated. Likewise, if the keyboard TLC is set with RIDEV_NOLEGACY, WM_KEYDOWN and related legacy keyboard messages are not generated.

If RIDEV_REMOVE is set and the hwndTarget member is not set to NULL, then parameter validation will fail.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Winuser.h (include Windows.h)

See also

Reference
GetRegisteredRawInputDevices
RegisterRawInputDevices
Conceptual
Raw Input

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Content

discouraged one
Usage Tables new url
http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf

ChGu
List of usage pages and corresponding usage
A list of Usage Pages used for usUsagePage (p. 14) as well as the corresponding Usage for usUsage:

http://www.usb.org/developers/devclass_docs/Hut1_12.pdf

Meta8
RIDEV_EXCLUDE requires hwndTarget to be null
Otherwise it will fail parameter validation.

Đonny
Visual Basic 9 Declaration
  

<StructLayout(LayoutKind.Sequential)> _

Public Structure RAWINPUTDEVICE

<MarshalAs(UnmanagedType.U2)> _

Public usUsagePage As UShort

<MarshalAs(UnmanagedType.U2)> _

Public usUsage As UShort

<MarshalAs(UnmanagedType.U4)> _

Public dwFlags As RAWINPUTDEVICEFlags

Public hwndTarget As IntPtr

End Structure

<Flags()> _

PublicEnum RAWINPUTDEVICEFlags AsInteger

RIDEV_APPKEYS = &H400

RIDEV_CAPTUREMOUSE = &H200

RIDEV_EXCLUDE = &H10

RIDEV_EXINPUTSINK = &H1000

RIDEV_INPUTSINK = &H100

RIDEV_NOHOTKEYS = &H200

RIDEV_NOLEGACY = &H30

RIDEV_PAGEONLY = &H20

RIDEV_REMOVE = &H1

EndEnum


Ondrej Spanel
RIDEV_CAPTUREMOUSE requires RIDEV_NOLEGACY

As seen in the header file, if you want to set RIDEV_CAPTUREMOUSE, you need to set RIDEV_NOLEGACY as well:

#define RIDEV_CAPTUREMOUSE 0x00000200 // effective when mouse nolegacy is specified, otherwise it would be an error


harshaw
RIDEV_EXINPUTSINK
RIDEV_EXINPUTSINK does not appear to work on window XP. Is this only with Vista? The documentation is very scarce.

AFAIK
RIDEV_EXINPUTSINK is defined as 0x1000 in the Vista SDK.