nn::applet::CTR::Enable Function

Syntax

void Enable(
     bool isSleepEnabled = true
);

Parameters

Name Description
in isSleepEnabled This option specifies whether sleep is enabled.

Return Values

None.

Description

Enables features specific to the applet library.

You must always call this function. Calling this function enables the features provided by the Applet library. The application is inactive until this function is called.

Because the sleep-related callbacks, the HOME Button callback, and POWER Button callback are enabled immediately after this function is called, applications must configure each of the callbacks as early as possible and then call this function. However, call this function before calling the nngxInitialize, nn::snd::Initialize, or nn::dsp::Initialize functions. (There is more information about the nngxInitialize function below.)

Specify true for the isSleepEnabled argument to have the function call nn::applet::CTR::EnableSleep(applet::NO_SHELL_CHECK) internally. In other words, this enables sleep notifications. However, the applet::NO_SHELL_CHECK argument indicates that when the nn::applet::CTR::EnableSleep function is called it does not check whether the system is closed. If you want to account for the possibility that that system may already be closed by that time, call nn::applet::CTR::EnableSleep(applet::SLEEP_IF_SHELL_CLOSED) immediately after this function.

Specify false for the isSleepEnabled argument to not enable sleep notifications. After this, call the nn::applet::CTR::EnableSleep function as appropriate.

This function calls nn::applet::CTR::WaitForStarting. Because you must determine whether to close the application when this function returns, call the nn::applet::CTR::IsExpectedToCloseApplication function after this one exits. Call the nngxInitialize function only after this determination has finished.

Example

  nnMain()
  {
      applet::SetSleepQueryCallback( mySleepQueryCallback, 0 );
      applet::SetAwakeCallback( myAwakeCallback, 0 );
      applet::Enable();
      if ( applet::IsExpectedToCloseApplication() ) // Check for a close request
      {
          _finalize_application();
          applet::PrepareToCloseApplication();
          applet::CloseApplication();
      }
      applet::EnableSleep( applet::SLEEP_IF_SHELL_CLOSED );
       ...

Note:

When applications that do not call this function are run on a debugger, the following problems occur because the applications are running outside of the CTR system.

This second problem can be resolved by calling the nngxStartLcdDisplay function.

If an application is started from the development menu and the POWER Button is pressed after startup, execution may stop at this function. For more information, see the documentation for the development menu.

Also, execution stops on the 3DS logo screen if an application that has not called this function is started from the HOME Menu.

Revision History

2011/07/26
Added a description of behavior when an application that has not called this function is started from the HOME Menu.
2011/02/03
Added that execution may stop when the POWER Button is pressed immediately after startup.
2011/01/24
Added description of the order of calling this function versus the initialization functions of other libraries.
2010/12/14
Added information related to determining whether to close the application. Added information on the EnableSleep function.
2010/11/30
Added example.
2010/11/15
Initial version.

CONFIDENTIAL