nn::applet::CTR::ProcessHomeButton Function
bool ProcessHomeButton(
void
);
None.
Processes transitions to the HOME Menu.
This function is used to jump to the HOME Menu when this is required by the nn::applet::CTR::IsExpectedToProcessHomeButton function.
The return value indicates whether it is necessary to wait with the nn::applet::CTR::WaitForStarting function after this function is called. If this is true, call the function. If this is false, you do not need to call the function. (Of course, even if you call the function it will simply exit without waiting.)
To ensure mutual exclusion with Sleep Mode, you must call nn::applet::CTR::DisableSleep(true) before calling this function. You must call nn::applet::CTR::EnableSleep(true) after waiting and determining to finish waiting. (Note that the above constraint is specific to the current version and may change in the future.)
You must also initialize the graphics library using the nngxInitialize function before calling this function. Also, after the display buffer has been set and buffers have been swapped once, you must turn on the LCD screens.
If the LCD screens are not turned on, the upper and lower screens will remain black even if you return to the HOME Menu. (Background music and sound effects will play normally, and key input will be handled as usual.) Although this function can be called even if a display buffer has not been configured, the image shown when the LCDs are turned on may be undefined.
Example
// HOME Button transition check
if ( applet::IsExpectedToProcessHomeButton() )
{
_save_my_data();
applet::DisableSleep(true);
// HOME Button transition process
applet::ProcessHomeButton();
// Wait
applet::WaitForStarting();
if( applet::IsExpectedToCloseApplication() )
{
_close_application();
}
applet::EnableSleep(true);
_recover_my_data();
}
Before calling this function, be sure that rendering has finished by calling the nngxWaitCmdlistDone function. For frameworks where multiple command lists will be swapped and commands will be created in parallel with rendering, pay close attention to the timing of nngxRunCmdlist function calls.
The GPU may hang if rendering has not completed before this function is called.
If rendering has not yet completed at the time that this function is called (while a command request is processing), execution halts on an assertion (only for the Development/Debug builds).
In addition, after returning from an applet such as the HOME Menu, be sure to reset all necessary registers because GPU register values will have been updated if the return value of nn::applet::CTR::IsExpectedToCloseApplication is false.
/* When using the GL library */ nngxUpdateState(NN_GX_STATE_ALL); /* When using the GD library */ nn::gd::System::ForceDirty(nn::gd::MODULE_ALL); /* When using the GR library */ // There is no API for returning settings because internal settings are not maintained. // Create all necessary commands for the next rendering pass. /* Others */ // Reset all necessary registers for the next rendering pass.
If HomeButtonCallback has been set by the nn::applet::CTR::SetHomeButtonCallback function, do not call this function until after the process has left the callback. (If you call the function beforehand, the process might become deadlocked.)
Although old versions of the library had the nn::applet::CTR::ProcessHomeButtonIfPrepared function, it has the exact same behavior as this function. Use this function instead.
If any library applets have been preloaded, calling this function cancels those preloads when the transition occurs.
You need to pay attention to race conditions with this function when you preload library applets in another thread. For example, if the nn::applet::CTR::IsExpectedToProcessHomeButton function detects the HOME Button and this function is later called in the same thread but library applets are preloaded in another, an assert statement will trigger a warning because of an inconsistency in internal states.
nngxInitialize function.
DisableSleep and EnableSleep functions.ProcessHomeButtonIfPrepared.
CONFIDENTIAL