Skip to main content
GameDev.net gamedev.net
🔒 Locked

Managed DirectInput - Mouse

Started by Cosmosis Sep 20, 2004 at 10:47 PM 1 replies 500+ views
Original Post
Cosmosis
Cosmosis
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!
turnpast
turnpast
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.