Reputation: 315
I'm writing a Windows application that uses SendInput to move the mouse without the user having to use an actual mouse. One of its desired features is that it'll create the same movement regardless of what the user's Mouse Speed setting is (assuming they don't have "Enhance pointer precision" checked, so my application shouldn't have to account for "mouse acceleration").
I do this by getting Windows' mouse speed setting and dividing my output by it. So, if the user doubles their mouse speed setting, my application halves its output, and they should cancel out (if the mouse speed setting actually represents a multiplier for the cursor speed).
I've been obtaining the mouse speed setting using SystemParametersInfo(SPI_GETMOUSESPEED...), which, according to Microsoft's documentation, gives the speed on a scale of 1 to 20.
int result;
if (SystemParametersInfo(SPI_GETMOUSESPEED, 0, &result, 0)) {
return result;
}
The problem is this value isn't linearly proportional to the actual mouse speed with a given input. If it were linearly proportional, if a given mouse movement moves the on-screen cursor by distance X, doubling the mouse speed setting and performing the same mouse movement should result in the on-screen cursor moving a distance of 2X. Halving the setting should result in a 0.5X movement on-screen.
But it doesn't work like that.
Even after my application divides its mouse speed by the Windows' mouse speed setting, very low mouse speed settings yield slower-than-expected output.
Is there any documentation that shows how to map the Windows mouse speed to an actual speed (whatever the units), suitable for cancelling this setting out? Or is there a better way for me to go about accounting for the user's mouse speed setting, or to ignore the user's mouse settings entirely?
Thanks!
Upvotes: 1
Views: 2572
Reputation: 315
Liquipedia's Counter-Strike wiki has the answer. This table shows how the notches in Windows' Mouse Speed settings corresponds to different multipliers. The logic appears to be that the middle notch is 1.0 (no change), every step to the right of it increases the multiplier by 0.25, and to the left decreases the sensitivity by 1/8 until it reaches 1/8. It then halves, and halves again.
It's easier to look at the table itself. My application just has this in an array (the middle row, EPP off, which appears to mean these numbers apply when Enhance Pointer Precision is disabled).
I've transcribed the relevant part of the table here. The left column is the number obtained using SystemParametersInfo(SPI_GETMOUSESPEED...), and the right column is the corresponding multiplier:
1 1/32
2 1/16
3 1/8
4 2/8
5 3/8
6 4/8
7 5/8
8 6/8
9 7/8
10 1.0
11 1.25
12 1.5
13 1.75
14 2.0
15 2.25
16 2.5
17 2.75
18 3.0
19 3.25
20 3.5
So far, this appears to work well in my application.
Upvotes: 4