A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(ci): a golden run that actually holds a gamepad
esengineeeeb56478df7
diff --git a/desktop/scripts/inputScript.mjs b/desktop/scripts/inputScript.mjsindex 29ffc751c..ea2aee4fd 100644--- a/desktop/scripts/inputScript.mjs+++ b/desktop/scripts/inputScript.mjs@@ -22,6 +22,10 @@* a frame range. A playthrough is a sequence, not a posture: "walk there, turn* round, hit it" cannot be said by keys all pressed at frame zero.*+ * `pad` is a gamepad the harness holds: the engine polls navigator.getGamepads,+ * so standing one up there drives its real polling path rather than poking its+ * state. Each entry sets axes/buttons over a frame range.+ ** `touches` are real TouchEvents — what a phone sends and what the web platform* binds; a mouse pointer proves nothing about playing with a thumb. Each presses* at (x, y) and optionally drags to (toX, toY) over its frame range, in@@ -34,6 +38,14 @@ export function inputScript(spec) {const taps = JSON.stringify((spec.taps ?? []).map((t) => ({ key: String(t.key), at: Number(t.at) || 0 })),);+ const pad = JSON.stringify(+ (spec.pad ?? []).map((p) => ({+ from: Number(p.from) || 0,+ to: Number(p.to ?? frames),+ axes: p.axes ?? {},+ buttons: p.buttons ?? {},+ })),+ );const touches = JSON.stringify((spec.touches ?? []).map((t, i) => ({id: i + 1,@@ -119,6 +131,18 @@ export function inputScript(spec) {const taps = ${taps};const holds = ${holds};const touches = ${touches};+ const padSpec = ${pad};+ let padState = null;+ if (padSpec.length) {+ padState = {+ index: 0, id: 'harness pad', connected: true, mapping: 'standard', timestamp: 0,+ buttons: Array.from({ length: 17 }, () => ({ pressed: false, touched: false, value: 0 })),+ axes: [0, 0, 0, 0],+ };+ Object.defineProperty(navigator, 'getGamepads', {+ value: () => [padState], configurable: true, writable: true,+ });+ }const live = [];const down = new Set();for (let i = 0; i < ${frames}; i++) {@@ -126,6 +150,17 @@ export function inputScript(spec) {if (h.from === i) { fireKey('keydown', h.key); down.add(h.key); }if (h.to === i && down.has(h.key)) { fireKey('keyup', h.key); down.delete(h.key); }}+ if (padState) {+ for (const p of padSpec) {+ const on = i >= p.from && i < p.to;+ for (const k of Object.keys(p.axes)) padState.axes[+k] = on ? p.axes[k] : 0;+ for (const k of Object.keys(p.buttons)) {+ const v = on ? p.buttons[k] : 0;+ padState.buttons[+k] = { pressed: v > 0.5, touched: v > 0, value: v };+ }+ }+ padState.timestamp = i;+ }for (const t of touches) {if (i === t.from) {live.push({ id: t.id, x: t.x, y: t.y });@@ -158,7 +193,8 @@ export function inputScript(spec) {for (const k of down) fireKey('keyup', k);for (const k of keys) fireKey('keyup', k);await raf();- return keys.length + taps.length + holds.length + touches.length + (pointer ? 1 : 0);+ return keys.length + taps.length + holds.length + touches.length + padSpec.length+ + (pointer ? 1 : 0);})()`;}diff --git a/tools/goldenProjects.mjs b/tools/goldenProjects.mjsindex faffe4641..bf115e61f 100644--- a/tools/goldenProjects.mjs+++ b/tools/goldenProjects.mjs@@ -77,7 +77,6 @@ export const KNOWN_GAPS = {// Present in the engine and shown by non-golden samples, but never carried// through the chain by a project the release argues from.settings: 'Celestial Heights persists language, effects and key bindings and reads them back at boot; volume waits on the game having sound',- controller: 'input-actions binds a gamepad, but no golden run drives one — Celestial Heights P5',// Measured: hello-world exports a 2.82MB single file, video-puzzle 3.22MB — so// the floor is the runtime, not the game, and no project reaches the 2MB cap.'startup-size': 'the playable runtime floor (~2.8MB) exceeds the 2MB default profile cap; see REARCH_EXPORT',@@ -171,7 +170,7 @@ export const GOLDEN = [certifies: ['tilemap', 'tile-collision', 'navigation', 'behavior-tree','scene-transition', 'y-sort', 'localization', 'ui-layout', 'text',- 'persistence', 'ui-inventory', 'achievements', 'touch',+ 'persistence', 'ui-inventory', 'achievements', 'touch', 'controller',],targets: ['web', 'desktop'],// Nightly, not pr: a project earns the release gate by having run, and this@@ -185,6 +184,9 @@ export const GOLDEN = [frames: 60,responds: 0.55,touches: [{ from: 4, to: 58, x: 0.13, y: 0.78, toX: 0.30, toY: 0.78 }],+ // Left stick east. The map binds it beside WASD, and nothing but a run+ // that holds a pad proves the binding is more than a line of code.+ pad: [{ from: 2, to: 58, axes: { 0: 1 } }],},},{@@ -261,6 +263,7 @@ export function interactFor(g) {keys: g.interact.keys ?? [],pointer: g.interact.pointer ?? null,touches: g.interact.touches ?? null,+ pad: g.interact.pad ?? null,frames: g.interact.frames ?? 40,responds: g.interact.responds ?? DEFAULT_RESPONDS,};diff --git a/tools/verify-golden.mjs b/tools/verify-golden.mjsindex 00550bb4a..e866f38fe 100644--- a/tools/verify-golden.mjs+++ b/tools/verify-golden.mjs@@ -199,10 +199,17 @@ for (const { id, target } of pairs) {touch: true,});}+ if (input.pad) {+ gestures.push({+ what: 'a gamepad',+ spec: { pad: input.pad, frames: input.frames },+ touch: false,+ });+ }let allAnswered = true;for (const gesture of gestures) {- const drivenPng = path.join(WORK, `${id}-${target}-driven-${gesture.touch ? 'touch' : 'keys'}.png`);+ const drivenPng = path.join(WORK, `${id}-${target}-driven-${gesture.what.replace(/\W+/g, '-')}.png`);const drive = spawnSync('npx', ['electron', path.join('scripts', LAUNCHER(target)),'--dir', out, '--out', drivenPng,