mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-07-06 09:32:17 +02:00
Use TimeoutHelper and accept MS
This commit is contained in:
parent
88fbd9a3c1
commit
a76eee0e34
@ -18,7 +18,7 @@
|
|||||||
#include "fatal_types.hpp"
|
#include "fatal_types.hpp"
|
||||||
#include "fatal_config.hpp"
|
#include "fatal_config.hpp"
|
||||||
|
|
||||||
static FatalConfig g_fatal_config;
|
static FatalConfig g_fatal_config = {};
|
||||||
|
|
||||||
static IEvent *g_fatal_settings_event = nullptr;
|
static IEvent *g_fatal_settings_event = nullptr;
|
||||||
|
|
||||||
@ -84,10 +84,7 @@ void InitializeFatalConfig() {
|
|||||||
|
|
||||||
setsysGetFlag(SetSysFlag_Quest, &config->quest_flag);
|
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->is_auto_reboot_enabled = R_SUCCEEDED(setsysGetSettingsItemValue("atmosphere", "fatal_auto_reboot_interval", &config->fatal_auto_reboot_interval, sizeof(config->fatal_auto_reboot_interval)));
|
||||||
config->fatal_auto_reboot_interval = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SetupConfigLanguages();
|
SetupConfigLanguages();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,8 @@ struct FatalConfig {
|
|||||||
const char *error_msg;
|
const char *error_msg;
|
||||||
const char *error_desc;
|
const char *error_desc;
|
||||||
const char *quest_desc;
|
const char *quest_desc;
|
||||||
s64 fatal_auto_reboot_interval;
|
u64 fatal_auto_reboot_interval;
|
||||||
|
bool is_auto_reboot_enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
IEvent *GetFatalSettingsEvent();
|
IEvent *GetFatalSettingsEvent();
|
||||||
|
@ -96,11 +96,7 @@ void PowerButtonObserveTask::WaitForPowerButton() {
|
|||||||
const FatalConfig *config = GetFatalConfig();
|
const FatalConfig *config = GetFatalConfig();
|
||||||
TimeoutHelper reboot_helper(config->quest_reboot_interval_second * 1000000000UL);
|
TimeoutHelper reboot_helper(config->quest_reboot_interval_second * 1000000000UL);
|
||||||
|
|
||||||
if (config->fatal_auto_reboot_interval > -1) {
|
TimeoutHelper auto_reboot_helper(config->fatal_auto_reboot_interval * 1000000);
|
||||||
svcSleepThread(config->fatal_auto_reboot_interval);
|
|
||||||
bpcRebootSystem();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool check_vol_up = true, check_vol_down = true;
|
bool check_vol_up = true, check_vol_down = true;
|
||||||
GpioPadSession vol_up_btn, vol_down_btn;
|
GpioPadSession vol_up_btn, vol_down_btn;
|
||||||
@ -128,6 +124,11 @@ void PowerButtonObserveTask::WaitForPowerButton() {
|
|||||||
while (true) {
|
while (true) {
|
||||||
Result rc = ResultSuccess;
|
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) {
|
if (check_vol_up && R_SUCCEEDED((rc = gpioPadGetValue(&vol_up_btn, &val))) && val == GpioValue_Low) {
|
||||||
bpcRebootSystem();
|
bpcRebootSystem();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user