diff --git a/common/defaults/system_settings.ini b/common/defaults/system_settings.ini index 9a10dcd7c..91c7f7cfb 100644 --- a/common/defaults/system_settings.ini +++ b/common/defaults/system_settings.ini @@ -3,4 +3,9 @@ upload_enabled = u8!0x0 ; Enable USB 3.0 superspeed for homebrew [usb] -usb30_force_enabled = u8!0x1 \ No newline at end of file +usb30_force_enabled = u8!0x1 +; Atmosphere custom settings +[atmosphere] +; Make the power menu's "reboot" button reboot to payload. +; Set to "normal" for normal reboot, "rcm" for rcm reboot. +power_menu_reboot_function = str!payload \ No newline at end of file diff --git a/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_reboot_manager.cpp b/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_reboot_manager.cpp index 12c52def9..248f2964e 100644 --- a/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_reboot_manager.cpp +++ b/stratosphere/ams_mitm/source/bpc_mitm/bpcmitm_reboot_manager.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include "bpcmitm_reboot_manager.hpp" #include "../utils.hpp" @@ -43,7 +43,20 @@ void BpcRebootManager::Initialize() { g_payload_loaded = true; - /* TODO: Figure out what kind of reboot we're gonna be doing. */ + /* Figure out what kind of reboot we're gonna be doing. */ + { + char reboot_type[0x40] = {0}; + u64 reboot_type_size = 0; + if (R_SUCCEEDED(Utils::GetSettingsItemValue("atmosphere", "power_menu_reboot_function", reboot_type, sizeof(reboot_type)-1, &reboot_type_size))) { + if (strcasecmp(reboot_type, "stock") == 0 || strcasecmp(reboot_type, "normal") == 0 || strcasecmp(reboot_type, "standard") == 0) { + g_reboot_type = BpcRebootType::Standard; + } else if (strcasecmp(reboot_type, "rcm") == 0) { + g_reboot_type = BpcRebootType::ToRcm; + } else if (strcasecmp(reboot_type, "payload") == 0) { + g_reboot_type = BpcRebootType::ToPayload; + } + } + } } static void ClearIram() { diff --git a/stratosphere/ams_mitm/source/set_mitm/setmitm_main.cpp b/stratosphere/ams_mitm/source/set_mitm/setmitm_main.cpp index b2ca562f9..f694588ae 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setmitm_main.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/setmitm_main.cpp @@ -40,10 +40,7 @@ using SetMitmManager = WaitableManager; void SetMitmMain(void *arg) { /* Wait for SD to initialize. */ Utils::WaitSdInitialized(); - - /* Load settings */ - SettingsItemManager::LoadConfiguration(); - + /* Create server manager */ auto server_manager = new SetMitmManager(3); diff --git a/stratosphere/ams_mitm/source/utils.cpp b/stratosphere/ams_mitm/source/utils.cpp index 8f3947d9e..81c5db99b 100644 --- a/stratosphere/ams_mitm/source/utils.cpp +++ b/stratosphere/ams_mitm/source/utils.cpp @@ -25,6 +25,8 @@ #include "ini.h" #include "sha256.h" +#include "set_mitm/setsys_settings_items.hpp" + static FsFileSystem g_sd_filesystem = {0}; static HosSignal g_sd_signal; @@ -187,6 +189,11 @@ void Utils::InitializeThreadFunc(void *args) { /* Signal SD is initialized. */ g_has_initialized = true; + + /* Load custom settings configuration. */ + SettingsItemManager::LoadConfiguration(); + + /* Signal to waiters that we are ready. */ g_sd_signal.Signal(); /* Initialize HID. */ @@ -541,4 +548,12 @@ void Utils::RefreshConfiguration() { fsFileClose(&config_file); ini_parse_string(g_config_ini_data, FsMitMIniHandler, NULL); -} \ No newline at end of file +} + +Result Utils::GetSettingsItemValueSize(const char *name, const char *key, u64 *out_size) { + return SettingsItemManager::GetValueSize(name, key, out_size); +} + +Result Utils::GetSettingsItemValue(const char *name, const char *key, void *out, size_t max_size, u64 *out_size) { + return SettingsItemManager::GetValue(name, key, out, max_size, out_size); +} diff --git a/stratosphere/ams_mitm/source/utils.hpp b/stratosphere/ams_mitm/source/utils.hpp index e929bb10a..2c15ec13e 100644 --- a/stratosphere/ams_mitm/source/utils.hpp +++ b/stratosphere/ams_mitm/source/utils.hpp @@ -73,6 +73,10 @@ class Utils { static bool IsHidAvailable(); static Result GetKeysDown(u64 *keys); static bool HasOverrideButton(u64 tid); + + /* Settings! */ + static Result GetSettingsItemValueSize(const char *name, const char *key, u64 *out_size); + static Result GetSettingsItemValue(const char *name, const char *key, void *out, size_t max_size, u64 *out_size); private: static void RefreshConfiguration(); }; \ No newline at end of file