fix so keyboard input works

Emscripen was hogging all keyboard events even when canvas didn't have
focus. There's an arcane way to fix that in js.
This commit is contained in:
Eric House 2021-02-16 05:59:54 -08:00
parent 74109ce172
commit 88e44d45ff
3 changed files with 6 additions and 5 deletions

View file

@ -67,7 +67,7 @@ all: main.js
# ${INPUTS} -o $@
# This isn't a thing any more
main.html: ${INPUTS} $(MAKEFILE) shell_minimal.html
main.html: ${INPUTS} Makefile shell_minimal.html
emcc $(DEFINES) -I . -I ../common -I ../relay -s USE_SDL=2 \
--preload-file assets_dir --shell-file shell_minimal.html \
-s USE_SDL_TTF=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' \
@ -76,9 +76,9 @@ main.html: ${INPUTS} $(MAKEFILE) shell_minimal.html
-s WASM=1 \
${INPUTS} -o $@
install: main.html $(MAKEFILE)
install: main.html
if [ -n "${XW_WASM_DEST}" ]; then \
for FILE in ${OUTPUTS} paho-mqtt.jspi xwutils.js; do \
for FILE in ${OUTPUTS} paho-mqtt.js xwutils.js; do \
[ -f $$FILE ] && scp $$FILE ${XW_WASM_DEST}; \
echo "$$FILE copied"; \
done; \

View file

@ -1,4 +1,4 @@
/* -*- compile-command: "cd ../wasm && make MEMDEBUG=TRUE main.html -j3"; -*- */
/* -*- compile-command: "cd ../wasm && make MEMDEBUG=TRUE install -j3"; -*- */
/*
* Copyright 2021 by Eric House (xwords@eehouse.org). All rights reserved.
*

View file

@ -129,7 +129,8 @@
let arguments = window.location.search.replaceAll('?', '').trim().split('&');
var Module = {
preRun: [],
// preRun: see https://stackoverflow.com/questions/45936800/emscripten-canvas-jquery-toggle-focus/46083467
preRun: [function () {ENV.SDL_EMSCRIPTEN_KEYBOARD_ELEMENT = "#canvas";}],
postRun: [],
arguments: arguments,
print: (function() {