How to configure mouse enhance pointer precision programmatically
c++, configuration, mouse, winapi
Solution
According to the documentation for the `SystemParametersInfo` function and `SPI_SETMOUSE`:
Sets the two mouse threshold values and the mouse acceleration. The `pvParam` parameter must point to an array of three integers that specifies these values. See mouse_event for further information.
So you need an array containing 3 values, and you specify a pointer to that array as the `pvParam` parameter when calling `SystemParametersInfo`.
Since all you care about is changing the acceleration (the last value), you probably want to retain the current values for the first two, the mouse threshold values. Do that by calling `SystemParametersInfo` with the `SPI_GETMOUSE` flag to obtain those values, then modifying the last one (the acceleration), and then calling `SystemParametersInfo` again, this time with the `SPI_SETMOUSE` flag.
Sample code (without recommended error checking):
// Turns mouse acceleration on/off by calling the SystemParametersInfo function.
// When mouseAccel is TRUE, mouse acceleration is turned on; FALSE for off.
void SetMouseAcceleration(BOOL mouseAccel)
{
int mouseParams[3];
// Get the current values.
SystemParametersInfo(SPI_GETMOUSE, 0, mouseParams, 0);
// Modify the acceleration value as directed.
mouseParams[2] = mouseAccel;
// Update the system setting.
SystemParametersInfo(SPI_SETMOUSE, 0, mouseParams, SPIF_SENDCHANGE);
}
And you probably already know this, but there are too many badly-behaved applications out there for me not to mention it just in case. If you're doing this in your application, be sure to save the original value so that you can restore it when your app is closed! This is just basic etiquette when you're modifying system-wide settings.
Problem
How to configure mouse enhance pointer precision programmatically in C++? I know that have some useful commands like SystemParametersInfo, for speed, ... ``` int x = 15; ``` SystemParametersInfo(SPI_SETMOUSESPEED, NULL, reinterpret_cast(x),SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE ); ... but I cannot find enhance precision----