Jump to content
  • Advertisement
Sign in to follow this  

[.net] [VB.NET]DirectInput & mouse issue

This topic is 2923 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

Hi guys,I'm working on a particle system on DX9 and I wanted to set the particles originating point to the mouse coordinates,so it should look like the particles are following the mouse.

I can create the DI device,but when I try to get the MouseState.X or .Y it trows me the coordinate then it goes back to 0,am I doing anything wrong?.

Here's some code:

mouse = New DirectInput.Device(SystemGuid.Mouse)
mouse.SetCooperativeLevel(Me.Handle, CooperativeLevelFlags.NonExclusive Or CooperativeLevelFlags.Background)

And this is the code I use to retrieve the coordinates:

mouseState = mouse.CurrentMouseState
pos = New Vector3(mouseState.X,mouseState.Y,0)

Thanks in advance.

Share this post

Link to post
Share on other sites
That's probably because you get relative coordinates, i.e. a delta value. Do you get negative values, too ? So you have to emulate the absolute position yourself: Adding the delta to member variable currentPosition and clamp the latter to your views/windows bounds.

By the way: Assuming you are in the context of Windows.Forms you are better off using the MouseMove event. In this case the coords will match your desktops mouse pointer coords.

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!