Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raw mouse input with Windows

Reading this article "Taking Advantage of High-Definition Mouse Movement" - http://msdn.microsoft.com/en-us/library/windows/desktop/ee418864(v=vs.100).aspx, I surmise that one should use raw input for more precise readings from input devices.

The article states that WM_MOUSEMOVE's primary disadvantage is that it is limited to the screen resolution.

Upon close inspection of the RAWMOUSE structure I see that lLastX and lLastY are long values and you get the delta via them.

To me it looks like WM_MOUSEMOVE and WM_INPUT is the same except with WM_INPUT you do not get acceleration (pointer ballistics) applied.

Are both WM_MOUSEMOVE and WM_INPUT limited to the screen resolution?

If so, what is the benefit of using WM_INPUT?

like image 430
links77 Avatar asked May 05 '12 13:05

links77


People also ask

Is raw input good for mouse?

The meaning of raw input is pretty intuitive. Enabling it causes the game to receive the mouse input directly from the hardware mouse to the game engine. This causes the movement of the crosshair to be more precise and dependent on nothing else but the game's amount of frames per second.

Do FPS games use raw mouse input?

FPS games typically use raw input, which bypasses any acceleration settings in the OS. This works on both Windows and macOS, assuming the game is properly written.

Is raw input or direct input better?

Raw Input is best, as the name implies: it's the pure data from your mouse, what it doesn't say is, it's without Windows meddling in the mouse input data. Thus "Raw".


2 Answers

RAWMOUSE gives you logical coordinates for the mouse based on the mouse's native resolution.

That is, you see the actual movement of the mouse.

Windows will use the mouse speed and acceleration (ballistics) settings to update the cursor position. Because of course the two are not linked - the apparent movement of the mouse must be interpreted to generate a cursor movement else how can more than one mouse be supported?

If you wish to control a pointer, as far as I can tell there is no reason to duplicate the Windows mouse ballistics calculations. Just let windows do it. Therefore for controlling the pointer, you should just use WM_MOUSEMOVE. That is, unless you wish to disable the mouse acceleration settings in your application.

However, if you want to control the player's POV (point of view), or use the mouse to control an in-game object such as a spaceship flight yoke, then the RAWMOUSE data gives you the best possible access to the movement of the mouse, and you can implement your own algorithm to convert that into flight yoke/POV movement.

like image 129
Ben Avatar answered Oct 28 '22 06:10

Ben


The main benefit and reason to use it is that that with rawInput you can use two mouses or more. Presently I write small game prototype which is designed to be played by two players with two mouses/mices - It is more complicated but It works and it is not bad because I do nod need to link external libs.

like image 32
grunge fightr Avatar answered Oct 28 '22 05:10

grunge fightr