From 650ee8fd97d0a7d8e9d7d39b4c929f33c10fe280 Mon Sep 17 00:00:00 2001 From: Sun <22406854+SunTheCourier@users.noreply.github.com> Date: Sun, 21 Apr 2019 22:21:05 -0700 Subject: [PATCH] Implement Auto Reboot Timer (#518) --- stratosphere/fatal/source/fatal_config.cpp | 5 +++++ stratosphere/fatal/source/fatal_config.hpp | 1 + stratosphere/fatal/source/fatal_task_power.cpp | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/stratosphere/fatal/source/fatal_config.cpp b/stratosphere/fatal/source/fatal_config.cpp index acd5b1346..0337bf0bb 100644 --- a/stratosphere/fatal/source/fatal_config.cpp +++ b/stratosphere/fatal/source/fatal_config.cpp @@ -84,5 +84,10 @@ void InitializeFatalConfig() { setsysGetFlag(SetSysFlag_Quest, &config->quest_flag); + if(R_FAILED(setsysGetSettingsItemValue("atmosphere", "fatal_auto_reboot_interval", &config->fatal_auto_reboot_interval, sizeof(config->fatal_auto_reboot_interval)))) { + config->fatal_auto_reboot_interval = -1; + } + + SetupConfigLanguages(); } diff --git a/stratosphere/fatal/source/fatal_config.hpp b/stratosphere/fatal/source/fatal_config.hpp index 12c495923..3cef93cf4 100644 --- a/stratosphere/fatal/source/fatal_config.hpp +++ b/stratosphere/fatal/source/fatal_config.hpp @@ -29,6 +29,7 @@ struct FatalConfig { const char *error_msg; const char *error_desc; const char *quest_desc; + s64 fatal_auto_reboot_interval; }; IEvent *GetFatalSettingsEvent(); diff --git a/stratosphere/fatal/source/fatal_task_power.cpp b/stratosphere/fatal/source/fatal_task_power.cpp index 07ac235d6..2b3e4fcb3 100644 --- a/stratosphere/fatal/source/fatal_task_power.cpp +++ b/stratosphere/fatal/source/fatal_task_power.cpp @@ -96,6 +96,12 @@ void PowerButtonObserveTask::WaitForPowerButton() { const FatalConfig *config = GetFatalConfig(); TimeoutHelper reboot_helper(config->quest_reboot_interval_second * 1000000000UL); + if (config->fatal_auto_reboot_interval != -1) { + svcSleepThread(config->fatal_auto_reboot_interval); + bpcRebootSystem(); + return; + } + 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))) {