anchor-demo / PhonePad
Your phone is the gamepad
Players scan a QR code and their phone's browser becomes a controller, for a web game or an Unreal game. Nothing to install on Android or iPhone. The game sees an ordinary gamepad, so a game that already reads gamepads needs no new input code.
Point your phone's camera at this code
or open the controller page and type
....
No phone? Open the controller in a new tab
Up to four phones at once. Each drawing above is what the page reads from navigator.getGamepads(), the same call any web game makes.
Measured
A phone on Wi-Fi has not been timed yet. The join box above shows each phone's path and its measured round trip as you play.
How it works
- The relay is a Cloudflare Worker. It opens a room for a game, gives it a 4-letter code and a QR code, serves the phone's controller page, and forwards between phones and the game. It keeps nothing once the room closes.
- Web games get a direct link. The relay introduces the phone and the page, then they talk straight to each other over WebRTC. If that link can't be made, input keeps going through the relay.
- Unreal games load an input-device plugin. Each phone becomes the usual
Gamepad_*keys for local player N, with the engine's own button-repeat timing and stick thresholds. - On the phone: a gamepad layout (stick, A/B/X/Y, shoulders, triggers) or a driving layout (gas and brake pedals, steering by tilting the phone or an on-screen slider). Buttons can carry the game's own names. A phone that drops gets its seat back within 30 s; a phone that sleeps lets go of everything.
Use it in your game
Deploy the relay once (npx wrangler deploy in relay/), then, in a web game:
import { PhonePad } from 'https://<your relay>/phonepad-host.js';
const pads = await PhonePad.start({ relay: 'https://<your relay>', layout: 'pad', seats: 4 });
pads.show(); // the QR box; phones now appear in navigator.getGamepads()
In Unreal 5.7, copy unreal/PhonePad into Plugins/ and set the relay:
[/Script/PhonePad.PhonePadSettings]
RelayUrl="https://<your relay>"
Seats=4
The README has the rest: the options, the Blueprint functions, the tests and the protocol.
Notes
- iPhone browsers cannot vibrate. Android phones buzz on each press and when the game asks.
- Tilt steering needs one tap to allow motion (iPhone asks), then a short calibration: hold the phone as you will play, tap Centre, turn it a little right.
- The relay stores no names, addresses or input. A room lasts while its game is open.