HydraIssues

Drive a head controller from the cluster: inject synthetic gamepad input through the Moonlight input path
open feature Project: hydraheadipad Reporter: 9 Nov 2026 10:53

Description

What is asked for

Send controller signals into a live stream from the cluster, so that the body and
the experience cannot tell them apart from a person holding the controller in
front of the iPad.

What exists today

Nothing can inject input. The head already polls a command channel every 3
seconds at GET /api/v1/heads/{id}/commands, but the payload is a single
boolean, screenshot. The head can therefore be asked to show what is on its
screen, and it cannot be asked to do anything.

The screenshot half is the useful precedent: together with input injection it
gives see and act, which is what walking a testbook without a person at the
device needs.

The injection point

Every controller event on the iPad funnels through one method:
Vendors/hydra-moonlight-ios/Limelight/Input/ControllerSupport.m,
updateFinished:. It reads one Controller object (button flags, both
triggers, both sticks) and makes a single LiSendMultiControllerEvent call.

A synthetic Controller driven through that same method produces packets that
are identical on the wire. There is no separate path to keep consistent and no
flag for the body to read, because the body is handed the same bytes.

The exit combination (Start plus Select plus L1 plus R1) is detected inside
updateFinished: from lastButtonFlags, so injected input trips the head's own
combination logic as well. That makes the deliberate exit route of issue 1154
testable from the cluster.

Design

Carry a sequence, not one press. The command channel polls every 3 seconds,
which is far too slow for one event per poll, and a remote operator does not
want to feel that latency. One poll instead delivers a whole script:

[
  {"buttons": ["a"], "hold_milliseconds": 80},
  {"wait_milliseconds": 200},
  {"buttons": ["start", "back", "left_shoulder", "right_shoulder"],
   "hold_milliseconds": 2000}
]

The head runs the script locally at the correct speed. Poll latency then only
decides when a sequence starts, never how it plays. Button names are spelled in
full, with no abbreviations.

New cluster route to enqueue: POST /api/v1/heads/{id}/input, admin gated, the
same authorisation shape the screenshot routes already use. The existing
commands payload grows a field to hand the queued script to the head.

What this cannot do

It cannot reproduce issue 1153, the A press that raises the iPad keyboard over
the game. That behaviour comes from the iPadOS focus engine, which reacts to the
physical input device before the application sees the event. Synthetic input
enters below that layer. Issue 1153 still needs a person with a real controller.

Acceptance

  • A queued script moves a character in a running experience on a body.
  • The exit combination script returns the head to the grid and does not show the
    red failure panel, which walks the deliberate exit route of issue 1154.
  • The body log and the Sunshine log show nothing that marks the input as
    synthetic.
  • Runbook records the route, the script grammar and the issue 1153 limit.
  • Testbook gains steps for a queued script and for an empty queue.

Shipped

hydracluster v2.1.0 (458a282, released 2026-11-09). The release feed at
releases.experiencenet.com/hydracluster/production/latest.json now serves
2.1.0. The production box picks it up on its own update cadence, so the live
/health still reported v2.0.137 at the time of writing.

hydraheadipad v0.6.0 (9897ab4, submodule d15c7ae). Validate run
42606552920 gave ** BUILD SUCCEEDED ** with all 44 selectors at the right
arity and HydraSyntheticController.m compiled into the target on arm64.

What was built

POST /api/v1/heads/{id}/input      queue one script, admin gated
GET  /api/v1/heads/{id}/input      the head collects it, the slot empties
GET  /api/v1/heads/{id}/commands   {"screenshot": false, "input": true}

A step either holds a controller state for hold_milliseconds and returns the
gamepad to neutral, or rests at neutral for wait_milliseconds.

Sender, so no JSON needs writing:

scripts/send-controller-input.sh <head-id> a:80 wait:200 \
    start+back+left_shoulder+right_shoulder:2000

Three decisions worth recording

The command payload stays all booleans. Heads already in the field decode
the whole /commands payload as a dictionary of booleans. A value of any other
type would have broken the screenshot command on every deployed head the moment
the cluster updated, silently. So the new command is a boolean doorbell and the
script is collected from its own route. Testbook step 2 on the cluster side
guards this.

The injector drives ControllerSupport updateFinished:, not
LiSendMultiControllerEvent directly.
That method is the single place that
calls LiSendMultiControllerEvent, so there is one input path rather than two
to keep agreeing. More importantly the controller exit combination is detected
inside updateFinished:, from lastButtonFlags. Sending the packets
directly would have reached the body and left the head sitting in the stream.
Driving the real method means a scripted combination leaves the stream exactly
as a physical one does, which is what makes this able to walk issue 1154's
deliberate exit route with nobody at the device.

It drives the on screen controls gamepad, not a third Controller. A
physical gamepad is merged into that one, and updateFinished: combines the
pair with an OR, so a script and a person holding a controller add together
rather than fighting over player zero.

The limit, stated so nobody expects otherwise

This cannot reproduce issue 1153. A scripted A press cannot raise the iPad
keyboard. That behaviour is the iPadOS focus engine reacting to the physical
input device before the application sees the event, and synthetic input enters
below that layer. Issue 1153 still needs a person with a real controller. This
is a property of iPadOS, not a gap to close later, and both the runbook and the
testbook say so.

The accepted vocabulary is therefore the fourteen buttons
reportControllerArrival: declares for a gamepad with no GCController behind
it: a, b, x, y, up, down, left, right, left_shoulder, right_shoulder, start,
back, left_stick_button, right_stick_button. special, the paddles, the
touchpad and the share button are deliberately excluded, because sending a
button the pad never declared is not worth the risk.

Still to do

Nothing is device verified. 12 new steps in the hydraheadipad testbook under
"Controller input arrives from the cluster (issue 1155)" and 10 in the
hydracluster testbook, none walked. The valuable ones are head step 7 (a
scripted exit combination leaves quietly), step 8 (ending the stream stops the
script mid hold), step 10 (a scripted press does NOT raise the keyboard) and
step 12 (the screenshot command still works, which is the compatibility check).

Issue stays open until those are walked.

Session Context

Venue
cloud-seven