mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-27 21:24:11 -04:00
fatal: Implement PowerButtonObserveTask
This commit is contained in:
parent
b771c42f7f
commit
13e5043d64
3 changed files with 51 additions and 2 deletions
|
@ -17,6 +17,30 @@
|
|||
#include <switch.h>
|
||||
#include "fatal_task_power.hpp"
|
||||
|
||||
void PowerButtonObserveTask::WaitForPowerButton() {
|
||||
/* Wait up to a second for error report generation to finish. */
|
||||
eventWait(this->erpt_event, TimeoutHelper::NsToTick(1000000000UL));
|
||||
|
||||
/* TODO: Force a reboot after some time if kiosk unit. */
|
||||
|
||||
BpcSleepButtonState state;
|
||||
while (true) {
|
||||
Result rc = bpcGetSleepButtonState(&state);
|
||||
if (R_SUCCEEDED(rc) && state == BpcSleepButtonState_Held) {
|
||||
bpcRebootSystem();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Wait 100 ms between button checks. */
|
||||
svcSleepThread(TimeoutHelper::NsToTick(100000000UL));
|
||||
}
|
||||
}
|
||||
|
||||
Result PowerButtonObserveTask::Run() {
|
||||
WaitForPowerButton();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result StateTransitionStopTask::Run() {
|
||||
/* Nintendo ignores the output of this call... */
|
||||
spsmPutErrorState();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue