nn::applet::CTR::IsExpectedToCloseApplication Function

Syntax

bool IsExpectedToCloseApplication(
     void
);

Arguments

None.

Return Values

true indicates that the application should be closed and false indicates that the application does not need to be closed.

Description

Determines whether an application should be closed.

A return value of true indicates that the shutdown process has started because there was a close request or for some other reason. In this case, close the application immediately.

A return value of false indicates that the application does not need to be closed. In this case, do nothing.

Call this function periodically (usually every frame). You must also check immediately after returning from a function that is waiting on WaitForStarting.

Do this before calling any of the other check functions in the APPLET library (nn::applet::CTR::IsExpectedToProcessHomeButton, nn::applet::CTR::IsExpectedToProcessPowerButton, and nn::applet::CTR::IsExpectedToReplySleepQuery) once control has returned from the waiting state.

Example
nnMain()
{
     ...
   while(1)
   {
     _exec();
     _draw();

     // Checking for close after each frame
     if ( applet::IsExpectedToCloseApplication() )
     {
        _application_finalize();
        applet::PrepareToCloseApplication();
        applet::CloseApplication();
        // Execution doesn't reach this point.
     }

     // Launch library applet after A Button press
     if ( _pushed_A_button() )
     {
        _start_library_applet();

        // Wait for return from library applet
        applet::WaitForStarting();

        // Check for close after control returns
        if ( applet::IsExpectedToCloseApplication() )
        {
          _application_finalize();
          applet::PrepareToCloseApplication();
          applet::CloseApplication();
          // Execution doesn't reach this point.
        }
     }
     ...

Revision History

2010/12/10
Removed a clause about closing an application because of the POWER Button.
2010/11/30
Initial version.

CONFIDENTIAL