frametop

Host input: a computer’s keyboard and mouse in Frametop (design notes)

Status: Linux hosts built (2026-10-27), with Frametop’s Vibepollo build; see “Linux hosts”. Windows and the Mac are planned, and the spikes below come first for them. Pausing the streams when the headset comes off isn’t built yet: only the keyboard and mouse go back.

The idea: while you wear the headset and a computer’s displays stream into Frametop (remote displays), that computer’s own keyboard and mouse work as if they were paired to the Frame. The mouse drives the 3D mouse, and the keys type wherever typing goes in Frametop. Take the headset off and the computer gets its keyboard and mouse back, and its streams stop. Put it back on and the streams come back, and the keyboard and mouse go back to Frametop. It’s what a Mac’s keyboard and trackpad do for an Apple Vision Pro with Mac Virtual Display.

Nothing new is needed to control the computer itself: the 3D mouse on one of its panels already sends the pointer, clicks and keys back to it through the stream. So the host’s mouse moves the 3D mouse, the 3D mouse is on the host’s panel, and the host’s cursor follows. Gaze mode, key bindings, drags across panels and Full Keyboard all work with the host’s keyboard and mouse as they do with a Bluetooth one. With gaze mode on it’s close to the Vision Pro: look at a panel, touch the trackpad, and the pointer is there.

Decisions (2026-10-20)

Question Decision
The Mac A small helper, Frametop Bridge, next to the stock Sunshine instances. Not a macOS build of the Vibepollo fork: its macOS code isn’t built by Vibepollo’s CI, our display role, microphone and display mode code is Windows and Linux only, and replacing LizardByte’s notarized Sunshine with our unsigned build would break Screen Recording and Accessibility on every update
Headset off The host gets its keyboard and mouse back and its streams stop at the same moment: when the pointer helper decides the headset is off (idle for HEADSET_OFF_AFTER, 1.5 s, or standby). No longer grace. Putting it back on waits for the streams, about 3-8 s
Volume and media keys Never taken: they stay on the computer
A Mac keyboard’s Cmd Always Meta, wherever typing goes. No Cmd/Ctrl swap for the Frametop desktop
Signing the Mac Bridge Ad hoc, built by CI. The macOS kit pins its SHA-256, and the setup clears its quarantine after checking it. Sunshine starts it, and it works under Sunshine’s Accessibility grant (S3). No Apple Developer ID

How it fits

