Use TimeoutHelper and accept MS

This commit is contained in:
Sun 2019-04-21 23:26:34 -07:00
parent 88fbd9a3c1
commit a76eee0e34
3 changed files with 12 additions and 13 deletions

View File

@ -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();
}

View File

@ -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();

View File

@ -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();