Nyx: emuMMC Manage window, Tools UI, and misc updates
- Add gui_emu_tools: emuMMC Manage window with correct positioning (LV_PROTECT_PARENT + re-parent to win) - Tools: single SD button (tap = SD partition manager, 3s hold = eMMC) - Remove emuSD from Nyx UI (tabs, UMS, partition manager); keep bootloader emusd - Shorten Create emuMMC description text by one character - Storage/build/config and dependency updates Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <bdk.h>
|
||||
|
||||
#include "gui.h"
|
||||
#include "gui_emu_tools.h"
|
||||
#include "gui_emummc_tools.h"
|
||||
#include "gui_tools.h"
|
||||
#include "gui_info.h"
|
||||
@@ -29,6 +30,7 @@
|
||||
|
||||
#include "../config.h"
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include <storage/boot_storage.h>
|
||||
|
||||
extern volatile boot_cfg_t *b_cfg;
|
||||
extern volatile nyx_storage_t *nyx_str;
|
||||
@@ -36,7 +38,7 @@ extern volatile nyx_storage_t *nyx_str;
|
||||
extern lv_res_t launch_payload(lv_obj_t *list);
|
||||
|
||||
static bool disp_init_done = false;
|
||||
static bool do_auto_reload = false;
|
||||
static bool do_reload = false;
|
||||
|
||||
lv_style_t hint_small_style;
|
||||
lv_style_t hint_small_style_white;
|
||||
@@ -187,7 +189,7 @@ static void _save_log_to_bmp(char *fname)
|
||||
char path[0x80];
|
||||
strcpy(path, "bootloader/screenshots");
|
||||
s_printf(path + strlen(path), "/nyx%s_log.bmp", fname);
|
||||
sd_save_to_file(bitmap, file_size, path);
|
||||
boot_storage_save_to_file(bitmap, file_size, path);
|
||||
|
||||
free(bitmap);
|
||||
free(fb);
|
||||
@@ -200,8 +202,8 @@ static void _save_fb_to_bmp()
|
||||
if (get_tmr_ms() < timer)
|
||||
return;
|
||||
|
||||
if (do_auto_reload)
|
||||
goto exit;
|
||||
if (do_reload)
|
||||
return;
|
||||
|
||||
// Invalidate data.
|
||||
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
|
||||
@@ -271,7 +273,7 @@ static void _save_fb_to_bmp()
|
||||
bmp->res_v = 2834;
|
||||
bmp->rsvd2 = 0;
|
||||
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
|
||||
char path[0x80];
|
||||
|
||||
@@ -288,7 +290,7 @@ static void _save_fb_to_bmp()
|
||||
s_printf(path + strlen(path), "/nyx%s.bmp", fname);
|
||||
|
||||
// Save screenshot and log.
|
||||
int res = sd_save_to_file(bitmap, file_size, path);
|
||||
int res = boot_storage_save_to_file(bitmap, file_size, path);
|
||||
if (!res)
|
||||
_save_log_to_bmp(fname);
|
||||
|
||||
@@ -304,7 +306,6 @@ static void _save_fb_to_bmp()
|
||||
manual_system_maintenance(true);
|
||||
lv_mbox_start_auto_close(mbox, 4000);
|
||||
|
||||
exit:
|
||||
// Set timer to 2s.
|
||||
timer = get_tmr_ms() + 2000;
|
||||
}
|
||||
@@ -664,7 +665,7 @@ void manual_system_maintenance(bool refresh)
|
||||
lv_img_dsc_t *bmp_to_lvimg_obj(const char *path)
|
||||
{
|
||||
u32 fsize;
|
||||
u8 *bitmap = sd_file_read(path, &fsize);
|
||||
u8 *bitmap = boot_storage_file_read(path, &fsize);
|
||||
if (!bitmap)
|
||||
return NULL;
|
||||
|
||||
@@ -794,7 +795,7 @@ lv_res_t mbox_action(lv_obj_t *btns, const char *txt)
|
||||
|
||||
bool nyx_emmc_check_battery_enough()
|
||||
{
|
||||
if (h_cfg.devmode)
|
||||
if (fuse_read_hw_state() == FUSE_NX_HW_STATE_DEV)
|
||||
return true;
|
||||
|
||||
int batt_volt = 0;
|
||||
@@ -934,34 +935,17 @@ static void _launch_hos(u8 autoboot, u8 autoboot_list)
|
||||
|
||||
void (*main_ptr)() = (void *)nyx_str->hekate;
|
||||
|
||||
boot_storage_end();
|
||||
sd_end();
|
||||
emmc_end();
|
||||
|
||||
hw_deinit(false);
|
||||
|
||||
(*main_ptr)();
|
||||
}
|
||||
|
||||
void reload_nyx(lv_obj_t *obj, bool force)
|
||||
void reload_nyx()
|
||||
{
|
||||
if (!force)
|
||||
{
|
||||
sd_mount();
|
||||
|
||||
// Check that Nyx still exists.
|
||||
if (f_stat("bootloader/sys/nyx.bin", NULL))
|
||||
{
|
||||
sd_unmount();
|
||||
|
||||
// Remove lvgl object in case of being invoked from a window.
|
||||
if (obj)
|
||||
lv_obj_del(obj);
|
||||
|
||||
do_auto_reload = false;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
b_cfg->boot_cfg = BOOT_CFG_AUTOBOOT_EN;
|
||||
b_cfg->autoboot = 0;
|
||||
b_cfg->autoboot_list = 0;
|
||||
@@ -969,6 +953,9 @@ void reload_nyx(lv_obj_t *obj, bool force)
|
||||
|
||||
void (*main_ptr)() = (void *)nyx_str->hekate;
|
||||
|
||||
// TODO:
|
||||
boot_storage_end();
|
||||
emmc_end();
|
||||
sd_end();
|
||||
|
||||
hw_deinit(false);
|
||||
@@ -979,7 +966,7 @@ void reload_nyx(lv_obj_t *obj, bool force)
|
||||
static lv_res_t reload_action(lv_obj_t *btns, const char *txt)
|
||||
{
|
||||
if (!lv_btnm_get_pressed(btns))
|
||||
reload_nyx(NULL, false);
|
||||
reload_nyx();
|
||||
|
||||
return mbox_action(btns, txt);
|
||||
}
|
||||
@@ -1001,7 +988,7 @@ static lv_res_t _removed_sd_action(lv_obj_t *btns, const char *txt)
|
||||
break;
|
||||
case 2:
|
||||
sd_end();
|
||||
do_auto_reload = false;
|
||||
do_reload = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1010,14 +997,12 @@ static lv_res_t _removed_sd_action(lv_obj_t *btns, const char *txt)
|
||||
|
||||
static void _check_sd_card_removed(void *params)
|
||||
{
|
||||
static lv_obj_t *dark_bg = NULL;
|
||||
|
||||
// The following checks if SDMMC_1 is initialized.
|
||||
// If yes and card was removed, shows a message box,
|
||||
// that will reload Nyx, when the card is inserted again.
|
||||
if (!do_auto_reload && sd_get_card_removed())
|
||||
if (!do_reload && sd_get_card_removed() && boot_storage_get_drive() == DRIVE_SD)
|
||||
{
|
||||
dark_bg = lv_obj_create(lv_scr_act(), NULL);
|
||||
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_style(dark_bg, &mbox_darken);
|
||||
lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES);
|
||||
|
||||
@@ -1033,12 +1018,12 @@ static void _check_sd_card_removed(void *params)
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_top(mbox, true);
|
||||
|
||||
do_auto_reload = true;
|
||||
do_reload = true;
|
||||
}
|
||||
|
||||
// If in reload state and card was inserted, reload nyx.
|
||||
if (do_auto_reload && !sd_get_card_removed())
|
||||
reload_nyx(dark_bg, false);
|
||||
if (do_reload && !sd_get_card_removed() && boot_storage_get_drive() == DRIVE_SD)
|
||||
reload_nyx();
|
||||
}
|
||||
|
||||
lv_task_t *task_emmc_errors;
|
||||
@@ -1472,14 +1457,15 @@ static lv_res_t _create_mbox_payloads(lv_obj_t *btn)
|
||||
lv_obj_set_size(list, LV_HOR_RES * 3 / 7, LV_VER_RES * 3 / 7);
|
||||
lv_list_set_single_mode(list, true);
|
||||
|
||||
if (!sd_mount())
|
||||
if (!boot_storage_mount())
|
||||
{
|
||||
// TODO: may not be SD, change error
|
||||
lv_mbox_set_text(mbox, "#FFDD00 Failed to init SD!#");
|
||||
|
||||
goto out_end;
|
||||
}
|
||||
|
||||
dirlist_t *filelist = dirlist("bootloader/payloads", NULL, 0);
|
||||
dirlist_t *filelist = dirlist("bootloader/payloads", NULL, false, false);
|
||||
sd_unmount();
|
||||
|
||||
u32 i = 0;
|
||||
@@ -1784,7 +1770,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
|
||||
u32 curr_btn_idx = 0; // Active buttons.
|
||||
LIST_INIT(ini_sections);
|
||||
|
||||
if (!sd_mount())
|
||||
if (!boot_storage_mount())
|
||||
goto failed_sd_mount;
|
||||
|
||||
// Check if we use custom system icons.
|
||||
@@ -1980,7 +1966,7 @@ failed_sd_mount:
|
||||
if (curr_btn_idx < 1)
|
||||
no_boot_entries = true;
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
free(tmp_path);
|
||||
|
||||
@@ -2147,7 +2133,7 @@ static void _create_tab_home(lv_theme_t *th, lv_obj_t *parent)
|
||||
label_btn = lv_label_create(btn_emummc, label_btn);
|
||||
s_printf(btn_colored_text, "%s%s", text_color, " "SYMBOL_LIST"#");
|
||||
lv_label_set_text(label_btn, btn_colored_text);
|
||||
lv_btn_set_action(btn_emummc, LV_BTN_ACTION_CLICK, create_win_emummc_tools);
|
||||
lv_btn_set_action(btn_emummc, LV_BTN_ACTION_CLICK, create_win_emu_tools);
|
||||
lv_btn_set_layout(btn_emummc, LV_LAYOUT_OFF);
|
||||
lv_obj_align(label_btn, NULL, LV_ALIGN_CENTER, 0, -28);
|
||||
lv_obj_set_pos(btn_emummc, 959, 160);
|
||||
@@ -2179,7 +2165,7 @@ static lv_res_t _save_options_action(lv_obj_t *btn)
|
||||
|
||||
int res = 0;
|
||||
|
||||
if (sd_mount())
|
||||
if (boot_storage_mount())
|
||||
res = !create_config_entry();
|
||||
|
||||
if (res)
|
||||
@@ -2191,7 +2177,7 @@ static lv_res_t _save_options_action(lv_obj_t *btn)
|
||||
|
||||
nyx_options_clear_ini_changes_made();
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user