fix(hook): read Windows pointer motion from raw input - #472
Draft
Stanley5249 wants to merge 1 commit into
Draft
Conversation
WH_MOUSE_LL carries the absolute cursor point, which the OS clamps at the desktop edge, so no motion reached the gesture accumulator on Windows at all. Raw input reports the device's own relative counts, matching macOS MOUSE_EVENT_DELTA_X and Linux REL_X. A message-only sink window registers for WM_INPUT with RIDEV_INPUTSINK (the agent never holds focus). The hook thread drains the whole queued backlog per wakeup via GetRawInputBuffer rather than one record per message: it also services the low-level hook, and reading singly put a 1 kHz mouse's report stream in front of every click. Records are released by calling DefWindowProcW directly, so cleanup does not depend on the Static control's window procedure. Buttons and motion arrive on two independent paths, and a WH_MOUSE_LL callback runs ahead of WM_INPUT records already queued, so a press discards the pending backlog — otherwise a flick made just before a gesture-button press would be summed into the fresh hold.
This was referenced Jul 27, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Alternative fix for #471, without the edge-clamp limitation of the simpler
approach. Raw input (
WM_INPUT) reports the device's own relative counts, so aswipe keeps producing deltas after the cursor hits a screen edge.
Opening as a draft: this is ~350 lines of Win32 FFI against
RAWINPUTlayout,buffer alignment, and record striding, and I'm not convinced the edge case earns
that maintenance cost. The ordering hazard below is the tell — it exists only
because motion and buttons stopped arriving on one channel, and the remedy is a
heuristic rather than a guarantee. Filed so the alternative is concrete and
reviewable, not because I think it should land as-is.
Changes
openlogi-hookwindows/raw_input.rs: message-only sink window +RIDEV_INPUTSINKregistration,
GetRawInputBufferbatch drain,RIDEV_REMOVEteardown.windows.rs:WM_INPUThandled in the message loop,DefWindowProcWcalleddirectly to release each record;
dispatch()extracted so both input pathsreach the callback.
the queued motion backlog — otherwise a flick made just before a gesture press
is summed into the fresh hold and commits a swipe the user never made.
Cargo.toml:Win32_UI_Input+Win32_Devices_HumanInterfaceDevice;Win32_UI_Input_KeyboardAndMousewas unused.Testing
cargo clippy -p openlogi-hook --all-targets— cleancargo test -p openlogi-hook— passingNote: the Windows CI job fails until #458 lands —
openlogi-hiddoes not buildwithout the
Win32_System_IOfeature.Refs #471