Changing mouse sensitivity

BlitzMax Forums/BlitzMax Programming/Changing mouse sensitivity

TomToad(Posted 2006) [#1]
I'm wanting to change the sensitivity of the mouse in a game. In other words, lowering the sensitivity will require bigger mouse movement to move the pointer the same amount and raising the sensitivity will require less mouse movement to move the pointer. I have come up with a program posted here.

This will work. It'll even reverse the mouse movement if you set the sensitivity to a negative value. Is this a good way to do it or is there a better way?


Gabriel(Posted 2006) [#2]
I've done this. The problem IIRC ( and it has been a while ) is that Blitz's mouselag problem causes some input to get dropped altogether. Meaning that after some time, the mouse gets out of sync with where you really are, and it reaches a point where it thinks the edge of the screen is somewhere less than the edge of the screen.

This *may* not still be an issue, but it's a consideration. If it *is* still a problem, you need to integrate a gentle move back towards the true mouse position without interfering with the mouse input too much. It can be tricky to do this without the user feeling like the mouse has a mind of it's own.

Ideally, BRL would implement a proper system for this so we can set the mouse sensitivity directly. Most similar languages/engines seem to do that.


VP(Posted 2006) [#3]
If you center the mouse every time you go through your mainloop, you'll avoid any problems re: screen edge.


TomToad(Posted 2006) [#4]
Yes, my example centers the mouse every time GetMouseX() or GetMouseY() is called, which is called each time through the loop.
I did notice one problem though. If you have a high mouse sensitivity setting, the movement becomes more coarse. For example, a sensitivity of 4 will cause the mouse to move in groups of 4 pixels at a time. This is because the final mouse movement is calculated as a multiple of the true mouse movement. So the true mouse moves one pixel and the final mouse moves 4 pixels.