Docs / DECLARATIVE-INPUT

Declarative Input System & Portable Controller Profiles (RFC)

Source: docs/DECLARATIVE-INPUT.md

Goals

YAML is the source of truth for input configuration. Support automatic, manual and hybrid mapping equally, offline, without mandatory accounts or registry. UI edits must round-trip to YAML without silently losing unrelated fields. Preserve backward compatibility with existing manifests.

Proposed schema (illustrative, not existing API)

input:
  players:
    - slot: 1
      device: auto
      mapping: hybrid
      profile: ./profiles/dualshock.yaml
      overrides:
        south: game.b
    - slot: 2
      device: virtual
      mapping: manual
      profile: ./profiles/snes-touch.yaml

Version profile schema; support inline profiles, relative local files and optional pinned registry/Git references. Profiles declare device matching (standard layout, vendor/product where available, not machine-specific IDs), logical controls, button/axis mappings, dead zones, sensitivity, inversion, vibration where supported, accessibility and optional player assignment. Manual mode requires explicit mappings; auto selects compatible profiles deterministically; hybrid overlays explicit overrides. Document precedence and conflicts; reject invalid mappings with actionable errors. Export self-contained configurations with resolved profiles; never include secrets or machine-specific bindings by default.

Architecture

Input providers (keyboard, USB/Bluetooth gamepads, phone touch controls over a paired web page, browser Gamepad API and native host as supported) -> normalized virtual controls -> emulator-specific adapters. Declare supported capabilities and report unsupported features, never silently claim support. Handle hotplug, reconnect, stable player slots, multiple controllers, focus loss and release of held inputs. Remote multiplayer input may use the same normalized interface with authorization and isolation; no dependency on multiplayer implementation. No arbitrary executable code in profiles.

Virtual mobile controller via QR (proposed)

device: virtual selects a phone-as-controller source for a player slot; the profile defines the touch layout and maps its buttons to the same normalized controls used by physical devices. The persistent YAML contains the controller type, slot and profile only. Pairing URLs, tokens and session IDs are ephemeral runtime state and must never be written into the manifest, exported profile or logs.

User flow

  1. In the Desktop App, choose Virtual controller (QR) for a player slot. Game Composer starts a temporary, session-scoped pairing endpoint and displays a QR code plus a short manual URL/code fallback.
  2. Scan with a phone on the same local network. The link opens a responsive, touch-first controller page in the phone browser; the user does not install an app or create an account.
  3. After pairing, the phone page shows the selected profile (for example, a SNES layout). Touch press/release events travel over the local transport to Game Composer, become normalized input events, then go through the emulator adapter.
  4. Closing the phone page, losing its heartbeat, stopping the game or ending the pairing session releases every held input and invalidates the pairing credential.

Pairing and transport requirements

  • Pairing is explicit and local by default: bind only to the required LAN interface, use a high-entropy single-use token, bind it to one running game session and player slot, expire it quickly, and allow immediate revocation. Reject reused, expired, malformed or wrong-session tokens.
  • Do not create a public tunnel or expose the host API to the internet. Use authenticated HTTPS/WSS on the local network; treat certificate/trust bootstrap for phones as an explicit design requirement. A relay, if added later, must be opt-in and separately reviewed.
  • The phone page receives only the control schema/layout and session status; it must not receive local filesystem paths, ROM bytes or other host capabilities. Enforce origin checks, message-size/rate limits and per-slot authorization.
  • Use ordered press/release messages, a heartbeat/deadman timeout, and an all-buttons-up reset on disconnect, page hide, tab close, host stop and controller replacement. Haptics are optional and capability-gated.
  • Pair one phone to one player slot initially. Multi-phone/multiplayer support must define slot ownership and conflict behavior rather than merging inputs silently.

Acceptance for the virtual-controller path

  1. Selecting the virtual controller in Desktop displays a fresh QR; scanning it on a phone opens the controller page and pairs only to the selected live session/slot.
  2. Pressing and releasing each mapped touch control emits the expected normalized events and reaches the emulator adapter; verify actual gameplay with input-correlated display evidence, not merely a connected socket.
  3. Expired, reused, revoked and wrong-session QR credentials are rejected; pairing works on a private LAN without requiring a cloud account or public tunnel.
  4. Phone disconnect, lost heartbeat, game stop and page refresh release held inputs within the documented timeout; reconnect requires a new valid pairing.
  5. Verify the desktop and phone layouts at narrow/mobile sizes, touch target sizes, screen rotation, keyboard/screen-reader labels and one-hand accessibility where supported.

Profile registries

Ship curated offline defaults for Xbox, PlayStation, Nintendo, generic controllers and keyboard; support community registries, Git URLs and local collections. Registries optional and discovery-only; version/pin profiles, validate schema and integrity, cache locally, explicit updates, export/import, search by device/console/accessibility. No central server required. Profiles are portable declarative data, not executable plugins.

Acceptance

  1. Schema validation, deterministic auto/manual/hybrid resolution, overrides and backwards compatibility tests.
  2. NES and SNES adapters with actual gameplay input verification, not just simulated frames; document platform/device limitations.
  3. Test keyboard, representative USB/Bluetooth controllers, two players, hotplug, reconnect, focus loss, unsupported controls and duplicate assignments.
  4. UI mapping wizard, live input preview, profile import/export and YAML round-trip; transfer profile to another compatible machine and verify identical logical mappings offline.
  5. Registry discovery, pinned offline cache, malformed profile rejection and no mandatory network access.
  6. Document configuration examples and emulator capability matrix; do not claim hardware tests without evidence.

Design RFC only; implementation and testing remain pending.

Back to all docs