diff --git a/common/defaults/system_settings.ini b/common/defaults/system_settings.ini index 075c0d454..07bb5e9e7 100644 --- a/common/defaults/system_settings.ini +++ b/common/defaults/system_settings.ini @@ -6,6 +6,9 @@ upload_enabled = u8!0x0 usb30_force_enabled = u8!0x0 ; Atmosphere custom settings [atmosphere] +; Reboot from fatal automatically after 5 seconds (in milliseconds) +; If field is disabled fatal waits for an input indefinitely +; fatal_auto_reboot_interval = u64!‪5000‬ ; 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 diff --git a/stratosphere/fatal/source/fatal_config.cpp b/stratosphere/fatal/source/fatal_config.cpp index acd5b1346..0bd7b2930 100644 --- a/stratosphere/fatal/source/fatal_config.cpp +++ b/stratosphere/fatal/source/fatal_config.cpp @@ -18,7 +18,7 @@ #include "fatal_types.hpp" #include "fatal_config.hpp" -static FatalConfig g_fatal_config; +static FatalConfig g_fatal_config = {}; static IEvent *g_fatal_settings_event = nullptr; @@ -84,5 +84,8 @@ void InitializeFatalConfig() { setsysGetFlag(SetSysFlag_Quest, &config->quest_flag); + config->is_auto_reboot_enabled = R_SUCCEEDED(setsysGetSettingsItemValue("atmosphere", "fatal_auto_reboot_interval", &config->fatal_auto_reboot_interval, sizeof(config->fatal_auto_reboot_interval))); + config->is_auto_reboot_enabled &= (config->fatal_auto_reboot_interval != 0); + SetupConfigLanguages(); } diff --git a/stratosphere/fatal/source/fatal_config.hpp b/stratosphere/fatal/source/fatal_config.hpp index 12c495923..6e4c1db7c 100644 --- a/stratosphere/fatal/source/fatal_config.hpp +++ b/stratosphere/fatal/source/fatal_config.hpp @@ -29,6 +29,8 @@ struct FatalConfig { const char *error_msg; const char *error_desc; const char *quest_desc; + u64 fatal_auto_reboot_interval; + bool is_auto_reboot_enabled; }; IEvent *GetFatalSettingsEvent(); diff --git a/stratosphere/fatal/source/fatal_task_power.cpp b/stratosphere/fatal/source/fatal_task_power.cpp index 07ac235d6..4f9117804 100644 --- a/stratosphere/fatal/source/fatal_task_power.cpp +++ b/stratosphere/fatal/source/fatal_task_power.cpp @@ -96,6 +96,8 @@ void PowerButtonObserveTask::WaitForPowerButton() { const FatalConfig *config = GetFatalConfig(); TimeoutHelper reboot_helper(config->quest_reboot_interval_second * 1000000000UL); + TimeoutHelper auto_reboot_helper(config->fatal_auto_reboot_interval * 1000000); + bool check_vol_up = true, check_vol_down = true; GpioPadSession vol_up_btn, vol_down_btn; if (R_FAILED(gpioOpenSession(&vol_up_btn, GpioPadName_ButtonVolUp))) { @@ -121,6 +123,11 @@ void PowerButtonObserveTask::WaitForPowerButton() { GpioValue val; while (true) { Result rc = ResultSuccess; + + if (config->is_auto_reboot_enabled && auto_reboot_helper.TimedOut() ) { + bpcRebootSystem(); + return; + } if (check_vol_up && R_SUCCEEDED((rc = gpioPadGetValue(&vol_up_btn, &val))) && val == GpioValue_Low) { bpcRebootSystem();