Skip to content

Instantly share code, notes, and snippets.

@robert-nix
Last active March 9, 2017 19:16
Show Gist options
  • Save robert-nix/38837b316bab86bf3205941769912814 to your computer and use it in GitHub Desktop.
Save robert-nix/38837b316bab86bf3205941769912814 to your computer and use it in GitHub Desktop.
// 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;
}
LIBRARY user32
EXPORTS
UserGetPrecisionTouchPadConfiguration @2548
UserSetPrecisionTouchPadConfiguration @2549
@robert-nix
Copy link
Author

For robustness, use mod = LoadLibrary("user32"), pfn = GetProcAddress(mod, (LPCSTR)2548); and check for null pointers and stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment