# 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.

## 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 on other sites
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 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 on other sites
You're very welcome!

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633345
• Total Posts
3011441
• ### Who's Online (See full list)

There are no registered users currently online

×