not receiving WM_INPUT

Started by
7 comments, last by ProgrammerZ 15 years, 9 months ago
Hey there! I was programming an input module for my game engine (anyone who's seen any of my last 10 posts knows this) and I was trying to add support for raw input (they'll know that too). Anyway, for some reason, I'm not receiving WM_INPUT messages. I fixed it so the program would display a little message box when I received a WM_INPUT message, and I haven't gotten any message boxes. Can anyone tell me why I moght not be getting WM_INPUT? --ProgrammerZ
Advertisement
Yep, and it's quite easy. A quick look at WM_INPUT on MSDN would have cleared that problem out :

Quote:
Remarks
Raw input is available only when the application calls RegisterRawInputDevices with valid device specifications


... so head on to RegisterRawInputDevices on MSDN to see how to setup to get those messages.
It might be easier with this MSDN sample.
I've already seen that sample....I registered my RAWINPUTDEVICE, so what could be the problem?
(Psst. This is when you show the code.)
I've got this exact same problem, been meaning to look into it for a while now. I suspected the problem is that my DirectX SDK version is too old, or some problem with the _WIN32_WINNT #define... which version are you using?
Here's my code: (sorry, don't know how to do those little code snippet thingys yet)

InputManager.h

/* clipped */

class InputManager
{
private:

RAWINPUTDEVICE m_RawInputDevice[1]; // our raw input device

/* clipped */

public:

/* clipped -- input methods */
};

And in the InputManager::Initialize((/* blah blah blah */) function


m_RawInputDevice[0].usUsagePage = HID_USAGE_PAGE_GENERIC;
m_RawInputDevice[0].usUsage = HID_USAGE_GENERIC_MOUSE;
m_RawInputDevice[0].dwFlags = RIDEV_NOLEGACY;
m_RawInputDevice[0].hwndTarget = 0;

if (!RegisterRawInputDevices(m_RawInputDevice, 1, sizeof(m_RawInputDevice[0])))
{
ShowError(L"InputManager::Initialize() -- RegisterRawInputDevices failed!");
return false;
}

in the InputManager::RespondToWM(/* blah blah blah */) function

switch (message)
{
/* clipped */

case WM_INPUT:
{
UINT dwSize = 40;
static BYTE lpb[40];
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER));

static RAWINPUT* raw = (RAWINPUT*)lpb;
if (raw->header.dwType == RIM_TYPEMOUSE)
{
int m_iMouseXDelta = raw->data.mouse.lLastX;
int m_iMouseYDelta = raw->data.mouse.lLastY;
}

} break;

}

Am I doing this the right way?


Okay, update. As I was posting that last post, I tried compiling my code. It worked!

I swear I didn't change anything. Does anyone know why this might be happening?
Another update: My program did compile, but when I run it, my computer is as slow as molasses. Hmmm....

This topic is closed to new replies.

Advertisement