From a6d7fa7fe11de2844b395833112e8a7b0f5e1c06 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sat, 11 Feb 2023 23:59:30 +0200 Subject: [PATCH] nyx: disable reboot to OFW button if autorcm --- nyx/nyx_gui/config.c | 1 + nyx/nyx_gui/config.h | 1 + nyx/nyx_gui/frontend/gui.c | 8 ++++++-- nyx/nyx_gui/frontend/gui_emmc_tools.c | 2 +- nyx/nyx_gui/frontend/gui_tools.c | 8 +++++--- nyx/nyx_gui/frontend/gui_tools.h | 2 +- nyx/nyx_gui/nyx.c | 2 +- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/nyx/nyx_gui/config.c b/nyx/nyx_gui/config.c index 28ae5a6..3fae913 100644 --- a/nyx/nyx_gui/config.c +++ b/nyx/nyx_gui/config.c @@ -42,6 +42,7 @@ void set_default_configuration() h_cfg.errors = 0; h_cfg.eks = NULL; h_cfg.rcm_patched = fuse_check_patched_rcm(); + h_cfg.autorcm_enabled = false; h_cfg.emummc_force_disable = false; sd_power_cycle_time_start = 0; diff --git a/nyx/nyx_gui/config.h b/nyx/nyx_gui/config.h index b8fd85d..47d3e75 100644 --- a/nyx/nyx_gui/config.h +++ b/nyx/nyx_gui/config.h @@ -37,6 +37,7 @@ typedef struct _hekate_config bool t210b01; bool emummc_force_disable; bool rcm_patched; + bool autorcm_enabled; u32 errors; hos_eks_mbr_t *eks; } hekate_config; diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index 10aba0c..4d0119a 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022 CTCaer + * Copyright (c) 2018-2023 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -1101,6 +1101,7 @@ static lv_res_t _create_mbox_reboot(lv_obj_t *btn) lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES); static const char * mbox_btn_map[] = { "\221OFW", "\221RCM", "\221Cancel", "" }; + static const char * mbox_btn_map_autorcm[] = { "\261OFW", "\221RCM", "\221Cancel", "" }; static const char * mbox_btn_map_patched[] = { "\221OFW", "\221Normal", "\221Cancel", "" }; lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL); lv_mbox_set_recolor_text(mbox, true); @@ -1108,7 +1109,10 @@ static lv_res_t _create_mbox_reboot(lv_obj_t *btn) lv_mbox_set_text(mbox, "#FF8000 Choose where to reboot:#"); - lv_mbox_add_btns(mbox, h_cfg.rcm_patched ? mbox_btn_map_patched : mbox_btn_map, _reboot_action); + if (h_cfg.rcm_patched) + lv_mbox_add_btns(mbox, mbox_btn_map_patched, _reboot_action); + else + lv_mbox_add_btns(mbox, !h_cfg.autorcm_enabled ? mbox_btn_map : mbox_btn_map_autorcm, _reboot_action); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); diff --git a/nyx/nyx_gui/frontend/gui_emmc_tools.c b/nyx/nyx_gui/frontend/gui_emmc_tools.c index 1720b6b..9a4df69 100644 --- a/nyx/nyx_gui/frontend/gui_emmc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emmc_tools.c @@ -155,7 +155,7 @@ static void _create_window_backup_restore(emmcPartType_t type, const char* win_l // Refresh AutoRCM button. if (emmc_btn_ctxt.restore && (type == PART_BOOT) && !emmc_btn_ctxt.raw_emummc) { - if (get_autorcm_status(false)) + if (get_set_autorcm_status(false)) lv_btn_set_state(autorcm_btn, LV_BTN_STATE_TGL_REL); else lv_btn_set_state(autorcm_btn, LV_BTN_STATE_REL); diff --git a/nyx/nyx_gui/frontend/gui_tools.c b/nyx/nyx_gui/frontend/gui_tools.c index 5ce9304..5273936 100644 --- a/nyx/nyx_gui/frontend/gui_tools.c +++ b/nyx/nyx_gui/frontend/gui_tools.c @@ -56,7 +56,7 @@ static lv_obj_t *_create_container(lv_obj_t *parent) return h1; } -bool get_autorcm_status(bool toggle) +bool get_set_autorcm_status(bool toggle) { u32 sector; u8 corr_mod0, mod1; @@ -128,6 +128,8 @@ out: free(tempbuf); emmc_end(); + h_cfg.autorcm_enabled = enabled; + return enabled; } @@ -141,7 +143,7 @@ static lv_res_t _create_mbox_autorcm_status(lv_obj_t *btn) lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL); lv_mbox_set_recolor_text(mbox, true); - bool enabled = get_autorcm_status(true); + bool enabled = get_set_autorcm_status(true); if (enabled) { @@ -1660,7 +1662,7 @@ static void _create_tab_tools_arc_autorcm(lv_theme_t *th, lv_obj_t *parent) lv_btn_set_action(btn3, LV_BTN_ACTION_CLICK, _create_mbox_autorcm_status); // Set default state for AutoRCM and lock it out if patched unit. - if (get_autorcm_status(false)) + if (get_set_autorcm_status(false)) lv_btn_set_state(btn3, LV_BTN_STATE_TGL_REL); else lv_btn_set_state(btn3, LV_BTN_STATE_REL); diff --git a/nyx/nyx_gui/frontend/gui_tools.h b/nyx/nyx_gui/frontend/gui_tools.h index c841708..ae4bbf1 100644 --- a/nyx/nyx_gui/frontend/gui_tools.h +++ b/nyx/nyx_gui/frontend/gui_tools.h @@ -23,7 +23,7 @@ extern lv_obj_t *ums_mbox; void create_tab_tools(lv_theme_t *th, lv_obj_t *parent); void nyx_run_ums(void *param); -bool get_autorcm_status(bool change); +bool get_set_autorcm_status(bool change); lv_res_t action_ums_sd(lv_obj_t *btn); #endif diff --git a/nyx/nyx_gui/nyx.c b/nyx/nyx_gui/nyx.c index 0fe3ced..58f0c93 100644 --- a/nyx/nyx_gui/nyx.c +++ b/nyx/nyx_gui/nyx.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2018 naehrwert * - * Copyright (c) 2018-2022 CTCaer + * Copyright (c) 2018-2023 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License,