Sign in to follow this  
neodasan

measure mouse movement (pixels?) using RAWINPUT?

Recommended Posts

neodasan    126
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

Share this post


Link to post
Share on other sites
XTAL256    106
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.

Share this post


Link to post
Share on other sites
Codeka    1239
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.

Share this post


Link to post
Share on other sites
neodasan    126
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.

Share this post


Link to post
Share on other sites
Codeka    1239
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.

Share this post


Link to post
Share on other sites
neodasan    126
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!


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this