Phase D/F/H: embedding shell - loading progress, fullscreen, file upload, touch controls

package/src/index.ts: fixes a real pre-existing bug (start()/loadTable()
never actually called vpinball_wasm_start with a table path argument),
adds byte-level download progress (onProgress) and requestFullscreen().

package/src/touch-controls.ts: new on-screen virtual flipper/plunger/start
button overlay that synthesizes the actual default keyboard scancodes
(SDL_SCANCODE_LSHIFT/RSHIFT/RETURN, read from InputManager.cpp) as real
KeyboardEvents dispatched on window, matching SDL3's Emscripten keyboard
target - keeps the native input path completely unmodified.

examples/basic/index.html: a real demo page - progress bar, a user-gesture
"Start" button (required for both audio autoplay and fullscreen), a file
picker for self-contained .vpx uploads, and the touch overlay shown on
touch-capable devices.

scripts/build.sh: two real bugs found and fixed via actual browser testing:
- MODULARIZE=1 without EXPORT_ES6=1 produces a classic script, not an ES
  module with a default export - `await import(...)).default` was always
  undefined. Fixes with -sEXPORT_ES6=1.
- --closure 1 silently stripped FS.writeFile/readFile/mkdir down to just
  low-level node ops, breaking runtime table loading with no compile-time
  warning. Dropped until root-caused; -O2 alone is kept.

Verified end-to-end in Chrome: full load->progress->start flow with no
errors, fullscreen actually engaging (document.fullscreenElement true),
and a file-picker-selected table loading correctly (LoadGameFromFilename
/tables/uploaded.vpx in the boot log, followed by a normal render).

README updated to reflect what's now validated vs. still open (real-device
input/audio confirmation remains the main open item).
This commit is contained in:
2026-08-22 16:45:04 +02:00
parent a5e5b6f34a
commit 487ca40a44
6 changed files with 352 additions and 46 deletions
+7 -2
View File
@@ -40,6 +40,7 @@ EMSCRIPTEN_LINK_FLAGS=(
-sMAX_WEBGL_VERSION=2
-sALLOW_MEMORY_GROWTH=1
-sMODULARIZE=1
-sEXPORT_ES6=1
-sEXPORT_NAME=VPinballModule
-sENVIRONMENT=web
-sEXPORTED_RUNTIME_METHODS=FS,ccall,cwrap
@@ -53,8 +54,12 @@ if [ "$BUILD_TYPE" = "Debug" ]; then
else
# CMAKE_BUILD_TYPE=Release only optimizes the compile step; emcc's link
# step needs its own -O level to actually run wasm-opt/dead-code
# elimination and (with --closure) minify the JS glue.
EMSCRIPTEN_LINK_FLAGS+=(-O2 --closure 1)
# elimination. NOTE: --closure 1 was tried here but strips FS.writeFile/
# readFile/mkdir (the FS convenience wrappers EXPORTED_RUNTIME_METHODS=FS
# is supposed to guarantee) down to just low-level node ops - dropped
# until that's root-caused, since a smaller JS glue isn't worth a broken
# runtime table-loading API.
EMSCRIPTEN_LINK_FLAGS+=(-O2)
fi
emcmake cmake \