diff --git a/pkg/emscripten/sopwith.html b/pkg/emscripten/sopwith.html index f8d3e77..7b90a66 100644 --- a/pkg/emscripten/sopwith.html +++ b/pkg/emscripten/sopwith.html @@ -58,6 +58,11 @@ function openManual() { window.open("doc/sopwith-emscripten.html"); } + function promptForInstall() { + if (installPrompt != null) { + installPrompt.prompt(); + } + } function programError() { canvas.style.visibility = "hidden"; loadingElement.style.visibility = "visible"; @@ -111,6 +116,11 @@ if (text) Module.printErr('[post-exception status] ' + text); }; }); + var installPrompt = null; + window.addEventListener("beforeinstallprompt", (event) => { + event.preventDefault(); + installPrompt = event; + }); diff --git a/src/swtitle.c b/src/swtitle.c index acb5f7c..c205eb7 100644 --- a/src/swtitle.c +++ b/src/swtitle.c @@ -220,6 +220,7 @@ void getgamemode(void) #endif #ifdef __EMSCRIPTEN__ swputs(" M - open manual\n"); + swputs(" I - install as app\n"); #endif Vid_Update(); @@ -255,6 +256,9 @@ void getgamemode(void) break; #endif #ifdef __EMSCRIPTEN__ + case 'I': + emscripten_run_script("promptForInstall()"); + break; case 'M': emscripten_run_script("openManual()"); break;