0

Go to the answer of the question

I'm trying to get my mouse speed, but when I call the function SystemParametersInfoA with parameter SPI_GETMOUSE it sets the target array to {0,0,0} which I think its not supposed to happen.

Example code:

int IntArr[3];
SystemParametersInfoA(SPI_GETMOUSE, 0, &IntArr, 0);

I tried changing my mouse sensitivity (from the control panel) but that didn't work either.

Does this function is supposed to return those zeros or thats my fault?

xXTurner
  • 61
  • 9
  • I'm assuming you really are calling `SystemParametersInfo` and not `GetSystemMetrics` as you say in the title. – Jonathan Potter Feb 14 '20 at 20:40
  • @JonathanPotter Yes, you are correct. Sorry I will fix it, my bad when copy pasting :D – xXTurner Feb 14 '20 at 20:45
  • Is the return value of `SystemParametersInfoA()` returning FALSE? If so, what does `GetLastError()` report? And how are you printing the array exactly? Please provide a [mcve]. – Remy Lebeau Feb 14 '20 at 20:53
  • @RemyLebeau It is returning TRUE, I have it on an if statement to test aginst 0 and if its 0 I print out GetLastError, but it returns true that was why I was confused. Im printing each element of the array, but thats not the point, i tested it with debugger and memory viewer it is indeed 0. – xXTurner Feb 14 '20 at 21:06
  • @RemyLebeau You can literally copy and paste this and it will be exactly like mine, and see for yourself if **IntArr** has any values other than 0. im using MSVC compiler (visual studio) – xXTurner Feb 14 '20 at 21:07
  • It doesn't look like you're doing anything wrong. Maybe those settings aren't used by the OS any more? Or Microsoft have broken the API. – Jonathan Potter Feb 14 '20 at 21:30
  • 1
    @JonathanPotter I'd bet on the second one – xXTurner Feb 14 '20 at 21:58

1 Answers1

1

The documentation says:

Retrieves the two mouse threshold values and the mouse acceleration.

At first I did tought that these two mouse threshold values were related to my mouse cursor sensitivty.

After a deeper search in the docs for mouse_event, I found out that in the remarks section it says:

The system applies two tests to the specified relative mouse motion when applying acceleration. If the specified distance along either the x or y axis is greater than the first mouse threshold value, and the mouse acceleration level is not zero, the operating system doubles the distance. If the specified distance along either the x- or y-axis is greater than the second mouse threshold value, and the mouse acceleration level is equal to two, the operating system doubles the distance that resulted from applying the first threshold test. It is thus possible for the operating system to multiply relatively-specified mouse motion along the x- or y-axis by up to four times.

Which basically means that these 3 values that I got in the destination array IntArr wasn't anything to do with sensitivity, but rather these 2 mouse threshold values and the "Enhance pointer precission" which was either 0 or 1 indicating it turned on or off, mine was disabled thats why I got all zeros.

In order to get the mouse sensitivity you have to use SystemParametersInfoA function with the SPI_GETMOUSESPEED parameter as uiAction instead.

xXTurner
  • 61
  • 9