Enable the volume controller dialog on Emscripten

Export volume_dialog_open() so the web shell can open it, and add
modal_run to ASYNCIFY_ADD since it drives an async loop.
This commit is contained in:
kichikuou
2026-07-01 17:21:49 +09:00
parent 602c55a5e5
commit a1e063c4b2
5 changed files with 12 additions and 16 deletions
+4 -6
View File
@@ -73,8 +73,10 @@ target_sources(xsystem35 PRIVATE
jpeg.c
menu.c
message.c
microui/microui.c
midi.c
mmap.c
modal.c
msgskip.c
mt19937-1.c
music.c
@@ -93,6 +95,7 @@ target_sources(xsystem35 PRIVATE
system.c
texthook.c
variable.c
volume.c
vsp.c
xsystem35.c
)
@@ -120,11 +123,6 @@ else()
endif()
endif()
if (NOT EMSCRIPTEN)
target_sources(xsystem35 PRIVATE
modal.c microui/microui.c volume.c)
endif()
if (HAVE_WEBP)
target_sources(xsystem35 PRIVATE webp.c)
target_link_libraries(xsystem35 PRIVATE WebP)
@@ -167,7 +165,7 @@ if (EMSCRIPTEN)
# Functions that call an asynchronous function via a function pointer must
# be added to ASYNCIFY_ADD, even if it had a direct call to another
# asynchronous function, so that the indirect call itself is instrumented.
-sASYNCIFY_ADD=commands2F60,nact_main,send_agsevent,cb_waitkey_sprite
-sASYNCIFY_ADD=commands2F60,nact_main,send_agsevent,cb_waitkey_sprite,modal_run
-sALLOW_MEMORY_GROWTH=1
-sNO_EXIT_RUNTIME=1
-sEXPORTED_FUNCTIONS=_main,_malloc
-4
View File
@@ -41,10 +41,6 @@ void menu_init(void) {
return;
}
void menu_render_overlay(void) {
return;
}
EM_JS(void, menu_setSkipState, (bool enabled, bool activated), {
xsystem35.shell.setSkipButtonState(enabled, activated);
});
+4
View File
@@ -24,6 +24,9 @@
#include <stdlib.h>
#include <string.h>
#include <SDL.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
#include "event.h"
#include "font.h"
@@ -290,6 +293,7 @@ static bool modal_event_trampoline(const SDL_Event *e) {
return current_modal->handler(e, current_modal);
}
EMSCRIPTEN_KEEPALIVE // Prevent inlining, because this function is listed in ASYNCIFY_ADD
void modal_run(modal *m) {
assert(!ctx); // modals are not nestable
ctx = calloc(1, sizeof(*ctx));
+4
View File
@@ -24,6 +24,9 @@
#include <stdio.h>
#include <string.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
#include "portab.h"
#include "system.h"
#include "nact.h"
@@ -215,6 +218,7 @@ static bool volume_build(mu_Context *ctx, modal *modal) {
return keep_open;
}
EMSCRIPTEN_KEEPALIVE
void volume_dialog_open(void) {
struct volume_state st = {
.base = { .build = volume_build, .handler = modal_default_handler },
-6
View File
@@ -40,10 +40,6 @@
#include <emscripten.h>
#endif
#ifndef __EMSCRIPTEN__
#define HAVE_VOLUME_VALANCER 1
#endif
#include "nact.h"
#include "debugger.h"
#include "portab.h"
@@ -503,9 +499,7 @@ int main(int argc, char **argv) {
if (integer_scaling)
gfx_setIntegerScaling(true);
#ifdef HAVE_VOLUME_VALANCER
volume_init();
#endif
menu_init();
if (debugger_mode != DEBUGGER_DISABLED) {