nn::applet::CTR::IsExpectedToProcessPowerButton Function

Syntax

bool IsExpectedToProcessPowerButton(
     void
);

Arguments

None.

Return Values

A value of true indicates that the POWER Button was clicked and a value of false indicates that it was not.

Description

Finds the state of the POWER Button.

A return value of true indicates that the POWER Button was pressed. In this case, the application must immediately call the nn::applet::CTR::ProcessPowerButton function and then wait with the nn::applet::CTR::WaitForStarting function.

A value of false indicates that a POWER Button press was not detected. In this case, do nothing.

Call this function periodically (usually every frame).

Example

  if ( applet::IsExpectedToProcessPowerButton() )
  {
    applet::DisableSleep();

    // POWER Button processing (transition to HOME Menu)
    applet::ProcessPowerButton();

    // Await
    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();
  }

Although this function was planned for removal in SDK 0.14.9, it was determined to be necessary upon further review of the shutdown sequence for the POWER Button. Though this is inconvenient, it is required to implement POWER Button handling.

It was originally assumed that determination functions, such as this one, and actual transition operation functions would be called in sequence from the same thread, but it is possible to have a mechanism where they are respectively called from separate threads. In such cases, however, sufficient care is needed such that there is nothing following the transition target operation during the working of the determination thread.

Revision History

2012/11/09
Added information on calling determination functions and transition functions from separate threads.
2011/02/09
Reworked for consistent terminology.
2011/01/24
Added mention of the DisableSleep and EnableSleep functions.
2010/12/09
This function was deemed necessary following a review of the shutdown sequence for the POWER Button.
2010/11/10
Initial version.

CONFIDENTIAL