diff --git a/src/input.c b/src/input.c
index a4f52a8..21593ad 100644
--- a/src/input.c
+++ b/src/input.c
@@ -297,3 +297,11 @@ const char *input_button_to_name(button_t button) {
}
return button_names[button];
}
+
+
+#if defined(__EMSCRIPTEN__)
+ #include
+ void EMSCRIPTEN_KEEPALIVE set_button(uint32_t button, uint32_t state) {
+ input_set_button_state(button, state ? 1.0 : 0.0);
+ }
+#endif
\ No newline at end of file
diff --git a/src/wasm-index.html b/src/wasm-index.html
index f739147..5b66efe 100644
--- a/src/wasm-index.html
+++ b/src/wasm-index.html
@@ -3,6 +3,9 @@
+
+
+
wipEout
@@ -143,6 +272,19 @@
no intro, no music ~11mb
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -164,10 +306,12 @@
audioCtx.resume();
return false;
};
+
var requestFullscreen = (ev) => {
ev.preventDefault();
document.getElementById('game').requestFullscreen();
};
+
document.getElementById('select-version').style.display = 'block';
document.getElementById('fullscreen').addEventListener('click', (ev) => requestFullscreen(ev, 'wipeout.js'))
document.getElementById('load-full-version').addEventListener('click', (ev) => loadScript(ev, 'wipeout.js'));
@@ -177,6 +321,29 @@
var progressElement = document.getElementById('progress');
var spinnerElement = document.getElementById('spinner');
+ let onGameLoad = function() {
+ document.getElementById('loading').style.display = 'none';
+ window.scrollTo(0, 0);
+
+ // Setup touch buttons if this is a touch device
+ if ('ontouchstart' in window) {
+ document.getElementById('head').style.display = 'none';
+ document.body.classList.add('touch');
+ let touchButtons = document.getElementsByClassName('button');
+ for (let i = 0; i < touchButtons.length; i++) {
+ let button = touchButtons[i];
+ button.addEventListener('touchstart', (ev) => {
+ Module._set_button(parseInt(ev.currentTarget.dataset.button), 1);
+ ev.currentTarget.classList.add('active');
+ });
+ button.addEventListener('touchend', (ev) => {
+ Module._set_button(parseInt(ev.currentTarget.dataset.button), 0);
+ ev.currentTarget.classList.remove('active');
+ });
+ }
+ }
+ };
+
var Module = {
preRun: [],
postRun: [],
@@ -211,7 +378,7 @@
progressElement.hidden = true;
if (!text) {
spinnerElement.hidden = true;
- document.getElementById('loading').style.display = 'none';
+ onGameLoad();
}
}
statusElement.innerHTML = text;