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.

Try it with your phone Source, MIT Drive a car with it

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

1 msround trip on the direct link (two browser tabs, one PC)
128 msmedian round trip through the relay (30 pings)
12/12checks in a headless Unreal 5.7 game, two scripted phones
21/21relay checks, local and deployed

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

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