From a76eee0e3452986d48c12b24d68c2bc3ce88a334 Mon Sep 17 00:00:00 2001 From: Sun <22406854+SunTheCourier@users.noreply.github.com> Date: Sun, 21 Apr 2019 23:26:34 -0700 Subject: [PATCH] Use TimeoutHelper and accept MS --- stratosphere/fatal/source/fatal_config.cpp | 9 +++------ stratosphere/fatal/source/fatal_config.hpp | 3 ++- stratosphere/fatal/source/fatal_task_power.cpp | 13 +++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/stratosphere/fatal/source/fatal_config.cpp b/stratosphere/fatal/source/fatal_config.cpp index 0337bf0bb..62d684b79 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,10 +84,7 @@ 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; - } - - + config->is_auto_reboot_enabled = R_SUCCEEDED(setsysGetSettingsItemValue("atmosphere", "fatal_auto_reboot_interval", &config->fatal_auto_reboot_interval, sizeof(config->fatal_auto_reboot_interval))); + SetupConfigLanguages(); } diff --git a/stratosphere/fatal/source/fatal_config.hpp b/stratosphere/fatal/source/fatal_config.hpp index 3cef93cf4..6e4c1db7c 100644 --- a/stratosphere/fatal/source/fatal_config.hpp +++ b/stratosphere/fatal/source/fatal_config.hpp @@ -29,7 +29,8 @@ struct FatalConfig { const char *error_msg; const char *error_desc; const char *quest_desc; - s64 fatal_auto_reboot_interval; + 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 7608ee2ea..4f9117804 100644 --- a/stratosphere/fatal/source/fatal_task_power.cpp +++ b/stratosphere/fatal/source/fatal_task_power.cpp @@ -96,12 +96,8 @@ 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; - } - + 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))) { @@ -127,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();