Sign in to follow this  

Raw Input for two mice.

This topic is 4305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to make a game where you can use two mice at the same time. I have it working but there is a small bug (so far). Whenever I move one cursor the other has some 'residual' movement too. It doesn't move in the same direction but it has some movement that shouldn't be there. My code in 'LRESULT CALLBACK default_window_proc' looks like this:
static int M1RelX = 0; 
static int M1RelY = 0;
static int M2RelX = 0;
static int M2RelY = 0;
//   --code removed ---
                 case WM_INPUT: 
		{
		  add_to_raw_mouse_x_and_y((HRAWINPUT)p_lparam);

		        M1RelX += get_raw_mouse_x_delta(1);
			M1RelY += get_raw_mouse_y_delta(1);
			M2RelX += get_raw_mouse_x_delta(2);
			M2RelY += get_raw_mouse_y_delta(2);
		  
		  if (M1RelX > 800){M1RelX = 800;}
		  if (M1RelX < 0){M1RelX = 0;}
		  
		  if (M1RelY > 600){M1RelY = 600; }
		  if (M1RelY < 0){M1RelY = 0; }


		  if (M2RelX > 800){M2RelX = 800; }
		  if (M2RelX < 0){M2RelX = 0;}

		  if (M2RelY > 600){M2RelY = 600;}
                  if (M2RelY < 0){ M2RelY = 0;}
						
		  return 0;
		} 







Definition and declaration files for raw-input functions: raw_mouse.c raw_mouse.h I'm not very fluent with Win32API so I used this page as a starting point. The demo application on that page seems to work fine. However when I try to implement it in my code I get the problem described above. Can anyone point what might be wrong? [Edited by - Calin on March 1, 2006 3:44:58 PM]

Share this post


Link to post
Share on other sites
There was a bit of discussion on using two mice in a recent thread here:

http://www.gamedev.net/community/forums/topic.asp?topic_id=377561&whichpage=1�

About that particular way, I don't have time to play with it, sorry. :(



discman1028

Share this post


Link to post
Share on other sites
I've solved the problem. I found some C# code for RawInput and after adapting my code I got it right. Thanks for that link though, it's good for reference.

Share this post


Link to post
Share on other sites

This topic is 4305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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