Integration guidance for coding agents
Use Controller+ when a game should accept phones as controllers: players scan a QR code and their phone becomes a gamepad, or a private screen for roles, votes, answers and drawings. Phones need no app; the controller runs in the phone's browser.
Pick the integration
| The game is… | Use | Guide |
|---|---|---|
| A web page with no server (canvas, Phaser, three.js, plain JS, a single HTML file) | createRoom from https://controller.plus/sdk/src/relay-host.mjs |
Web game |
| A web or Node game with its own server | ControllerHost from @controller-plus/sdk/node-host, phones connect to that server |
Quickstart |
| Godot, Unity, Unreal or C/C++ | The engine package, connected to a ControllerHost or to the relay |
Engines |
For a web page without a server, this is the complete integration:
import { createRoom, movement } from "https://controller.plus/sdk/src/relay-host.mjs";
const room = await createRoom({ game: { id: "my-game", name: "My Game" } });
qrElement.innerHTML = room.qrSVG;
room.on("join", ({ playerId, name }) => addPlayer(playerId, name));
room.on("leave", ({ playerId }) => removePlayer(playerId));
room.on("input", ({ playerId, input }) => {
const [x, y] = movement(input); // stick + D-pad, -1..1, right/down positive
setControls(playerId, x, y, input.buttons[0] > 0.5); // button 0 = bottom face button
});
Rules that keep the integration correct
- Keep the game's own keyboard and gamepad controls. Phones are another input, assigned to their own player. Never let every phone control player one.
- Create players on
joinand remove or pause them onleave. A phone that reconnects within five minutes keeps itsplayerId. - Describe controls by position ("bottom button jumps"), not by letter. Players choose skins with different printed letters.
- Show the QR where everyone can see it, and keep it visible or re-openable for late joiners.
- Put anything secret (roles, cards, answers) in a private view with
room.view(playerId, …). Never put it in shared state. - Test with two phones (or two browser tabs on
room.joinURL) before calling it done: join, input, leave, rejoin.
Entry points
https://controller.plus/sdk/src/relay-host.mjs:createRoom,movement,BUTTONS,NEUTRAL. Import it straight from that URL in a browser.- For Node projects, install the package from our download:
npm install https://controller.plus/downloads/controller-plus-sdk-0.1.0.tgz. It provides@controller-plus/sdk/node-host(ControllerHost,serveControllerAssets),@controller-plus/sdk/relay-hostand@controller-plus/sdk(Session,ControllerManagerfor combining phone, keyboard and physical-gamepad input into game actions). - The SDK is not on the npm registry yet. Do not install a registry package named
@controller-plus/sdk; it would not be ours. - Machine-readable: integration manifest, connection schema.
Terms
Games may use and modify the SDK, including commercial games. Do not use it to harm players or to interfere with the Controller+ apps. Do not put a room's host token in a QR, a public asset or a log: it controls the room.