Windows Trackpad Helper
A small Windows library to help python applications track finger state on precision trackpads, that may not be exposed otherwise. This allows, for example, PyQt apps to know if the trackpad is providing events after the user has lifted their fingers. This is needed because even though the device and the drivers provide this info, it may not trickle down to a framework like Qt.
It interacts directly with the Windows API via ctypes (included in the Python standard library) and can hook any native Win32 window handle (HWND). While the demo uses PyQt6, the library should work with any GUI framework that exposes an HWND handle (such as PySide6, wxPython, Tkinter, GLFW, SDL2, or raw Win32 windows).
Touch Tracking Algorithm & Heuristics
The library hooks Windows Raw Input (WM_INPUT messages for Digitizer/Touchpad usage pages) to track physical touchpad contact:
is_finger_down(system_id: int = 0):- When
system_idis non-zero (specific device): Returns1if raw touchpad contact is active,0if inactive (and is a precision touchpad), or-1if the state is unknown (e.g. non-precision device). - When
system_idis0(global/default): Employs the time heuristic and returns:1(Touching): Raw touchpad touch contact is active.0(Lifted): Raw contact is inactive, but a touch occurred within the lift threshold window (default10000ms).-1(Unknown): Raw touch is inactive and occurred outside the window (or never touched / non-precision device).
- When
get_time_since_last_touch(system_id: int = 0): Returns the precise milliseconds since the last physical contact occurred (-1if never touched).set_lift_threshold(threshold_ms: int): Configures the time window (in milliseconds) used by global queries to distinguish betweenLifted(0) andUnknown/Idle(-1) states.get_lift_threshold(): Returns the currently configured threshold in milliseconds.
Your application can query is_finger_down() inside its own scroll/wheel event loop to determine the physical finger state cleanly and simply.
Quick Start (Local Run)
To compile the DLL and run the dumper demo locally:
# 1. Compile the C++ DLL locally (requires MSVC or gcc & CMake)
build.bat
# 2. Install package locally in editable mode with optional demo dependencies
py -m pip install -e ".[demo]"
# 3. Run the dumper demo
python -m windows_trackpad_helper.demo_pyqt6
Direct Integration Example (Generic Win32)
from windows_trackpad_helper import TrackpadHelper
# 1. Initialize the helper
trackpad = TrackpadHelper()
# Explicitly configure the lift threshold window to 10 seconds
trackpad.set_lift_threshold(10000)
# 2. Hook your window using its native HWND handle (from Tkinter, wx, GLFW, etc.)
hwnd = my_window.window_id() # Replace with your framework's HWND getter
trackpad.init_hwnd(hwnd)
# ... inside your scroll/wheel event handler:
finger_state = trackpad.is_finger_down()
if finger_state == 1:
state_str = "Touching"
elif finger_state == 0:
state_str = "Lifted"
else:
state_str = "Unknown"
print(f"Physical Touch State: {state_str}")
# 3. Cleanly unhook on window close
trackpad.shutdown()
Metadata
Release files for windows-trackpad-helper 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| windows_trackpad_helper-1.0.1.tar.gz | 26.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| windows_trackpad_helper-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.3 kB
Release files / windows_trackpad_helper-1.0.1.tar.gz
| Download URL | windows_trackpad_helper-1.0.1.tar.gz |
|---|---|
| Size | 26.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8845cb282318b209630b37be5914bcbb5a3a5ecd8a1b58dbf1f421709b20387
|
|
BLAKE2b-256 checksum How to use checksums |
3ff1f3c31be84c59924c64adbb5314689b75cfb6e214f7b97f6283f74780d736
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / windows_trackpad_helper-1.0.1-py3-none-any.whl
| Download URL | windows_trackpad_helper-1.0.1-py3-none-any.whl |
|---|---|
| Size | 25.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
33084058b9b1870b2469ea6b838c2793eb8dd5a573370a4b68aac81421efd21b
|
|
BLAKE2b-256 checksum How to use checksums |
ae352bb4faa99eac26eec175ad33d55952ac5a94bf6efc394b566e2f59f28058
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|