Controller+BETADownload

Connect phones to a local game

The six starters using examples/local-common run from the unpacked SDK archive with Node 22 or newer; it already holds the packages they need (in a source checkout, run npm ci once at the SDK root). No vendor service, account, bundler or development watcher is needed. Each game has two phone seats. Keep examples/local-common beside a starter when adapting it; that folder contains the HTTP(S) server, QR lobby, lifecycle handlers and test helpers. Source imports point into this checkout; change them to the SDK's public package exports when integrating into another project.

The browser tests import the committed driver from ../../testing/index.mjs so they run directly in the checkout. The SDK archive also ships the public @controller-plus/sdk/testing export; use that import in your own project. Install Chrome separately or set CHROME_PATH to its installed executable. No browser download occurs. Run tests one at a time, with one Chrome process for both phones. Godot tests use two SDK Session phones and stop Godot before any optional browser capture.

Contents

Join from a phone

Start the game with PUBLIC_ORIGIN set to this computer's reachable Wi-Fi address, including the starter's port. Replace the address in each README with your own. Open that same address on the shared display, then scan its QR with the phones' cameras. You can also open Open phone controller. Phones and computer must be on the same network, and the firewall and Wi-Fi must allow connections between them.

The default 127.0.0.1 address is for testing on this computer. A separate phone cannot reach it. These six servers accept PORT=49700 through PORT=49799; set PUBLIC_ORIGIN to the same port. An occupied port fails with an error so the QR never silently advertises a different address.

The pygame starter uses its own launcher and port range. Rally Court has a loopback showcase host.

Motion on iPhone

Touch controls work over ordinary LAN HTTP. Browser motion on iPhone needs a secure page and the player's permission. A phone opening another computer's HTTP address does not get the browser's localhost exception. MDN explains the secure-context and user-gesture requirements.

Choose the setup that fits your game:

All six servers accept certificate and key paths. For example, from the SDK root:

TLS_CERT=/absolute/path/to/trusted-cert.pem \
TLS_KEY=/absolute/path/to/private-key.pem \
PUBLIC_ORIGIN=https://game-host.local:49701 \
node examples/wheel-race/server.mjs

Replace the paths and hostname. Keep keys outside the checkout. The server serves HTTPS and WSS on the same port. Trust is required on the phone and any native engine client; these examples do not disable certificate verification. The Godot and C starters use gamepad controls, so their normal HTTP setup needs no sensor permission.

A new game's modes list turns on its first mode in the browser. A player can choose another supported mode in MENU; updates within that game keep the choice. Tap TAP FOR TILT on the wheel or flight instrument, allow motion access, then move the phone gently and check that the control responds. Wait for this first reading before tapping CENTER (Wheel) or LEVEL (Flight) in your comfortable hold. If permission is denied or no reading arrives, turn tilt off in MENU and drag the wheel or stick. Flight's throttle lever remains touch controlled. LEVEL also recenters the touch flight stick.

Seats, output and shutdown

runtime.mjs handles join with resumed, leave, removed, invitation and feedback-result. Games keep progress by player ID, clear input on departure, and delete it on permanent removal. A disconnected seat stays reserved for five minutes. The browser keeps its invitation and latest resume ticket in the same tab's session storage: refreshing the scrubbed /join page resumes automatically while those saved details and the seat remain valid. The driver's reload() performs a real page reload after releasing held touches. Reopening a current invitation in that tab also uses the saved ticket. A fresh tab without the ticket takes a new seat. If storage was cleared or the seat expired, scan the current QR; Disconnect clears the saved room and ticket. Server restarts create new rooms and reset progress.

Type remove p1 in the server terminal, then Enter, to free that seat. Removal invalidates its resume ticket and rotates the player invitation. The lobby observes the invitation revision and reloads both its QR and link. Only the player invitation is public. Engine host credentials stay in process memory or the authorized child environment.

Each scoring/action cue has a distinct request ID, followed by bounded rumble. A feedback-result receipt reports browser handling; it does not prove audible sound or physical vibration. Muted or unsupported output does not prevent playing.

Ctrl+C or SIGTERM closes the simulation timer, engine child if present, host sockets and HTTP(S) server. Test teardown uses finally, including on failure. The native starter also releases input when its host transport closes. The Godot add-on neutralizes on connection loss and reconnects with its runtime credentials.

Scratch files and captures

Set EXAMPLES_TMP and CONTROLLER_PLUS_TEST_TMP to a scratch directory on a disk with space. Godot stages its project and add-on there, so imports and .godot files never appear in the source checkout. Its staged project is removed after shutdown. On macOS, a sandbox permits file writes only inside that staged project; this game keeps progress in memory and never uses user://. Native builds stay in scratch for inspection and can be deleted afterward. No engine, browser or compiled binary is checked in.

Tests normally need no screenshot tool. For optional evidence, set EXAMPLE_CAPTURE_DIR and RENDER_PAGE to the installed render-page CLI. Tests save both phone PNGs, close their browser, then render the game with that CLI. Godot is stopped before this pass; its image is a scene SVG produced by the actual GDScript simulation, rather than a GPU framebuffer. Engine phone PNGs are a separate rendering pass after their Session tests.

Headless checks cover input routing, independent seats, feedback messages, resume, removal and cleanup. Real Wi-Fi, camera scanning, iPhone trust and motion prompts, physical tilt, speakers, vibration motors and physical gamepads still need device checks.

All start pages · Search developer docs · Ship a game