Search code examples
c++winapiraw-input

What does `RAWINPUT::header::wParam` contain for keyboard input


On looking at the MSDN documentation for RAWINPUT structure, it has the following declaration:

typedef struct tagRAWINPUT {
  RAWINPUTHEADER header;
  union {
    RAWMOUSE    mouse;
    RAWKEYBOARD keyboard;
    RAWHID      hid;
  } data;
} RAWINPUT, *PRAWINPUT, *LPRAWINPUT;

Further, the RAWINPUTHEADER struct contains these:

typedef struct tagRAWINPUTHEADER {
  DWORD  dwType;
  DWORD  dwSize;
  HANDLE hDevice;
  WPARAM wParam;
} RAWINPUTHEADER, *PRAWINPUTHEADER;

Of which the thing of interest is the member wParam:

wParam

Type: WPARAM

The value passed in the wParam parameter of the WM_INPUT message.

So, what exactly does this wParam contain? (specifically for keyboard KEYDOWN input?)


Solution

  • The documentation for WM_INPUT tells you this information:

    wParam
    The input code. This parameter can be one of the following values.

    RIM_INPUT
    0
    Input occurred while the application was in the foreground. The application must call DefWindowProc so the system can perform cleanup.

    RIM_INPUTSINK
    1
    Input occurred while the application was not in the foreground. The application must call DefWindowProc so the system can perform the cleanup.