Last active
March 9, 2017 19:16
-
-
Save robert-nix/38837b316bab86bf3205941769912814 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lib /def:user32.def | |
// cl /O2 test.cpp /link user32.lib | |
#include <Windows.h> | |
#include <stdio.h> | |
struct PrecisionTouchPadConfig { | |
BYTE LegacyParams[3]; | |
BOOL LoadedSettings; | |
// 0: No delay (always on) | |
// 1: Short delay | |
// 2: Medium delay (default) | |
// 3: Long delay | |
// 4: Turn off taps | |
DWORD AAPThreshold; | |
// 0001: PTPEnabled | |
// 0004: EnableEdgy | |
// 0008: ScrollDirection | |
// 0080: LeaveOnWithMouse | |
// 0100: RightClickZoneEnabled | |
// 0200: TapAndDrag | |
// 0400: IsTPActive | |
// 0800: IsMouseConnected | |
DWORD Flags; | |
}; | |
extern "C" BOOL __stdcall UserGetPrecisionTouchPadConfiguration(PrecisionTouchPadConfig *config); | |
extern "C" BOOL __stdcall UserSetPrecisionTouchPadConfiguration(PrecisionTouchPadConfig *config); | |
int main() { | |
PrecisionTouchPadConfig config = {0}; | |
// Must be 0 or 1 for GetPrecisionTouchPadConfiguration to return data. | |
config.LoadedSettings = 1; | |
BOOL getSuccess = UserGetPrecisionTouchPadConfiguration(&config); | |
printf("getSuccess = %d\n LegacyParams=%02x%02x%02x\n LoadedSettings=%02x\n AAPThreshold=%d\n Flags=%08x\n", | |
getSuccess, | |
config.LegacyParams[0], config.LegacyParams[1], config.LegacyParams[2], | |
config.LoadedSettings, config.AAPThreshold, config.Flags); | |
if (getSuccess) { | |
config.AAPThreshold = 0; | |
BOOL setSuccess = UserSetPrecisionTouchPadConfiguration(&config); | |
printf("setSuccess = %d\n", setSuccess); | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LIBRARY user32 | |
EXPORTS | |
UserGetPrecisionTouchPadConfiguration @2548 | |
UserSetPrecisionTouchPadConfiguration @2549 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For robustness, use
mod = LoadLibrary("user32")
,pfn = GetProcAddress(mod, (LPCSTR)2548);
and check for null pointers and stuff.