poweroff/reboot for Rosalina misc. menu

This commit is contained in:
Ezekiel Bethel 2017-06-11 17:06:43 +01:00
parent 52a18831a7
commit 37eb21d297
No known key found for this signature in database
GPG Key ID: 6915A190A8C54CCB
2 changed files with 54 additions and 1 deletions

View File

@ -34,3 +34,5 @@ extern Menu miscellaneousMenu;
void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void);
void MiscellaneousMenu_ChangeMenuCombo(void);
void MiscellaneousMenu_InputRedirection(void);
void MiscellaneousMenu_PowerOff(void);
void MiscellaneousMenu_Reboot(void);

View File

@ -36,11 +36,13 @@
Menu miscellaneousMenu = {
"Miscellaneous options menu",
.nbItems = 3,
.nbItems = 5,
{
{ "Switch the hb. title to the current app.", METHOD, .method = &MiscellaneousMenu_SwitchBoot3dsxTargetTitle },
{ "Change the menu combo", METHOD, .method = MiscellaneousMenu_ChangeMenuCombo },
{ "Start InputRedirection", METHOD, .method = &MiscellaneousMenu_InputRedirection },
{ "Power off", METHOD, .method = &MiscellaneousMenu_PowerOff },
{ "Reboot", METHOD, .method = &MiscellaneousMenu_Reboot },
}
};
@ -259,3 +261,52 @@ void MiscellaneousMenu_InputRedirection(void)
}
while(!(waitInput() & BUTTON_B) && !terminationRequest);
}
void MiscellaneousMenu_Reboot()
{
Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu");
Draw_DrawString(10, 30, COLOR_WHITE, "Press A to reboot, press B to go back.");
Draw_FlushFramebuffer();
Draw_Unlock();
do
{
u32 pressed = waitInputWithTimeout(1000);
if(pressed & BUTTON_A)
{
svcKernelSetState(7);
}
else if(pressed & BUTTON_B)
{
return;
}
}
while(!terminationRequest);
}
void MiscellaneousMenu_PowerOff() // Soft shutdown.
{
Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu");
Draw_DrawString(10, 30, COLOR_WHITE, "Press A to power off, press B to go back.");
Draw_FlushFramebuffer();
Draw_Unlock();
do
{
u32 pressed = waitInputWithTimeout(1000);
if(pressed & BUTTON_A)
{
menuLeave();
srvPublishToSubscriber(0x203, 0);
}
else if(pressed & BUTTON_B)
{
return;
}
}
while(!terminationRequest);
}