Cleaned up and rearranged the Rosalina menu in preparation for future features

This commit is contained in:
Hikari-chin
2017-07-23 22:44:14 -04:00
committed by Aurora Wright
parent a0c2b43b34
commit a4629e4b65
6 changed files with 209 additions and 131 deletions

View File

@@ -38,16 +38,12 @@
Menu miscellaneousMenu = {
"Miscellaneous options menu",
.nbItems = 8,
.nbItems = 4,
{
{ "Switch the hb. title to the current app.", METHOD, .method = &MiscellaneousMenu_SwitchBoot3dsxTargetTitle },
{ "Change the menu combo", METHOD, .method = MiscellaneousMenu_ChangeMenuCombo },
{ "Save settings", METHOD, .method = &MiscellaneousMenu_SaveSettings },
{ "Start InputRedirection", METHOD, .method = &MiscellaneousMenu_InputRedirection },
{ "Toggle LEDs", METHOD, .method = &MiscellaneousMenu_ToggleLEDs },
{ "Toggle Wireless", METHOD, .method = &MiscellaneousMenu_ToggleWireless },
{ "Power Off", METHOD, .method = &MiscellaneousMenu_PowerOff },
{ "Reboot", METHOD, .method = &MiscellaneousMenu_Reboot },
{ "Save settings", METHOD, .method = &MiscellaneousMenu_SaveSettings },
}
};
@@ -338,123 +334,3 @@ void MiscellaneousMenu_InputRedirection(void)
}
while(!(waitInput() & BUTTON_B) && !terminationRequest);
}
void MiscellaneousMenu_ToggleLEDs(void)
{
Draw_Lock();
Draw_ClearFramebuffer();
Draw_FlushFramebuffer();
Draw_Unlock();
do
{
Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu");
Draw_DrawString(10, 30, COLOR_WHITE, "Press A to toggle, press B to go back.");
Draw_DrawString(10, 40, COLOR_RED, "NOTE: Entering sleep mode will reset the LED state!");
Draw_FlushFramebuffer();
Draw_Unlock();
u32 pressed = waitInputWithTimeout(1000);
if(pressed & BUTTON_A)
{
mcuInit();
u8 result;
mcuGetLEDState(&result);
u8 value = ~result;
mcuWriteRegister(40, &value, 1);
mcuExit();
}
else if(pressed & BUTTON_B)
return;
}
while(!terminationRequest);
}
void MiscellaneousMenu_ToggleWireless(void)
{
Draw_Lock();
Draw_ClearFramebuffer();
Draw_FlushFramebuffer();
Draw_Unlock();
do
{
Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "Miscellaneous options menu");
Draw_DrawString(10, 30, COLOR_WHITE, "Press A to toggle, press B to go back.");
Draw_DrawString(10, 40, COLOR_WHITE, "Current status:");
u8 wireless = (*(vu8 *)((0x10140000 | (1u << 31)) + 0x180));
Draw_DrawString(100, 40, (wireless ? COLOR_GREEN : COLOR_RED), (wireless ? " ON " : " OFF"));
Draw_FlushFramebuffer();
Draw_Unlock();
u32 pressed = waitInputWithTimeout(1000);
if(pressed & BUTTON_A)
{
nwmExtInit();
NWMEXT_ControlWirelessEnabled(!wireless);
nwmExtExit();
}
else if(pressed & BUTTON_B)
return;
}
while(!terminationRequest);
}
void MiscellaneousMenu_Reboot(void)
{
Draw_Lock();
Draw_ClearFramebuffer();
Draw_FlushFramebuffer();
Draw_Unlock();
do
{
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();
u32 pressed = waitInputWithTimeout(1000);
if(pressed & BUTTON_A)
svcKernelSetState(7);
else if(pressed & BUTTON_B)
return;
}
while(!terminationRequest);
}
void MiscellaneousMenu_PowerOff(void) // Soft shutdown.
{
Draw_Lock();
Draw_ClearFramebuffer();
Draw_FlushFramebuffer();
Draw_Unlock();
do
{
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();
u32 pressed = waitInputWithTimeout(1000);
if(pressed & BUTTON_A)
{
menuLeave();
srvPublishToSubscriber(0x203, 0);
}
else if(pressed & BUTTON_B)
return;
}
while(!terminationRequest);
}