diff options
| author | 2026-08-26 17:56:52 -0400 | |
|---|---|---|
| committer | 2026-08-26 17:56:52 -0400 | |
| commit | 197d41a3e23cab35848f623c6133baccc62aacbe (patch) | |
| tree | 04943c1de9653de53615e10ced1eab07c2562325 /src/fruits/cmv/cmv.c | |
| parent | 6094c907b26e21f13373bae6bf3306dbae40af3c (diff) | |
| download | camu-197d41a3e23cab35848f623c6133baccc62aacbe.tar.gz camu-197d41a3e23cab35848f623c6133baccc62aacbe.tar.bz2 camu-197d41a3e23cab35848f623c6133baccc62aacbe.zip | |
OSD stuff and Android fixes
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/fruits/cmv/cmv.c')
| -rw-r--r-- | src/fruits/cmv/cmv.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/fruits/cmv/cmv.c b/src/fruits/cmv/cmv.c index 58c8e32..74e3555 100644 --- a/src/fruits/cmv/cmv.c +++ b/src/fruits/cmv/cmv.c @@ -53,6 +53,10 @@ static nn_thread_result NNWT_THREADCALL event_loop_thread(void *userdata) static bool decode_addr(str *addr, str *enc) { + if (al_str_find(enc, '.') != AL_STR_NO_POS) { + al_str_clone(addr, enc); + return true; + } char value[4]; // max = 255. for (u32 i = 0; i < 8; i += 2) { str sub = al_str_substr(enc, i, i + 2); @@ -75,40 +79,39 @@ static bool parse_exe_name(str *exe_name, str *addr) u32 index = al_str_rfind(exe_name, '/'); if (index == AL_STR_NO_POS) { if ((index = al_str_rfind(exe_name, '\\')) == AL_STR_NO_POS) { - goto def; + return false; } } str sub = al_str_substr(exe_name, index + 1, exe_name->length); if (al_str_cmp(&sub, &al_str_c("sink-"), 0, 5) != 0) { - goto def; + return false; } sub = al_str_substr(&sub, 5, sub.length); // Skip version. if ((index = al_str_find(&sub, '-')) == AL_STR_NO_POS) { - goto def; + return false; } sub = al_str_substr(&sub, index + 1, sub.length); if ((index = al_str_find(&sub, '.')) != AL_STR_NO_POS) { sub = al_str_substr(&sub, 0, index); } - al_str_from(addr, ""); decode_addr(addr, &sub); log_debug("Parsed address %.*s from exe filename.", al_str_x(addr)); return true; -def: - return false; } static struct cmv c = { 0 }; +#ifdef STELA_USE_PLATFORM_MAIN +s32 stl_platform_main(u32 argc, str *argv, void *extra) +#else s32 window_system_main(u32 argc, str *argv, void *extra) +#endif { - (void)extra; - bool local; #ifdef CAMU_SINK_ONLY local = argc > 1; @@ -134,9 +137,9 @@ s32 window_system_main(u32 argc, str *argv, void *extra) nn_event_loop_init(&c.loop); u8 type; - str addr = al_str_null(); + str addr = AL_STR_EMPTY; if (local) { -#ifdef NAUNET_ON_WINDOWS +#if defined NAUNET_ON_WINDOWS || defined NAUNET_ON_ANDROID type = NNWT_SOCKET_TCP; al_str_clone(&addr, &al_str_c("127.0.0.1")); #else @@ -151,8 +154,8 @@ s32 window_system_main(u32 argc, str *argv, void *extra) } else { type = NNWT_SOCKET_TCP; char *SINK_IP = getenv("SINK_IP"); - al_str_from(&addr, ""); if (!SINK_IP || !decode_addr(&addr, &al_str_cr(SINK_IP))) { + local = true; // If no IP, default back to local. al_str_cat(&addr, &al_str_c("127.0.0.1")); } } @@ -228,11 +231,22 @@ s32 window_system_main(u32 argc, str *argv, void *extra) #endif nn_packet_free(packet); } + if (extra) { + u32 start_index = *(u32 *)extra; + if (start_index != 0) { + camu_server_local_set_index(&c.server, start_index); + } + } } struct nn_thread thread; nn_thread_create(&thread, event_loop_thread, &c); +#ifdef STELA_USE_PLATFORM_MAIN + al_str_free(&addr); + return 0; +#endif + while (camu_desktop_tick(&c.desktop)) {} camu_desktop_stop(&c.desktop); @@ -251,6 +265,7 @@ out: return ret; } +#ifndef STELA_USE_PLATFORM_MAIN static bool sigint_force = false; static void sigint_handler(s32 signum) { @@ -314,3 +329,4 @@ s32 main(s32 argc, char *argv[]) return ret; } +#endif |