Jump to content
  • Advertisement
Sign in to follow this  
ProgrammerZ

not receiving WM_INPUT

This topic is 3700 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
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?


Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!