the host's keyboard and mouse
  Windows: our Vibepollo fork (low-level hooks take them, Raw Input gives the mouse's counts)
  macOS:   Frametop Bridge (a CGEventTap), one per Mac
      │  events: evdev key codes, relative motion, buttons, high-resolution wheel
      │  ◄── an engage lease from the Frame every 500 ms
      ▼
ft-stream: the host's stream that holds its input lock (one per host, like the audio lock)
      │  datagrams to the input relay
      ▼
input relay: a "network device" per host and kind (mouse: pointer, keyboard: pass-through)
      → the 3D mouse, mapped buttons, key bindings, typing to the desktop, a remote panel, or Steam

The protocol

Both transports carry the same messages. On the fork they’re control stream packets, which on a Sunshine host are encrypted (the fork refuses them otherwise, like the microphone’s 0x3003). On the Bridge they’re length-prefixed records on its TLS connection.

The host’s own input is never sent back: Sunshine’s injected events (the Frame’s clicks and keys on the host’s panels) have the INJECTED flags on Windows, and on the Mac they’re told apart by the posting process (Vibepollo’s macOS input posts mouse events from a HIDSystemState source, so the source state can’t tell them from the hardware’s).

When the host’s input goes to Frametop

The Frame sends leases for a host while all of these hold:

Tests and a faked wearer

The pointer helper can’t tell the testbench’s worn on from a real head, so a test that fakes the wearer while a host that lends its input streams takes that computer’s keyboard and mouse from whoever sits at it (2026-10-30: linuxpc, mid-sentence, from a run that never meant to touch it). Leases need the user’s say-so for tests:

Headset off and on

The ft-stream holding a host’s input lock asks the pointer helper’s headset state itself, every second (see “On the Frame”). When it goes to away:

  1. The Frame stops the leases (release at once). The host gives its keyboard and mouse back within one lease of the change. Keys and buttons held at that moment come up on the side they went down on: a Ctrl held on the Frame comes up on the Frame. That release lifts an escape too. When no stream sees the headset come off (none was running, or it was reconnecting), the next one sends the release before its first lease, from the pointer helper’s word on when the headset last went back on.
  2. Planned, not built: ft-screens stops every remote display’s stream. With our fork, that hands the monitor back its own resolution and HDR, and frees the host’s encoder and the Frame’s decoder. The panels would stay where they are, with their last picture and a “Paused” label, not destroyed: destroying overlays while SteamVR goes to standby has crashed vrcompositor before. Until then the streams keep running with the headset off.

When it’s worn again, the host’s input goes back to Frametop at the helper’s next “worn” answer, once the stream holding the lock is live. Until then the keyboard and mouse stay on the computer.

Safety

Windows: in the fork

A capture thread in sunshine.exe (the service starts it in the console session as SYSTEM, tools/sunshinesvc.cpp), alive only while a Frametop client with mouse and keyboard permission holds an engage lease:

macOS: Frametop Bridge

One small helper per Mac (Swift, built by the Frametop CI as a universal binary, ad hoc signed, pinned in the macOS kit):

On the Frame, the ft-stream holding a Mac’s input lock connects to its Bridge with the display’s client key.

Linux hosts

Built first (2026-10-27), for a Hyprland host (linuxpc). Wayland gives no global input capture, and Vibepollo’s packaged service runs as its own user without access to /dev/input, so the fork adds a capture service of its own, vibepollo-host-input (packaging/linux/vibepollo-host-input.c in frametop-vibepollo):

The fork’s host side (src/frametop_hostin*.cpp) gives the lease to one client at a time (another gets released busy), only on an encrypted control stream and only to a client allowed both mouse and keyboard. Windows and macOS hosts answer released unsupported.

The protocol as built: 0x3005 is version 1, then engage (1) with a u32 sequence and a u16 lease in ms, release (2) or drop (3). 0x3004 is version 1, then one record: events (1: kind, 1 keyboard or 2 mouse, a u16 count, then evdev type u16, code u16, value s32 each, little-endian; a report ends with 0 0 0; a mouse record carries BTN_MOUSE to BTN_TASK and relative motion, a keyboard record the other keys), state (2: engaged 0 or 1, then the reason), or hello (3: kinds, then the host’s name). State and hello come on every change and once a second. Reasons: lease, host, escape, busy, permission, overflow, dropped, stalled, closed, off, service, unsupported.

On the Frame, ft-stream does what “On the Frame” says without ft-screens: the stream holding the host’s input lock asks the pointer helper (gaze ? headset on-at) and the relay (pause ?) every second itself, taking answers only from this user’s processes, and a helper or relay that stops answering counts as a drop. An answer counts from when it was given, the kernel’s send time on the datagram (SO_TIMESTAMPNS, GivenAt), not from when ft-stream read it: one left waiting while the switch was off is stale when it comes back on. It waits up to 100 ms for room to send the relay a host message; one it couldn’t send says hostbye, so the relay lets go of the host’s keys rather than miss a key-up, and the next hello brings the devices back. A hostbye that couldn’t go either is owed, and that kind gets no hostdev until it has gone, so the relay’s own 3 s timeout lets go meanwhile. These sends run on moonlight’s control receive thread, so a stuck relay slows the control stream by up to 100 ms per message. A release goes out on each fresh switch-off or headset-off, leased or not, and for an escape in the marker that the headset came off and went on since (see the escape above), so a new ft-stream also lifts an escape it never saw. Before each decision it reads the tests’ files in $XDG_RUNTIME_DIR (and in /run/user/UID when that is a nested desktop’s), and one that forbids drops the lease at once and logs hostinput: no lease for HOST's keyboard and mouse while FILE says a test may not take them; the testbench’s input-lock guard alone left a short gap when a host got the switch while its stream held the lock. stream/hostinput.h has the records, when to hold, drop or release (Decide), the kept escape (EscapeMark, OnAt, OffOnSince), the tests’ files (TestForbidding) and the relay’s messages (Relay), offline-tested by stream/test/hostinput-test.cpp. moonlight-common-c gets LiSendFrametopHostInputLease and LiSetFrametopHostInputCallback from stream/moonlight-hostin.patch (channel 0x08 for leases; the callback only sees packets that came encrypted).

On the Frame

Spikes

  What Learns
S1 (Frame) The relay’s network devices, fed by a fake host in an offline test like input/test/keys-test.py The 3D mouse, typing to the desktop and to Steam, held keys at engage and release, a device that stops saying hello
S2 (the test PC) A standalone capture test, run the way sunshine.exe runs (SYSTEM, console session), and as the signed-in user Hooks from that context; whether Raw Input still arrives for events a hook takes; that injected events are told apart; the cursor staying still while taken
S3 (the Mac) A standalone event tap Taking moves without the cursor drifting; trackpad scrolling and momentum; telling Sunshine’s posted events apart; Secure Input; whether a helper Sunshine starts works under Sunshine’s Accessibility grant

Results so far (2026-10-20)

S1 passed (offline). Branch host-input (8d2de5e): host devices in the input relay, as under “On the Frame”, with input/test/hostin-test.py. A fake host’s hello makes a mouse (pointer) and a keyboard (pass-through), bus network. Its motion wakes and moves the 3D mouse, and its left button is the trigger. Its keys go to ft-screens while typing goes to the desktop, and out on the virtual keyboard while typing goes to Steam. A Meta tap on it opens the Steam menu (the default binding). With no word for 3 s both devices go away; a key it held on Steam comes up there, and one it held on the desktop comes up at the next scan (a held key isn’t released while the host is still there). hostbye drops one device, and a bad id or kind does nothing. The other input tests still pass. Not done: ft-stream’s side, and anything live.

S2 (the test PC), without anyone there. spike.exe (sources in ~/.cache/host-input-spike/win, not in the repo) ran as SYSTEM in the console session, started the way sunshinesvc starts sunshine.exe (consolerun.exe from a SYSTEM scheduled task), with injected input standing in for the hardware:

S3 (the Mac). spike (C/Objective-C, ~/.cache/host-input-spike/mac, built on the Mac with Xcode’s clang). Over SSH (sshd-session) there is no Accessibility, so an active tap is refused, as expected. Run from Terminal with Accessibility granted: