Get cursor x and y values using RAWINPUT

I need to use RAWINPUT instead of GetCursorPos because I am trying to get the x and y values while in a game. If I use GetCursorPos, the x and y values will constantly be at the center of the screen because that's how the game works. I read that RAWINPUT was perfect for cases like this but I am lost on how to properly use it. I have many questions after working on trying to figure it out for many hours.

Am I headed in the right direction?

Why won't this print out "Input" when I move my mouse?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main()
{
	LPARAM SwitchLParam = 0;
	while(1)
	{
		switch (SwitchLParam)
		{
			case WM_MOUSEMOVE:
			{
				cout << "Input" << endl;
			}
		}
	}
}


On this page: http://msdn.microsoft.com/en-us/library/windows/desktop/ms645596(v=vs.85).aspx it says I need a handle to the RAWINPUT structure, how do I make a handle to it?

My final goal is to get the lLastX and lLastY values from this structure:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
typedef struct tagRAWMOUSE {
  USHORT usFlags;
  union {
    ULONG  ulButtons;
    struct {
      USHORT usButtonFlags;
      USHORT usButtonData;
    };
  };
  ULONG  ulRawButtons;
  LONG   lLastX;
  LONG   lLastY;
  ULONG  ulExtraInformation;
} RAWMOUSE, *PRAWMOUSE, *LPRAWMOUSE;


How do I get them?
Help please :<

I have been working on it constantly but I can only get this figured out faster with help.
Last edited on
Topic archived. No new replies allowed.