Mercurial > repos > blastem
comparison nuklear_ui/blastem_nuklear.c @ 2600:251cc75574af
Basic emscripten support
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 13 Feb 2025 02:18:30 -0800 |
parents | 6f1eebc0a90b |
children | c768bbd912f1 |
comparison
equal
deleted
inserted
replaced
2599:ca8141c2d6ba | 2600:251cc75574af |
---|---|
2451 {"Load ROM", view_load}, | 2451 {"Load ROM", view_load}, |
2452 {"Lock On", view_lock_on}, | 2452 {"Lock On", view_lock_on}, |
2453 {"Save State", view_save_state}, | 2453 {"Save State", view_save_state}, |
2454 {"Load State", view_load_state}, | 2454 {"Load State", view_load_state}, |
2455 {"Settings", view_settings}, | 2455 {"Settings", view_settings}, |
2456 #ifndef __EMSCRIPTEN__ | |
2456 {"Exit", NULL} | 2457 {"Exit", NULL} |
2458 #endif | |
2457 }; | 2459 }; |
2458 static menu_item sc3k_items[] = { | 2460 static menu_item sc3k_items[] = { |
2459 {"Resume", view_play}, | 2461 {"Resume", view_play}, |
2460 {"Load ROM", view_load}, | 2462 {"Load ROM", view_load}, |
2461 {"Load Tape", view_load_tape}, | 2463 {"Load Tape", view_load_tape}, |
2462 {"Save State", view_save_state}, | 2464 {"Save State", view_save_state}, |
2463 {"Load State", view_load_state}, | 2465 {"Load State", view_load_state}, |
2464 {"Settings", view_settings}, | 2466 {"Settings", view_settings}, |
2467 #ifndef __EMSCRIPTEN__ | |
2465 {"Exit", NULL} | 2468 {"Exit", NULL} |
2469 #endif | |
2466 }; | 2470 }; |
2467 | 2471 |
2468 if (nk_begin(context, "Main Menu", nk_rect(0, 0, render_width(), render_height()), 0)) { | 2472 if (nk_begin(context, "Main Menu", nk_rect(0, 0, render_width(), render_height()), 0)) { |
2469 if (current_system->type == SYSTEM_SMS && ((sms_context *)current_system)->i8255) { | 2473 if (current_system->type == SYSTEM_SMS && ((sms_context *)current_system)->i8255) { |
2470 menu(context, sizeof(sc3k_items)/sizeof(*sc3k_items), sc3k_items, exit_handler); | 2474 menu(context, sizeof(sc3k_items)/sizeof(*sc3k_items), sc3k_items, exit_handler); |
2509 } else { | 2513 } else { |
2510 render_force_cursor(0); | 2514 render_force_cursor(0); |
2511 } | 2515 } |
2512 } | 2516 } |
2513 | 2517 |
2518 void ui_enter(void) | |
2519 { | |
2520 render_enable_gamepad_events(1); | |
2521 } | |
2522 | |
2523 void ui_exit(void) | |
2524 { | |
2525 if (config_dirty) { | |
2526 apply_updated_config(); | |
2527 persist_config(config); | |
2528 config_dirty = 0; | |
2529 } | |
2530 render_enable_gamepad_events(0); | |
2531 } | |
2532 | |
2514 void ui_idle_loop(void) | 2533 void ui_idle_loop(void) |
2515 { | 2534 { |
2516 render_enable_gamepad_events(1); | 2535 #ifndef __EMSCRIPTEN__ |
2536 ui_enter(); | |
2517 const uint32_t MIN_UI_DELAY = 15; | 2537 const uint32_t MIN_UI_DELAY = 15; |
2518 static uint32_t last; | 2538 static uint32_t last; |
2519 while (current_view != view_play) | 2539 while (current_view != view_play) |
2520 { | 2540 { |
2521 uint32_t current = render_elapsed_ms(); | 2541 uint32_t current = render_elapsed_ms(); |
2523 render_sleep_ms(MIN_UI_DELAY - (current - last) - 1); | 2543 render_sleep_ms(MIN_UI_DELAY - (current - last) - 1); |
2524 } | 2544 } |
2525 last = current; | 2545 last = current; |
2526 render_update_display(); | 2546 render_update_display(); |
2527 } | 2547 } |
2528 if (config_dirty) { | 2548 ui_exit(); |
2529 apply_updated_config(); | 2549 #endif |
2530 persist_config(config); | |
2531 config_dirty = 0; | |
2532 } | |
2533 render_enable_gamepad_events(0); | |
2534 } | 2550 } |
2535 static void handle_event(SDL_Event *event) | 2551 static void handle_event(SDL_Event *event) |
2536 { | 2552 { |
2537 if (event->type == SDL_KEYDOWN) { | 2553 if (event->type == SDL_KEYDOWN) { |
2538 keycode = event->key.keysym.sym; | 2554 keycode = event->key.keysym.sym; |