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>AppletHomeButtonCallback</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>::AppletHomeButtonCallback</CODE> Type</h1>
11<h2>Syntax</h2>
12    <div class="section">
13      <pre class="definition">
14typedef bool(* nn::applet::CTR::AppletHomeButtonCallback)(uptr arg, bool isActive, nn::applet::CTR::HomeButtonState state);</pre>
15    </div>
16<h2>Description</h2>
17    <div class="section">
18<p>The type of the callback function invoked when HOME is pressed.</p><!-- write here --><P>
19The callback is called when a HOME Button press is detected. <BR><B>Note:</B> The thread that calls this callback has a stack size of roughly 4 KB. Take care to avoid overflows.
20</P><P>
21Use the <CODE><a href="../../../nn/applet/CTR/SetHomeButtonCallback.html">nn::applet::CTR::SetHomeButtonCallback</a></CODE> function to set the callback.
22</P><P>The value specified in <span class="argument">arg</span> is passed as is when setting the callback. Use as appropriate.
23</P><P>The <span class="argument">isActive</span> argument specifies whether the application is active. A value of <CODE>true</CODE> means the application is active.
24</P><P>The <span class="argument">state</span> argument specifies the HOME Button state. This is similar to the value obtained by calling the <CODE><a href="../../../nn/applet/CTR/GetHomeButtonState.html">nn::applet::CTR::GetHomeButtonState</a></CODE> function.
25</P><P>
26The return value determines whether to enable detection of HOME Button presses after this callback. A return value of <CODE>false</CODE> disables HOME Button detection. If HOME Button presses are detected after this callback, the <a href="../../../nn/applet/CTR/IsExpectedToProcessHomeButton.html"><CODE>nn::applet::CTR::IsExpectedToProcessHomeButton</CODE></a> function returns <CODE>true</CODE>. When the application is inactive, normally there is no need to detect HOME Button presses, so we recommend setting the same value as <span class="argument">isActive</span>.
27</P><P>
28Use as shown in the example below.
29</P><PRE>
30  Example
31
32  bool myHomeButtonCallback( uptr arg, bool isActive, applet::HomeButtonState state )
33  {
34      NN_UNUSED_VAR(arg);
35
36      if ( isActive )
37      {
38          if ( state == applet::HOME_BUTTON_SINGLE_PRESSED )
39          {
40             NN_LOG("HOME BUTTON is clicked.\n");
41          }
42          else
43          {
44             NN_LOG("HOME BUTTON is double-clicked.\n");
45          }
46          return true;
47      }
48      else
49      {
50          return false;
51      }
52  }
53
54  nnMain()
55  {
56      applet::SetHomeButtonCallback( myHomeButtonCallback, 0 );
5758  }
59</PRE><P>
60<B>Note</B>:
61</P><P>
62In CTR-SDK 4.0 and later versions, the double-click is no longer returned as a <SPAN class="argument">state</SPAN> parameter for the callback. The process does not enter the portion of the sample code that displays &quot;HOME BUTTON is double-clicked.&quot; The definition for the double-click itself remains for purposes of compatibility, but in the future it might be deleted.
63</P></div>
64<h2>Revision History</h2>
65    <div class="section">
66      <dl class="history">
67        <dt>2012/02/01</dt>
68<dd>Noted that the double-click is no longer returned in CTR-SDK 4.0 and later versions.<br />
69        </dd>
70        <dt>2011/01/24</dt>
71<dd>Added description of the stack.<br />
72        </dd>
73        <dt>2010/12/01</dt>
74<dd>Added details.
75        </dd>
76        <dt>2010/11/10</dt>
77<dd>Initial version.<br />
78        </dd>
79      </dl>
80    </div>
81  <hr><p>CONFIDENTIAL</p></body>
82</html>
83