Playing with the TV remote
In Fabi Play’s TV apps (Samsung, LG, Android TV and Google TV, Fire TV) a family can also play without a phone: the home offers «Col telecomando» (with the remote) next to «Col telefono» (with the phone, recommended). A grown-up picks who is playing on the TV («Chi gioca?»: the age, an avatar, a name if they like), then a game that can be played with the remote. There is no calibration: the intro, then the game.
A game opts in with inputs in fabi-play.json:
"inputs": ["body", "remote"]inputs is optional; absent means ["body"]. It always includes "body" (Fabi Play is a movement platform), lists
each input once, and knows only body and remote: anything else is an error in the check (the Studio,
parseManifest, the JSON Schema). Only games that list "remote" are shown when playing with the remote.
With one child, most games need no code
Section titled “With one child, most games need no code”The screen turns the remote’s keys into the gestures the body makes, and animates a puppet body in the frames (the
same puppet as the simulator), so gesture events, drawAvatar and the keyboard adapter
(data-keys, FabiPlay.keys()) work as with a camera:
| Key | Gesture |
|---|---|
| ↑ or OK | jump (then land); a held key jumps once |
| ↓ held | squat, then stand on release |
| ← / → | lane-left / lane-right (stepping back to the middle is lane-center, as with the body) |
| OK twice quickly | clap (the first press already jumped) |
| Back | Fabi Play’s pause (a pause message), never the game’s |
OK twice is a clap only in games whose movements include "clap" (elsewhere it is two jumps). A key held down
counts once, and a key still held when a pause or a turn starts counts again only after it is released. Nothing
else is made: no hands aiming, no shapes, no freeze. The game never gets the keys themselves. While it
plays, the TV shows a small legend of the keys your game uses (from movements in the manifest) in the bottom-right
corner, and a reminder that the phone plays better in the bottom-left one: keep those corners free of anything
essential. On a tablet or a phone playing alone, the top-right corner is Fabi Play’s too (its pause button: see
Pause and resume).
The Magic Remote (LG) points too
Section titled “The Magic Remote (LG) points too”It reaches the game as ordinary pointer and mouse events: hover, and a click with OK. While it points, its OK is
only that click, not a jump. play.pointer is true when
the TV saw the remote point before the game started (only with "remote"; it is not updated later). A game that
lists "remote" must work with the arrow keys alone and, where it has things to pick (bubbles, answers, buttons),
let a pointer click them as well: pointer events, large hit areas, a hover highlight. Fabi Play’s own menus, the
pickers and the turn screen are clickable too, and hovering one of their buttons focuses it.
The arrows as a cursor: "remoteCursor": true
Section titled “The arrows as a cursor: "remoteCursor": true”A game picked or drawn with a pointer (a painting game) can ask for the arrows to move a free cursor instead of making gestures:
"inputs": ["body", "remote"], "remoteCursor": trueThen, in remote mode, the TV draws a cursor above your game in the colour of the child playing and moves it with the
arrows: slowly at first, for precision, faster the longer an arrow is held, stopping at the edges. OK presses it:
held, it stays pressed (OK held = paint); a quick OK is a click. Back is still Fabi Play’s pause. Your game gets it
exactly like a Magic Remote: play.pointer is true, and the SDK makes ordinary pointermove/mousemove,
pointerdown/mousedown, pointerup/mouseup and click events at the cursor. At a pause, a break or a turn a
held OK is let go with pointercancel and mouseup, no click. The arrows make no gestures then (no lanes, no jump,
no squat), and the legend in the corner says «Muovi», «Premi (tieni premuto per disegnare)», «Pausa». If the Magic
Remote’s own pointer is used too, whichever was used last wins.
Several children: turns, if your game follows the contract
Section titled “Several children: turns, if your game follows the contract”One remote is one child. With several children Fabi Play runs turns, a round each, but only for games that say in
fabi-play.json that they follow the turns contract, with "turns": true (only next to "remote" in inputs):
"inputs": ["body", "remote"], "turns": trueThe TV reads it from your manifest when the game is chosen, and only then sends the turn order in init. A game
without it is played by the first child only, and the TV tells the grown-up it is «un bambino alla volta» (one child
at a time).
The game sees one child at a time. play.players is the child playing now (exactly one id, a frozen array: read it
again after a turn), and play.turns is every child who plays, in order ([1, 2, 3]; one child, or the body: the
same as play.players). The contract:
- Play a round (a race, a level) with the child in
play.players. - When that child’s round ends, whatever happened in it (a crash or a fall ends a round too), and turns remain, call
play.break('turn'). The screen always answersbreak-start, then shows «Tocca a Mia!» (Mia’s turn) with the scores so far until a grown-up hands over the remote and presses OK (the turn screen may also host an ad, as other breaks do), then sends aturnmessage (play.on('turn', ({ players }) => …), orFabiPlay.on('turn', …)), after whichplay.playersis the next child, thenbreak-done. Start that child’s round. - After the last child’s round, call
play.end()with every child’s scores:play.end([{ player: 1, … }, { player: 2, … }]). The end screen shows each child’s stars. Ending before every child has played is a bug: the TV warns in its console (the simulator in its log).
Only break('turn') swaps children: break('level') and break('gameover') never do, so a round never changes hands
midway. The SDK takes a turn only inside a 'turn' break, and only to the next child in play.turns; it drops any
other. Player ids keep their meaning (slots, avatars): keep each child’s score by id. At a turn the next child’s
puppet starts recentred, in the middle lane, with no lane gesture (the keyboard adapter resets its lane too). With
the simple API, score(n) without a player goes to the child playing now, and end(n) gives the child playing now
n and each child before them their last score() (or 0). A body session never gets a turn: its players stay for
the whole game.
const play = await connect()const scores = new Map()play.ready()startRound(play.players[0])
async function roundOver(player, score) { scores.set(player, score) if (play.turns.indexOf(player) < play.turns.length - 1) { // break-start, the turn screen, turn (play.players is the next child now), break-done. await play.break('turn') startRound(play.players[0]) } else play.end(play.turns.map((p) => ({ player: p, score: scores.get(p) ?? 0 })))}Adapt with play.input
Section titled “Adapt with play.input”play.input is 'body' (the default, and what older screens mean) or 'remote'; it is also in the start event
with pointer, and live as FabiPlay.input, FabiPlay.hasPointer, FabiPlay.players, FabiPlay.turns. With the
remote: slow the game down a little, show a selection the arrows move (and a pointer clicks) instead of a hand
cursor, drop what the remote can’t do.
Games aimed with the hands (movements: ["hands"], the pointer() adapter) should not list "remote" unless they
offer a remote-friendly selection: a child with a remote has no hand cursor.
Try it in the simulator
Section titled “Try it in the simulator”Tick «Telecomando» in the simulator’s panel: one puppet, the keyboard as the remote (the arrows, Enter for OK,
Backspace for Back), and init with input: 'remote'. With «Giocatori» above 1 and "turns": true in your
manifest the simulator sends the whole turn order (as the TV does) and shows «Tocca a Giocatore 2!» at each
break('turn') until you press Enter; the log shows break · turn, turn · ora gioca G2, and warns when the
manifest doesn’t say turns or the game ends before every child has played. «Puntatore» says the remote points (init.pointer): the mouse then reaches the game, as LG’s
Magic Remote would. simulator.html?remote=1&players=2 opens it that way. With "remoteCursor": true in your manifest, «Telecomando» moves
the TV’s cursor with the arrow keys instead (Enter presses it, held: pressed).