0038: TV remotes, keyboards and typing
- Status: Accepted (owner, 2026-11-24). Proposed (owner's direction, 2026-11-21; all five parts built)
- Date: 2026-11-21
Context
Only pads reach apps today: padd grabs pads and makes virtual ones, so a Bluetooth remote, keyboard or mouse on the host goes nowhere. The pairing screen for Bluetooth devices (README goal 4, roadmap shell step 3) was never built, and with no pad connected there is nothing to pair one with. There will never be HDMI-CEC, so the TV's own power and volume need another way. Typing on a TV with a pad or remote is slow, and some apps need it (search, sign-in).
Decision
- Every input reaches the front app. Remote, keyboard and mouse nodes from
/dev/inputgo to the screen's front app the way pads do (the host's BlueZ owns the adapter, the kernel makes the nodes). The home reads them as it reads a remote's keys today. - Bluetooth page. The runner talks to the host's bluetoothd over the system D-Bus socket: Settings lists, pairs and forgets devices. With no pad or remote connected, the first remote or pad found in pairing mode is paired by itself, so a fresh box can be reached with nothing but the device in hand.
- Volume. A remote's HID volume keys change the box's own volume and show it in the status pill (ADR 0033). TV power, TV volume and input go through the remote's IR learning, not through us.
- T9. On a remote with a number pad, multi-tap letters (not predictive) are typed through the screen's
couchdogs-input(ADR 0028), with the letter being chosen shown in the pill. - Typing from a browser. The LAN page (ADR 0022, sign-in code ADR 0031) gets a Type box: pick a screen, the text goes through the runner to that screen's
input.socktext ops. Arrows, Enter and Back can follow, so a phone works as a remote. A remote's voice typing types through the same/type(ADR 0042).
Recommended remote, written in the README once this ships: BOXPUT BPR3S (Bluetooth, number pad for T9, IR learning on its Power, Vol-, Vol+ and Input keys, which always send IR). Learning is known to copy NEC TVs fully, Samsung and LG on those four keys; other brands unconfirmed, so the README says which brands are known and does not promise every TV. Cheapest option: an MX3 air mouse (2.4 GHz dongle, no Bluetooth, keyboard on the back), with a warning about its build quality.
Consequences
The runner gains a D-Bus client and the /run/dbus socket, and padd (or a sibling) routes non-pad nodes. Auto-pair must not take a neighbour's device: only when nothing is connected, and only devices that advertise as remotes or pads. Typing from the LAN page is input into the household's screens, so it sits behind the same sign-in as the rest of that page.
Amendment (2026-11-21): how part 1 reaches the app
padd grabs every USB or Bluetooth node that is not a pad and sends its keys, buttons, motion and wheel as couchdogs-input datagrams (ADR 0028) to the TV's screen, or to the device screen the TV shows, the way the server sends a streamed keyboard. Not libinput in Gamescope: the TV screen has no /dev/input by design, the daemon already reaches Steam's nested display, and keeping the keys in padd lets it apply the lone-Escape hold (Back on a remote) and, later, take the volume keys. Only USB and Bluetooth: a machine's own PS/2 keyboard and a VM's QEMU devices stay with the console. A remote's Home key goes Home at once.
Amendment (2026-11-21): how part 3 works
padd keeps a host node's volume keys from the app and posts POST /volume {change: up|down|mute} to the runner, which runs pactl in the TV's screen on its default sink (the HDMI sink every TV app and the join viewer play into): 5% a step, never past 100% (PipeWire's software gain clips there), up or down unmutes. The pill shows a level notice: the words and the hold's meter standing at the level, which stays in place while a key repeats. Always the TV's sound, also while the TV shows a device, since the sound plays on the TV. A device's own keys stay on the device.
Amendment (2026-11-21): how part 2 works
The runner keeps one jeepney connection to the host's system bus (BlueZ ties discovery to the connection that started it). Settings has a Bluetooth row on every home with household rows: the card asks for a scan, lists paired devices and the near, named pads, remotes and keyboards, pairs with A (Just Works through the runner's own pairing agent, see the amendment below: a keyboard that wants a code typed is refused with those words) and forgets after a confirm. Auto-pair runs only while nothing that drives a screen is connected, takes the nearest named device whose Icon, Class, Appearance or HID service says pad, remote or keyboard, and tries each address once per 10 min, so a neighbour's laptop or headphones are never taken and a refusal does not loop. Pairs are trusted and connected, so they come back by themselves. BLUETOOTH_AUTOPAIR=0 turns auto-pair off.
Amendment (2026-11-21): how part 4 works
padd turns a host node's digits into letters only while an app is in front of the screen it types into (not a home, not the join viewer) and only on a node that never sent a letter key, so a keyboard keeps its digits and a home keeps digits as keys. Phone order with the digit last (2 is abc2, 0 is a space then 0, 1 is punctuation then 1): a tap of the same digit moves on, 1 s after the key comes up the shown letter is typed, any other key or digit types it at once, and holding a digit 0.8 s types the digit. The letter goes as a text op to the screen's couchdogs-input. The pill on the TV shows the letters with the chosen one marked (a pick notice, on the TV also while it shows a device, since the remote is in the living room). No prediction and no dictionary.
Amendment (2026-11-23): a pairing agent, so pairs keep a bond
The owner paired a pad from the Bluetooth card; it showed as paired and did
nothing. With no agent registered, BlueZ paired it without keeping a link key
(Paired, not Bonded), and bluetoothd's input plugin refuses HID from a device
without a bond ("Rejected connection from !bonded device", ClassicBondedOnly,
the default since CVE-2023-45866). The runner now registers BlueZ's default
agent (NoInputNoOutput) on its own D-Bus connection and thread, and registers
again when bluetoothd restarts. It says yes only to calls from bluetoothd, only
for the device a pair job is pairing (and to services of devices already
paired), and refuses a PIN or passkey request. After Pair, a device that is
still not bonded is removed and the card says "it did not keep the pairing".
A classic HID device found paired without a bond for 10 s, outside a pair job,
is forgotten once, so auto-pair can take it again. A host that turned
ClassicBondedOnly off is not a case this handles differently.
Amendment (2026-11-23): a screen with no controller says so
The owner: "how do we pair if no controller is connected?", and the wizard
should handle it, "same if somehow someone removed all paired devices".
Auto-pair already looks whenever nothing drives the TV, but nothing on screen
said so. Now the TV's home carries controller: null while the host has any
input paired over Bluetooth or plugged in by USB; a paired pad that is asleep
counts, so a normal disconnect never brings the panel back. Otherwise
{state: "looking" | "pairing" | "off",
name} from the runner's auto-pair ("off": no adapter or auto-pair turned
off, so the words say to plug one in by USB). The home shows it as a panel,
not a card: nobody on the couch can press anything, and a device that joined
the TV still uses the home under it. When it turns null after showing, the
panel says "Connected" for 2 s and goes. Until the runner's first read of BlueZ
and padd's first count, the home says nothing at all: a runner restart must
never flash the panel on a household whose only pad is paired and asleep. The
first-run wizard starts with
the same panel as a page while controller is set, and moves on by itself.
Only the TV's home: a streamed device always brings its own input (the one
difference is the HDMI screen having no input of its own). The LAN page gets
the Settings card's Bluetooth list (look, pair, forget), signed in only, so
a phone can pair a remote that auto-pair skipped.
Not chosen: a modal card (it would take the joiner's home too), and the panel on every home (a device's screen is driven by the device it streams to).
Amendment (2026-11-24): the header shows every input, the panel goes
The owner asked for "an indicator of how many controllers we have, possibly
batteries, like some consoles do", and called the "No controller" box "another
brand new plain box". The panel is gone. The header, left of the clock, shows
one glyph per input that plays on that screen now (pad, remote, keyboard,
mouse), pads with their player number, and 4 battery bars where the input
reports one (amber at one bar, a bolt while charging; no toast). Every home
shows its own, a device's included; a device's own keyboard and mouse are the
device and are not listed. With nothing on the TV the same spot shows a dim
pad and the auto-pair words ("Pair a controller", "Pairing POST /local counts became POST /inputs
({pads, keys, screens: {screen: [{kind, player, battery, charging}]}}, on
change and every 30 s); host pads read the kernel's power_supply, a device's
pads Moonlight's CONTROLLER_BATTERY, which the server forwards to padd as op
battery. Auto-pair logs why it skips a near unpaired input, once per change
of reason, to find why a pair took long. Not chosen: BlueZ Battery1 (no link
to a player number) and drawing it into the stream (the shell owns the header).
Amendment (2026-11-24): BlueZ battery as a second source
The owner's pad gives Linux no battery through its kernel driver, so the
header showed none. padd now adds a host pad's Bluetooth address (its HID
uniq, when that is a MAC) to its POST /inputs entry. The runner fills a
missing battery from BlueZ Battery1 Percentage of the connected device
with that address, then drops the address before any home is built. The
kernel's power_supply stays first. This links BlueZ to a player number,
which is why it was not chosen above. A pad that reports to neither still
shows no bars.
Amendment (2026-11-24): the Bluetooth card is the TV's
Only the TV's home has the Settings row: a device screen has no Bluetooth of
its own. The card lists devices in sections, Connected, Paired (paired but
not connected, such as a sleeping pad) and Nearby; the section heads take no
focus. Each row has the kind glyph from the header, the name, and BlueZ's
battery as the header's 4 bars. The card line says "Searching…" while a scan
runs. A on a nearby device pairs it; on a paired one it opens Disconnect
(only while connected; the runner calls Device1 Disconnect, the pairing
stays), Forget (asks first, Keep focused) and Close.
Amendment (2026-11-26): an air-mouse remote's OK is Enter
The BPR3S sends OK as its pointer node's left button, and its gyro moves the pointer all the time, so OK clicked wherever the pointer had drifted and never picked the selected tile. A pointer node whose device (same Bluetooth address, or same USB path) also has a key node with a Back key is a remote's pointer: its left button goes to the app as Enter, and its motion still moves the pointer. A keyboard with a touchpad has no Back key, so its clicks stay clicks.