Sign in to follow this  
neodasan

processing two mouse events - is this possible?

Recommended Posts

neodasan    126
Hello, When attaching two USB mice to a single computer, the mouse events are aggregated to reflect movement in the single cursor. Is there a way to log the amount of movement each mouse attributes to the final cursor movement. For example, when the cursor has moved 1000 pixels in a given direction, is there a way to log the individual input from Mouse 1 and Mouse 2 which corresponded in this movement?

Share this post


Link to post
Share on other sites
Evil Steve    2017
What platform / API / language? This might be possible with DirectInput; the DirectX Caps Viewer (Which comes with the DirectX SDK) will be able to tell you (Since there'll be more than one mouse visible there).

For Win32, and I believe SDL on Windows (Although I'm not entirely sure), the OS combines all mouse input into one device, so you won't be able to do it.

Share this post


Link to post
Share on other sites
neodasan    126
Quote:
Original post by mattd
You should be able to use Raw Input to get data from each mouse separately.


Thanks! but Raw Mouse Input just returns x and y based on the single mouse cursor position. I guess I need each mouse's movement information regardless of the "unified" cursor.

Share this post


Link to post
Share on other sites
mattd    1078
Are you sure? You should be able to enumerate two seperate devices, register for raw input messages on both, and be able to tell which mouse is doing the moving when one moves.

This site thinks so too..

Share this post


Link to post
Share on other sites
neodasan    126
Quote:
Original post by mattd
Are you sure? You should be able to enumerate two seperate devices, register for raw input messages on both, and be able to tell which mouse is doing the moving when one moves.

This site thinks so too..


Thanks, Mattd again.

Then what is lLastX and lLastY of RAW MOUSE INPUT http://msdn.microsoft.com/en-us/library/ms645578(VS.85).aspx ? I though they are the relative x and y values based on the current mouse position (each mouse). Am I wrong? Anybody knows what this values come from?







Share this post


Link to post
Share on other sites
iMalc    2466
As per that page, it's the "signed relative motion or absolute motion, depending on the value of usFlags", for one of your mice. I imagine you get packets that correspond to both mice and something in each packet tells you which one it came from.

You seem to be posting stuff in disbelief without actually trying it. I will tell you now, that raw input is made to allow this and there would be nothing else on Windows that will. So what are you waiting for? Start using it!

Share this post


Link to post
Share on other sites
neodasan    126
Quote:
Original post by iMalc
As per that page, it's the "signed relative motion or absolute motion, depending on the value of usFlags", for one of your mice. I imagine you get packets that correspond to both mice and something in each packet tells you which one it came from.

You seem to be posting stuff in disbelief without actually trying it. I will tell you now, that raw input is made to allow this and there would be nothing else on Windows that will. So what are you waiting for? Start using it!


Thanks, iMalc! No I've already tried RAW MOUSE INPUT stuffs. Just not sure what its lLastX and lLastY values are exactly and how I should make use of them to measure two different mouse movements. That's my question.

Share this post


Link to post
Share on other sites
UltimaX    468
Here is a web page with a few samples (even a wrapper) for this. Look at these and you will see how they are used for relative, absolute, etc.

http://www.jstookey.com/arcade/rawmouse/

Please note though that this is only supported under Windows XP!
-It's available in Windows XP and up; sorry about that.


[EDIT]
Perhaps the Windows MultiPoint Mouse SDK is a great solution for what you are trying to accomplish? It states that it's used for WPF, but it's .NET so it's worth a shot. It allows up to 25 mouse devices at once...

http://www.microsoft.com/multipoint/mouse-sdk/developer.aspx

[Edited by - UltimaX on February 17, 2010 12:26:13 PM]

Share this post


Link to post
Share on other sites
mattd    1078
Quote:
Original post by UltimaX
Here is a web page with a few samples (even a wrapper) for this. Look at these and you will see how they are used for relative, absolute, etc.

http://www.jstookey.com/arcade/rawmouse/

Please note though that this is only supported under Windows XP!

Windows XP is the minimum version that supports Raw Input, not the only version. (Check MSDN)

Share this post


Link to post
Share on other sites
mattd    1078
Quote:
Original post by neodasan
Quote:
Original post by iMalc
As per that page, it's the "signed relative motion or absolute motion, depending on the value of usFlags", for one of your mice. I imagine you get packets that correspond to both mice and something in each packet tells you which one it came from.

You seem to be posting stuff in disbelief without actually trying it. I will tell you now, that raw input is made to allow this and there would be nothing else on Windows that will. So what are you waiting for? Start using it!


Thanks, iMalc! No I've already tried RAW MOUSE INPUT stuffs. Just not sure what its lLastX and lLastY values are exactly and how I should make use of them to measure two different mouse movements. That's my question.

Those values contain either relative or absolute mouse coordinates. You can tell which kind they are by looking at the flags part of the RAWMOUSE structure. (You have read the MSDN docs, right? :])

You differentiate which mouse is giving this motion by looking at the hDevice member of RAWINPUTHEADER, which is the RAWINPUTs you get in the WM_INPUT raw input handler.

EDIT: If you mean you need to know how to the "when the cursor has moved 1000 pixels in a given direction" bit you mentioned in your OP, you'll need to store a start coordinate, and calculate the distance from the current mouse position on each mouse update. If it's >= 1000px, perform your action.

Share this post


Link to post
Share on other sites
Evil Steve    2017
Quote:
Original post by mattd
EDIT: If you mean you need to know how to the "when the cursor has moved 1000 pixels in a given direction" bit you mentioned in your OP, you'll need to store a start coordinate, and calculate the distance from the current mouse position on each mouse update. If it's >= 1000px, perform your action.
Raw input from mice is in device units rather than pixels, so you'll also need some sort of mouse sensitivity setting to convert from mouse units to pixels.

Also note that raw input is unfiltered and does not have pointer ballistics applied to it, so the mouse pointer may feel "heavy" (E.g. Unreal Tournament 2004's UI uses raw input (through DirectInput) and feels awful).

What exactly are you trying to use multiple mice for?

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