measure mouse movement (pixels?) using RAWINPUT?

Started by
4 comments, last by neodasan 14 years, 2 months ago
Hello, I am trying to measure how much users move their mouse. I used raw input. (http://msdn.microsoft.com/en-us/library/ms645536(VS.85).aspx). If I move straight the mouse cursor from the left-end to right-end of my screen, the total x value (added up all relative values) should be roughly screen's horizontal resolution (for example 1280). However, the value is always different depending on moving speed or something else whenever I measure it. I feel if moving speed is slow, the code generates more values... How can I get the exact pixel count(x or y) using raw input?? Thank you
Advertisement
Quote:Original post by neodasan
I feel if moving speed is slow, the code generates more values...

Probably because it's returning a number based on how far the mouse has moved, not the actual screen movement. Moving your mouse faster moves the cursor faster across the screen (in a non-linear fashion).

Why are you using raw input though? If you want to monitor the movement of the cursor outside of the client area (your window), use SetCapture and ReleaseCapture to capture all mouse movements, then process the mouse move events/messages.
[Window Detective] - Windows UI spy utility for programmers
I assume this is for display in some widget or something, so you want to be notified of the movement regardless of whether your app is under the cursor, but you still want other apps to be able to use the mouse normally (so no SetCapture).

What you'll want to do is set up a low-level mouse hook (more info here), since as XTAL256 says, you'll want the data after ballistics (that is, the 'acceleration') has been applied.
Quote:Original post by XTAL256
Quote:Original post by neodasan
I feel if moving speed is slow, the code generates more values...

Probably because it's returning a number based on how far the mouse has moved, not the actual screen movement. Moving your mouse faster moves the cursor faster across the screen (in a non-linear fashion).

Why are you using raw input though? If you want to monitor the movement of the cursor outside of the client area (your window), use SetCapture and ReleaseCapture to capture all mouse movements, then process the mouse move events/messages.


Because I need to use two mice. RAWINPUT can distinct two mice devices.
Quote:Original post by neodasan
Because I need to use two mice. RAWINPUT can distinct two mice devices.
You will need to apply ballistics (also known as "acceleration") to make the cursor feel right, then. That page describes the basic algorithm to convert between the arbitrary numbers that the mouse gives you and "real" units.
Quote:Original post by Codeka
Quote:Original post by neodasan
Because I need to use two mice. RAWINPUT can distinct two mice devices.
You will need to apply ballistics (also known as "acceleration") to make the cursor feel right, then. That page describes the basic algorithm to convert between the arbitrary numbers that the mouse gives you and "real" units.


Dear Codeka, Thank you so much for great advices.
I have only two sets of relative x and ys(lLastX, lLastY) from two mice. How can I calculate using that formula? I tried to solve this, but still don't have a clue....

Actually cursor position is not important. My interest is how i can measure separate movements of two mice regardless of the single cursor...

Sorry!


This topic is closed to new replies.

Advertisement