Jump to content
  • Advertisement
Sign in to follow this  
DMatovich

Implementing Mouse Acceleration

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

So I finally get to the point in my UI for a game that I'm working on where I have to stop falling back on the Windows API for tracking Mouse Position. Although I use DirectInput exclusively for input capture, I was simply querying cursor position whenever I got a MouseDelta event for DirectInput. MouseDelta at that point, was only directly used by the game itself, so discrepancies between delta amount and cursor movement where not noticable. Now I have GUI controls that depend on MouseDelta events being at the same amount as the actual cursor movement, so I recoded my cursor code really quick to use a sensitivity amount multiplied by the delta I get from DirectInput. (with a fractional movement accumulater for smoothness). It works just fine, no issues there, fairly common stuff. I immediately notice, however, that I have no mouse acceleration. Its not entirely necessary, but its a nice touch, and if its simple (read: not _really_ hard) to implement I would like to do so. Trouble is a quick google search doesn't turn up anything but pages of articles talking about how DirectInput _does_not_ take acceleration into account :(. Does anybody have or know where I can locate any information on implementing mouse acceleration myself for my GUI? I suppose that this could go in a number of threads, but since I'm using DirectInput I felt it belonged here the best. Thanks in advance for your time! -Dave

Share this post


Link to post
Share on other sites
Advertisement
One simple method would be to scale your sensitivity by some factor of the delta. For example, if you determine that a delta of 20 represents "normal" movement, then a delta of 40 would represent faster movement. If you change your formula to (sensitivity * delta * delta/20) you would get accelerated movement for larger deltas and decelerated movement for smaller deltas. You can play with the factor to come up with something that feels comfortable.

You could get fancy and use some logarithmic function, but I think the above method could be tweaked to give quite usable results.

Share this post


Link to post
Share on other sites
Thanks for your reply Dave. I think your right, this should give quite usable results. I was thinking of one of those aforementioned "fancy logarithmic functions" when I asked the question, but I think this simple solution will do everything I need (and be more efficient, at that).

Thanks again,

-Dave

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!