Hackpack Experiments
Try-outs for the Twilio Hackpack v4 kiosk that are not games, served as plain HTML. Linked from both arcade menus.
Open on the device
http:///_api/- On-screen keyboards — QWERTY, ABC, phone pad and big keys. Type what you want and press MAKE: AI writes a page for the kiosk.
- Made here — Every page made from the keyboard, newest first.
- Block World — A tiny block-building world drawn with canvas 2D. Arrows walk, drag the screen to look, tap a block to break it, hold to place one.
Where things live
backend.js serves every page at /_api/<path> from its PAGES list, with each page's script as a String.raw constant at the bottom (KEYBOARDS_JS). App.jsx is only this page.
minis.js is imported by backend.js and handles make, made and m/<id>. MAKE on the keyboard posts the typed words to make, which asks AI for one canvas page written to the device rules, saves it in the minis database and opens it. Change what the AI is told in its RULES text. AI calls from this public page use the owner's credits, capped at 40 pages a day.
The keyboards page shows the last input (tap position or key) under the text box, so you can see how the touch screen's taps land.
Device rules every page follows
TARGET DEVICE: Twilio Hackpack v4 (Raspberry Pi Zero W, 2018 firmware)
Every page backend.js serves at /_api/<path> runs on this device. App.jsx
(the vibes.diy page) is for people on vibes.diy only; the device never loads
it. When you add or change a page, edit PAGES and its script constant in
backend.js, and keep every page script inside these rules.
BROWSER
- Full-screen kiosk built on WebKitGTK 2.16, about the same as Safari 10.1 (2017).
- ES2017 at most. Avoid: optional chaining (?.), nullish coalescing (??), object
spread, Array.prototype.flat, private class fields, BigInt.
- Use one classic <script>, not type="module". Use XMLHttpRequest, not fetch.
- CSS: flexbox, grid and custom properties are fine. Avoid flex "gap",
aspect-ratio, :is()/:where() and inset.
- Slow CPU (single core, 512 MB RAM): keep the DOM small, prefer one <canvas>,
no large libraries.
SCREEN
- 640 x 480 viewport, no scrolling. Use big, high-contrast text (16px minimum,
20px+ for menu items).
INPUT: joystick and buttons as keys, plus a touch screen (see TOUCH SCREEN)
The hardware controls arrive as ordinary keydown/keyup events:
Control Key e.keyCode e.key
Joystick up ArrowUp 38 "ArrowUp"
Joystick down ArrowDown 40 "ArrowDown"
Joystick left ArrowLeft 37 "ArrowLeft"
Joystick right ArrowRight 39 "ArrowRight"
START Enter 13 "Enter"
SELECT Space 32 " "
A a 65 "a"
B b 66 "b"
X x 88 "x"
Y y 89 "y"
POWER (tap) Escape 27 "Escape"
- Check e.keyCode first and fall back to e.key. Call preventDefault() on these keys.
- The joystick is digital, like arrow keys. A diagonal sends two arrows held
at once, so track key state with a "held" map on keydown/keyup rather than
reacting only to single presses.
- Held keys may auto-repeat keydown. Ignore repeats unless you want them.
- Desktop playtesting: the same keys on a laptop keyboard behave identically.
RESERVED / CAUTION
- POWER: 1 tap = Escape (use it for in-app back; it arrives about 0.4 s after
the tap), 2 taps = home to the launcher (your page never sees it), 3 taps =
toggle the joystick between arrow keys and mouse cursor, hold 3 s = shutdown.
Never ask users to tap POWER more than once or to hold it.
- Show on-screen hints using these button names: START, SELECT, A, B, X, Y,
joystick.
INPUT MODE (persistent; set it on load)
- Call pywebview.api.inputArrow({}) for keyboard/arrow controls (default), or
pywebview.api.inputCursor({}) if your page needs the joystick as a mouse.
- Poll for window.pywebview.api first; it appears shortly after load. Do nothing
if it never appears (desktop testing).
- The mode persists until changed. Users can also flip it with 3 taps of POWER.
- Every page in this vibe already calls inputArrow({}) on load (INPUT_JS).
TOUCH SCREEN
- The screen is a touch screen in mouse mode: a tap arrives as mousedown /
mouseup / click at the tapped point, not as touch events. Make on-screen
buttons tappable (listen for mousedown, map clientX/clientY through
getBoundingClientRect to canvas coordinates) and keep them big, about 48 px
or more. Keep joystick control working too.
CONVENTIONS (match the existing launcher and Arcade)
- Menus: up/down to choose, START or A to confirm, B to go back.
- In games: A = primary action, B = secondary/back, START = pause,
SELECT = alternate action (e.g. boost).
- The page must work fully with keyboard input from the moment it loads, with
nothing to click first.
OPTIONAL: LED BAR (5 RGB LEDs)
Pages loaded in the kiosk can reach the Hackpack's Python API. It appears
shortly after load, so poll for it:
window.pywebview && window.pywebview.api
Calls return Promises and take a single plain object of strings/numbers only
(no booleans or null):
pywebview.api.showLightsParams({demo: 3, repeat: 1}) // built-in pattern 1-37
pywebview.api.lightsOff({})
pywebview.api.setLightIntensity({intensity: 40}) // 0-100, default 15
Patterns: 1 scanner, 2 white swell, 3 rainbow, 12-17 pong colors,
18-23 color waves, 30-37 "OK Go" flashes (32 green, 35 red).
Only one call to the same function may be in flight at once; wait for its
Promise before calling it again. The page must still work when
window.pywebview is missing (e.g. desktop testing).