• Advertisement
Sign in to follow this  

Managed DirectInput - Mouse

This topic is 4897 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 having issues with getting the state of the mouse in managed DirectInput. I've scoured the forums, searched for tutorials, but so far I've come up empty. I'm using the Visual C# 2005 Express Beta.
mouse.SetCooperativeLevel(parent, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Foreground);
mouse.SetDataFormat(DeviceDataFormat.Mouse);
mouse.Acquire();

It throws an "ArgumentException" when I try to get the device state.
return mouse.GetDeviceState(typeof(MouseState));

I've tried different cooperative levels, and Ive tried different parameters to the call to GetDeviceState. All yield the same result. Does anyone know whats wrong? If you think I would be better off not using DirectInput for my mouse can you tell me why? thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Just use the CurrentMouseState property in Device. I believe that to use GetDeviceState you also have to use SetDataFormat so the device knows what kind of data it is gathering.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
GetDeviceState takes 2 arguments

the size of the device state struct and the pointer to it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement