nn::applet::CTR::ProcessPowerButtonAndWait Function

Syntax

void ProcessPowerButtonAndWait();

Parameters

None.

Return Values

None.

Description

Processes POWER Button transition and goes into standby until activated.

This function was designed to be used as follows. Only call this function if the nn::applet::CTR::IsExpectedToProcessPowerButton function returns true. After this function returns, make sure to check whether to exit the application using the nn::applet::CTR::IsExpectedToCloseApplication function.

    if ( nn::applet::CTR::IsExpectedToProcessPowerButton() )
    {
        // Perform processing as needed here before transitioning to the POWER Menu.

        nn::applet::CTR::ProcessPowerButtonAndWait();
        if ( nn::applet::CTR::IsExpectedToCloseApplication )
        {
            // Leave the main loop, and perform termination processing
        }

        // Perform processing as needed here after returning from the POWER Menu.
    }

This function performs the following processing internally.

    // Disable sleep
    bool e = IS_SLEEP_ENABLED();  // pseudocode: Check if sleep is enabled.
    if ( e )
    {
        nn::applet::CTR::DisableSleep();
    }
    // Process power button
    nn::applet::CTR::ProcessPowerButton();
    nn::applet::CTR::WaitForStarting();
    // Enable sleep if necessary
    if ( e )
    {
        nn::applet::CTR::EnableSleep();
    }

There is no need to take the sleep-enabled status into account when calling this function. This is because although it will return to Sleep Mode regardless of the return value of the nn::applet::CTR::IsExpectedToCloseApplication function, the sleep-related callback will not be called if the application termination flag is true.

In addition, you must initialize the graphics library using the nngxInitialize function before calling this function. Then, 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).

Revision History

2012/02/07
Noted that execution halts on an assertion if rendering has not yet completed at the time this function is called.
2012/01/16
Added a specific example about limitations when calling this function (the need to wait for rendering to complete).
2011/09/08
Added information about limitations when calling this function (the need to wait for rendering to complete).
2011/08/01
Added information about limitations related to display buffer swapping and the LCD screens when calling this function.
2011/03/30
Added note about the need for the nngxInitialize function.
2011/03/07
Initial version.

CONFIDENTIAL