input-capture: protocol §10.4, README rewrite, TODO §4 ticked
§10.4 records ten things the lane established from the Windows source (one-sided hotkey matching, the three meanings of Md.WheelDelta, the virtual cursor and its primary+-1 clamp, the unconditional relative bias, SwitchLocation, synthesised LLKHF bits, the eleven ReleaseAllKeys VKs, the two input counters, monitor enumeration) plus the macOS device masks. The README's Assumptions and Handshakes now describe what shipped, with the nine decisions and three deliberate non-ports in the work log. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
59fc7a3162
commit
fd1ceeac08
5 files changed
+449
-117
No files matched your search
@@ -697,3 +697,82 @@ sees them. One subsection per lane, appended, never rewritten.
|
||||
makes a macOS stream read mean exactly what `ReadEx(buf, 0, PACKAGE_SIZE)`
|
||||
means on Windows (`:574`), including "a short count is an `Invalid` package
|
||||
and a zero count is an `Error` package" (`:574-578, 588-593`).
|
||||
|
||||
### 10.4 input-capture (2026-09-16)
|
||||
|
||||
1. **Hotkey matching is one-sided, which is why the Ctrl+Alt block needs its
|
||||
own veto.** `Common.HotkeyMatched` (`Common.cs:127-129`) tests only that
|
||||
the code is equal and that every modifier the hotkey *asks for* is down;
|
||||
extra modifiers are ignored. So Win+Ctrl+Alt+L still fires with Shift also
|
||||
held, while the switch-machine keys, which are matched by arithmetic rather
|
||||
than by a `HotkeySettings` (`InputHook.cs:611-614`), are guarded by an
|
||||
explicit `shiftDown || winDown → return true` (`:604-610`, issue #26597).
|
||||
Only the second family is protected.
|
||||
2. **`Md.WheelDelta` carries three unrelated things.** For `WM_MOUSEWHEEL` /
|
||||
`WM_MOUSEHWHEEL` it is a signed multiple of 120; for `WM_XBUTTON*` it is the
|
||||
button index 1 or 2; for `NextMachine (121)` it is a machine id (§4.4). The
|
||||
sender extracts it as `(short)((mouseData >> 16) & 0xffff)`
|
||||
(`InputHook.cs:254`) — a *signed* 16-bit read, so a wheel notch towards the
|
||||
user arrives as −120 and not as 65416.
|
||||
3. **While a remote machine is controlled, the coordinates on the wire come
|
||||
from a virtual cursor, not from the pointer.** The hook keeps
|
||||
`hookCallbackMouseData.X/Y`, adds the raw delta from the real pointer to it,
|
||||
and clamps the result to `PrimaryScreenBounds ± 1` (`InputHook.cs:287-309`).
|
||||
That clamped value is what `Event.cs:112-113` scales to 0..65535 and what
|
||||
edge detection is fed, which is how the *controller's* primary monitor
|
||||
becomes the rectangle a controlled machine's pointer roams (§4.4). On macOS
|
||||
the real pointer is frozen by `CGAssociateMouseAndMouseCursorPosition(false)`
|
||||
while deltas keep arriving, so the same virtual cursor is kept explicitly.
|
||||
4. **The relative bias is applied unconditionally; the setting only chooses
|
||||
which pair of numbers is sent.** `InputHook.cs:311-312` adds
|
||||
`MOVE_MOUSE_RELATIVE` to every `dx`/`dy` it computes, zero included, whether
|
||||
or not `MoveMouseRelatively` is on. `Event.cs:105` then picks the tagged
|
||||
deltas when the setting is on and the absolute pair when it is off, so its
|
||||
`Math.Abs(dx) >= MOVE_MOUSE_RELATIVE` test is always true on that path and
|
||||
is not a second condition.
|
||||
5. **A pending switch overrides the next few mouse packets.** After
|
||||
`PrepareToSwitchToMachine` sets `SwitchLocation`, the hook replaces the
|
||||
coordinates of the next `SwitchLocation.Count` mouse events with the landing
|
||||
point — in pixels when it is `XY_BY_PIXEL`-tagged, otherwise scaled from the
|
||||
controller's primary monitor — and calls `Common.HideMouseCursor(false)`
|
||||
once (`InputHook.cs:268-284`). `Event.cs:97` suppresses the outgoing packet
|
||||
entirely while that counter is positive.
|
||||
6. **`LLKHF_EXTENDED` and `LLKHF_ALTDOWN` are read from the Windows hook
|
||||
struct, never computed** (`InputHook.cs:348`), so a non-Windows sender has to
|
||||
synthesise them: `ALTDOWN` from its own Alt state, `EXTENDED` from the fixed
|
||||
Windows set — the navigation block, right Control and right Alt, both Windows
|
||||
keys, keypad divide, Num Lock and the keypad's Enter. The keypad Enter is the
|
||||
only key where the bit is load-bearing rather than cosmetic: it and Return
|
||||
share `VK_RETURN 0x0D` and the receiver tells them apart by the bit
|
||||
(`InputSimulation.cs:108-157`).
|
||||
7. **`ReleaseAllKeys` releases eleven virtual keys, not eight.** The list is
|
||||
`LSHIFT, LCONTROL, LMENU, LWIN, RSHIFT, RCONTROL, RMENU, RWIN, SHIFT, MENU,
|
||||
CONTROL` (`InitAndCleanup.cs:225-229`), each sent only if
|
||||
`GetAsyncKeyState` says it is down, and the whole routine is rate-limited to
|
||||
once per 2 s (`:215-220`).
|
||||
8. **Two input counters, and only one of them means "a human is here".**
|
||||
`Event.InputEventCount` is bumped for every hook callback including our own
|
||||
injected events (`InputHook.cs:209, 339`); `Event.RealInputEventCount` is
|
||||
bumped only after the `RealData` check (`:223, 345`). It is the second one
|
||||
`SendAwakeBeat` compares (§3.3), so a machine being driven remotely does not
|
||||
keep its own screensaver awake.
|
||||
9. **Monitor enumeration seeds the desktop from the primary and never unions
|
||||
it.** `GetScreenConfig` copies `Screen.PrimaryScreen.Bounds` into both
|
||||
rectangles first (`WinAPI.cs:122-125`), and `MonitorEnumProc` extends
|
||||
`newDesktopBounds` only in the `else` branch, i.e. only for monitors that are
|
||||
*not* at the origin (`:70-102`). The corner list (`SensitivePoints`,
|
||||
`:104-109`) is built from `rcMonitor`'s exclusive right/bottom, so the
|
||||
corners of a 1920×1080 monitor at the origin are (0,0), (1920,0),
|
||||
(1920,1080), (0,1080) — one pixel outside the monitor on two sides.
|
||||
`CGDisplayBounds` uses the same half-open convention, so the macOS corners
|
||||
are computed the same way.
|
||||
10. **macOS-side facts this lane established.** Left and right modifiers are
|
||||
distinguished by the device bits of `CGEvent.flags`, which `CGEventFlags`
|
||||
does not expose: `NX_DEVICELCTLKEYMASK 0x01`, `LSHIFT 0x02`, `RSHIFT 0x04`,
|
||||
`LCMD 0x08`, `RCMD 0x10`, `LALT 0x20`, `RALT 0x40` and — not adjacent to the
|
||||
others — `NX_DEVICERCTLKEYMASK 0x2000`, with Caps Lock's state in
|
||||
`NX_ALPHASHIFTMASK 0x10000`. Keys with no Windows virtual-key code (`fn`,
|
||||
the keypad `=`, the JIS-only keys) cannot be sent at all and stay local. The
|
||||
sign convention of `scrollWheelEventFixedPtDeltaAxis2` against Windows'
|
||||
"positive `WM_MOUSEHWHEEL` means scroll right" is **not yet verified** and
|
||||
is a CP1 question.
|
||||
Reference in new issue
Block a user