nn::applet::CTR::SetSleepQueryCallback Function

Syntax

void SetSleepQueryCallback(
     AppletSleepQueryCallback callback,
     uptr arg = 0
);

Arguments

Name Description
in callback Callback.
in arg Callback arguments.

Return Values

None.

Description

Sets the sleep query callback.

When something happens to cause a transition to sleep mode during normal operation (such as the system being closed), the applet manager queries all applications and applets if it is okay to transition to sleep mode. The system does not transition to sleep mode if just one application or applet sends a "reject" reply. This equates to a cancellation of the sleep request, causing the AWAKE callback set by nn::applet::CTR::SetAwakeCallback to be called.

Specify nn::applet::CTR::REPLY_ACCEPT to accept the sleep request, nn::applet::CTR::REPLY_REJECT to reject it, and nn::applet::CTR::REPLY_LATER to defer it.

When deferring, handle any required processing, then call nn::applet::CTR::ReplySleepQuery to immediately return either nn::applet::CTR::REPLY_ACCEPT or nn::applet::CTR::REPLY_REJECT.

If no callback is set, the query is treated as if REPLY_REJECT were returned. This is because accepting the sleep request instead could cause problems, such as if the applet were in the middle of saving data or rendering to the screen.

If the applet itself is not active, such as when another applet or menu has control or when waiting via nn::applet::CTR::WaitForStarting, always return nn::applet::CTR::REPLY_ACCEPT to sleep queries. This is to allow the active applet to determine whether to transition to sleep mode. This does not apply to applications designed to not transition to sleep mode while transitioning to another applet.

Example

// Sleep query callback
void mySleepQueryCallback(uptr arg)
{
  NN_UNUSED_VAR(arg);
  if ( applet::IsActive() )
  {
    return applet::REPLY_LATER;
  }
  else
  {
    return applet::REPLY_ACCEPT;
  }
}

Revision History

2010/11/10
Initial version.

CONFIDENTIAL