Jump to content
  • Advertisement
Sign in to follow this  
ProgrammerZ

setting the cursor position

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

Hey y'all.... I'm programming a simple engine to build my games upon, and I was wondering how to move the cursor to a certain position, like in an FPS where you move the mouse to aim, and you'd have to center the mouse every frame so you didn't run into the edge of the screen. I saw on some post that you didn't need to center the mouse if you used DirectInput; you could just get the mouse movement even if the mouse was at the edge of the screen, but I programmed a demo and found that it doesn't work that way. I've also read that the Win32 SetCursorPos() function can produce terrible results; anyone have any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
What I do is use directInput.

for every frame update I retrieve the data for the device, which gives me the button clicks, changes in position etc..

IDirectInputDevice::GetDeviceData( sizeof(DIDEVICEOBJECTDATA), DIDEVICEOBJECTDATA, &num, 0 );


I then check for changes in the data and store that information until the next frame update.

When I create my mouse, I make sure to use these flags: DISCL_FOREGROUND | DISCL_EXCLUSIVE cooperative levels

MSDN about coop levels

Share this post


Link to post
Share on other sites
I just switched my dxinput code to WM_INPUT, and the improvements were noticeable ( thanks to the above replies )...

I'd like to change my answer to "Use WM_INPUT" instead of "DXInput"

Share this post


Link to post
Share on other sites
Thanks for all the replies, guys! I thought I read somewhere that DirectInput wasn't recommended, but I wasn't sure where I saw it.

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!