Skip to content

Commit 7e792c4

Browse files
committed
EMCC: implement ask(), fix key handling
1 parent c7a7e5a commit 7e792c4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/platform/emcc/runtime.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <emscripten/key_codes.h>
1313
#include "include/osd.h"
1414
#include "common/inet.h"
15-
#include "common/smbas.h"
15+
#include "common/device.h"
1616
#include "lib/maapi.h"
1717
#include "ui/audio.h"
1818
#include "ui/theme.h"
@@ -110,8 +110,9 @@ void Runtime::alert(const char *title, const char *message) {
110110
}
111111

112112
int Runtime::ask(const char *title, const char *prompt, bool cancel) {
113-
int result = 0;
114-
return result;
113+
return EM_ASM_INT({
114+
return !window.confirm(UTF8ToString($0) + "\n" + UTF8ToString($1));
115+
}, title, prompt);
115116
}
116117

117118
void Runtime::browseFile(const char *url) {
@@ -333,6 +334,13 @@ void Runtime::processEvent(MAEvent &event) {
333334
case EVENT_TYPE_DN:
334335
_output->scroll(false, false);
335336
break;
337+
case EVENT_TYPE_KEY_PRESSED:
338+
handleEvent(event);
339+
if (event.key != -1 && isRunning()) {
340+
dev_pushkey(event.key);
341+
}
342+
break;
343+
336344
default:
337345
handleEvent(event);
338346
break;
@@ -343,6 +351,7 @@ void Runtime::runShell() {
343351
logEntered();
344352
audio_open();
345353
net_init();
354+
chdir("/basic");
346355
while (1) {
347356
runMain(MAIN_BAS);
348357
}

0 commit comments

Comments
 (0)