nn::applet::CTR::ProcessHomeButtonAndWait Function

Syntax

void ProcessHomeButtonAndWait();

Parameters

None.

Return Values

None.

Description

Processes HOME Menu 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::IsExpectedToProcessHomeButton 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::IsExpectedToProcessHomeButton() )
    {
        // Perform processing as needed here before transitioning to the HOME Menu.

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

        // Perform processing as needed here after returning from the HOME 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 HOME button
    nn::applet::CTR::ProcessHomeButton();
    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).
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.

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 rendering before and after calling this function.
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