nn::applet::CTR::ProcessPowerButton Function
bool ProcessPowerButton(
void
);
None.
Processes POWER Button transitions.
This function is used to handle POWER Button transitions when this is required by the nn::applet::CTR::IsExpectedToProcessPowerButton 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. There is no need to call the function if the value is false, but if called the function exits without problems. (Currently no case exists where the value could be false.)
To ensure mutual exclusion with Sleep Mode, you must call nn::applet::CTR::DisableSleep(true) before calling this function. For strict symmetry, it would be necessary to call nn::applet::CTR::EnableSleep(true) after waiting and determining to finish waiting. However, since the finish determination is always true, it should cause no problems to omit that function call. (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.
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).
Example
if ( applet::IsExpectedToProcessPowerButton() )
{
applet::DisableSleep();
// POWER Button processing (transition to HOME Menu)
applet::ProcessPowerButton();
// Wait
applet::WaitForStarting();
if ( applet::IsExpectedToCloseApplication() ) // Probably 'true'
{
_close_application();
}
// Control is unlikely to reach this point, so the lines below here can be omitted
applet::EnableSleep();
}
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.)
nngxInitialize function.
DisableSleep and EnableSleep functions.CONFIDENTIAL