diff --git a/docs/features/input-capture/README.md b/docs/features/input-capture/README.md index 5c3e754..a49ede3 100644 --- a/docs/features/input-capture/README.md +++ b/docs/features/input-capture/README.md @@ -36,8 +36,25 @@ code does not enforce is here. the destination is remote, convert to `CapturedInput`, push and swallow (`InputHook.cs:361-368` keyboard, `:322-325` mouse); if local, push mouse *moves only* so `Edge` can watch for a crossing, and pass everything through. - Three uncontended `OSAllocatedUnfairLock` acquisitions per event at most - (snapshot, virtual cursor, counters) and no allocation (invariant 4). + No allocation on any of it (invariant 4). +- **Four locks are reachable from the callback**, all uncontended + `OSAllocatedUnfairLock`s held only for a struct copy: `EventTap.counters`, + `RoutingState`'s box (the snapshot *and* the virtual cursor share it), + `Screens`' layout and `CaptureQueue`'s ring. Counted from the code, per + event, on the four paths that matter: + - **local key**: 2 — `counters`, snapshot read. An unmapped key adds one + `counters`; a matched hotkey adds one ring push, and an escape hotkey one + more `RoutingState` write. + - **local mouse move**: 3 — `counters`, snapshot read, virtual-cursor write; + 4 when Easy Mouse lets the move be offered as an `.edgeCandidate` (one ring + push). `Screens` is not read on this path. + - **remote key**: 3 — `counters`, snapshot read, one ring push. A + `flagsChanged` pushes once per modifier transition instead, and twice more + for a Caps Lock toggle. + - **remote mouse move**: 6 — `counters`, snapshot read, virtual-cursor + advance, `Screens`' layout, then two ring pushes (`.mouse` and + `.edgeCandidate`); 5 when the candidate is suppressed. This is the worst + path in the file. - **Swallowing is a separate flag from the destination.** ALL-machines mode sends input to every peer *and* keeps it locally (`InputHook.cs:361`), so `swallowKeys`/`swallowMouse` are set by the Engine, not derived here.