nn::applet::CTR::GetSleepNotificationState FunctionAppletSleepNotificationState GetSleepNotificationState( void );
None.
Gets the sleep notification state.
This function may return the following values to the application.
| Value | Description |
|---|---|
| applet::NOTIFY_NONE | Normal Use |
| applet::NOTIFY_SLEEP_QUERY | After SLEEP_QUERY notification (deferred). |
| applet::NOTIFY_SLEEP_ACCEPT | After SLEEP_QUERY notification (accepted). |
| applet::NOTIFY_SLEEP_REJECT | After SLEEP_QUERY notification (rejected). |
| applet::NOTIFY_SLEEP_ACCEPTED | After SLEEP confirmed. |
| applet::NOTIFY_AWAKE | After AWAKE notification. |
This function returns applet::NOTIFY_SLEEP_QUERY when the application's sleep query callback returned applet::REPLY_LATER.
In this case, the ReplySleepQuery function must immediately return either nn::applet::CTR::REPLY_ACCEPT or nn::applet::CTR::REPLY_REJECT.
This function returns applet::NOTIFY_SLEEP_ACCEPT when the query callback return value or the nn::applet::CTR:ReplySleepQuery return value is applet::REPLY_ACCEPT.
This function returns applet::NOTIFY_SLEEP_REJECT when the query callback return value or the nn::applet::CTR:ReplySleepQuery return value is applet::REPLY_REJECT.
This function returns applet::NOTIFY_SLEEP_ACCEPTED when all applications and applets reply "accept" to the sleep query and confirm sleep mode. However, in such cases, the system immediately transitions to sleep mode, so it is almost impossible to actually use this value in the application.
This function returns applet::NOTIFY_AWAKE after the system wakes up and the AWAKE callback is called.
This function returns applet::NOTIFY_NONE after a call to the nn::applet::CTR::ClearSleepNotificationState function.
This function is intended to be used to check if the application needs to reply to sleep queries using the main thread. The API also includes the inline nn::applet::CTR::IsExpectedToReplySleepQuery function for this purpose. That function simply checks whether the sleep notification state is NOTIFY_SLEEP_QUERY.
Example
// Okay to write this way too:
if ( applet::GetSleepNotificationState() == applet::NOTIFY_SLEEP_QUERY )
{
applet::ReplySleepQuery( applet::REPLY_ACCEPT );
awakeEvent.Wait(); // Sleep
}
// Or write it this way:
if ( applet::IsExpectedToReplySleepQuery() )
{
applet::ReplySleepQuery( applet::REPLY_ACCEPT );
awakeEvent.Wait(); // Sleep
}
CONFIDENTIAL