nn::applet::CTR::ProcessPowerButton Function

Syntax

bool ProcessPowerButton(
     void
);

Arguments

None.

Return Values

Returns a value indicating whether it is necessary to wait.

Description

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 particular to the current version and may change in future.)

In addition, before calling this function you must initialize the graphics library using the nngxInitialize function.

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.)

Revision History

2011/03/30
Added the need to use the nngxInitialize function.
2011/02/17
Added a cautionary note about setting the callback.
2011/01/24
Added mention of the DisableSleep and EnableSleep functions.
2010/12/09
Initial version.

CONFIDENTIAL