Jump to content
  • Advertisement
Sign in to follow this  
Taram

Mouse movement question

This topic is 4723 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 am using WM_MOUSEMOVE to get the x,y coordinates of the mouse cursor. However, it stops showing changes when it reaches the bounds of your screen resolution. I want to record camera position and I don't want it to stop moving when my mouse gets to 1280,1024 (or whatever resolution my screen is at). One solution I can think of is to somehow move the mouse to the center of the screen and then record its movement offset from the origin every frame. This would give me the direction and the magnitude of the movement. Is this the solution that I should use? If so, what windows functions should I look at to manually move the mouse cursor? Or, is there a better way?

Share this post


Link to post
Share on other sites
Advertisement
Every time you get a WM_MOUSEMOVE, you save the cursor position and set the cursors position to the center of the screen. Then you find the change in the saved cursors position from the previously saved cursor position (which should be set to the center of the screen in the beginning obviously) and work with this instead. You can append this delta position to the cameras position of what ever you like.

Share this post


Link to post
Share on other sites
I thought maybe there might be a WM_ message that recorded mouse movement regardless of where the mouse cursor is. Oh well, your method sounds easy enough. Time to google for a SetCursor() function. Thanks!

Share this post


Link to post
Share on other sites
if you dont mind DirectX, DirectInput is easy to use and probably a better choice than trying to use WM_MOUSEMOVE.

Share this post


Link to post
Share on other sites
I'de just like to add that, you don't need to set the cursor to the center of the window everytime you read it, you just need to do it when it leaves the window, cuts a little bit on overhead.

Share this post


Link to post
Share on other sites
I've found using direct input for mouse controls to be a little laggy sometimes. It's really easy to use, but on some of the projects I've been working on the mouse doesn't respond like it should. Has anyone else had this problem with DirectInput?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!