1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
3  <head>
4    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5    <meta http-equiv="Content-Style-Type" content="text/css" />
6    <link rel="stylesheet" href="../../../css/manpage.css" type="text/css" />
7<title>ProcessPowerButtonAndWait</title>
8  </head>
9  <body>
10<h1><CODE><a href="../../../nn/Overview.html">nn</a>::<a href="../../../nn/applet/Overview.html">applet</a>::<a href="../../../nn/applet/CTR/Overview.html">CTR</a>::ProcessPowerButtonAndWait</CODE> Function</h1>
11<h2>Syntax</h2>
12    <div class="section">
13      <pre class="definition">
14void ProcessPowerButtonAndWait();
15</pre>
16    </div>
17<h2>Parameters</h2>
18    <div class="section">
19<p>None.</p>
20    </div>
21<h2>Return Values</h2>
22    <div class="section">
23None.
24               </div>
25<h2>Description</h2>
26    <div class="section">
27<p>Processes POWER Button transition and goes into standby until activated.</p><p>
28This function was designed to be used as follows. Only call this function if the <CODE><a href="../../../nn/applet/CTR/IsExpectedToProcessPowerButton.html">nn::applet::CTR::IsExpectedToProcessPowerButton</a></CODE> function returns <CODE>true</CODE>. After this function returns, make sure to check whether to exit the application using the <CODE><a href="../../../nn/applet/CTR/IsExpectedToCloseApplication.html">nn::applet::CTR::IsExpectedToCloseApplication</a></CODE> function.
29      </p><pre>
30    if ( nn::applet::CTR::IsExpectedToProcessPowerButton() )
31    {
32        // Perform processing as needed here before transitioning to the POWER Menu.
33
34        nn::applet::CTR::ProcessPowerButtonAndWait();
35        if ( nn::applet::CTR::IsExpectedToCloseApplication )
36        {
37            // Leave the main loop, and perform termination processing
38        }
39
40        // Perform processing as needed here after returning from the POWER Menu.
41    }
42</pre><p>
43This function performs the following processing internally.
44<pre>
45    // Disable sleep
46    bool e = IS_SLEEP_ENABLED();  // pseudocode: Check if sleep is enabled.
47    if ( e )
48    {
49        nn::applet::CTR::DisableSleep();
50    }
51    // Process power button
52    nn::applet::CTR::ProcessPowerButton();
53    nn::applet::CTR::WaitForStarting();
54    // Enable sleep if necessary
55    if ( e )
56    {
57        nn::applet::CTR::EnableSleep();
58    }
59</pre></p><p>There is no need to take the sleep-enabled status into account when calling this function. This is because although it will return to Sleep Mode regardless of the return value of the <CODE><a href="../../../nn/applet/CTR/IsExpectedToCloseApplication.html">nn::applet::CTR::IsExpectedToCloseApplication</a></CODE> function, the sleep-related callback will not be called if the application termination flag is <CODE>true</CODE>.
60      </p><p>
61In addition, you must initialize the graphics library using the <CODE>nngxInitialize</CODE> function before calling this function. Then, after the display buffer has been set and buffers have been swapped once, you must turn on the LCD screens.
62      </p><p>
63If the LCD screens are not turned on, the upper and lower screens will remain black even if you return to the HOME Menu. (Background music and sound effects will play normally, and key input will be handled as usual.) Although this function can be called even if a display buffer has not been configured, the image shown when the LCDs are turned on may be undefined.
64      </p><p>
65Before calling this function, be sure that rendering has finished by calling the <CODE>nngxWaitCmdlistDone</CODE> function. For frameworks where multiple command lists will be swapped and commands will be created in parallel with rendering, pay close attention to the timing of <a href="../../../nn_gx/nngxRunCmdlist.html"><CODE>nngxRunCmdlist</CODE></a> function calls.<br />The GPU may hang if rendering has not completed before this function is called.<BR>If rendering has not yet completed at the time that this function is called (while a command request is processing), execution halts on an assertion (only for the Development/Debug builds).<br /></p></div>
66<h2>Revision History</h2>
67    <div class="section">
68      <dl class="history">
69        <dt>2012/02/07</dt>
70<dd>Noted that execution halts on an assertion if rendering has not yet completed at the time this function is called. <br />
71        </dd>
72        <dt>2012/01/16</dt>
73<dd>Added a specific example about limitations when calling this function (the need to wait for rendering to complete).<BR>
74        </dd>
75        <dt>2011/09/08</dt>
76<dd>Added information about limitations when calling this function (the need to wait for rendering to complete).<BR>
77        </dd>
78        <dt>2011/08/01</dt>
79<dd>Added information about limitations related to display buffer swapping and the LCD screens when calling this function.<BR>
80        </dd>
81        <dt>2011/03/30</dt>
82<dd>Added note about the need for the <CODE>nngxInitialize</CODE> function.
83        </dd>
84        <dt>2011/03/07</dt>
85<dd>Initial version.<br />
86        </dd>
87      </dl>
88    </div>
89  <hr><p>CONFIDENTIAL</p></body>
90</html>
91