1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3<head>
4<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows">
6<META http-equiv="Content-Style-Type" content="text/css">
7<title>PAD_Read</title>
8<LINK rel="stylesheet" href="../css/nitro.css" type="text/css">
9</head>
10
11<body>
12
13<h1 align="left">PAD_Read <IMG src="../image/NTR.gif" align="middle"><IMG src="../image/TWL.gif" align="middle"></h1>
14<h2>Syntax</h2>
15
16<dl>
17  <dd>
18<CODE>#include &lt;nitro/pad.h&gt;</CODE><BR> <BR> u16<CODE> PAD_Read( void );</CODE></dd>
19</dl>
20
21<h2>Arguments</h2>
22<P>None.</P>
23
24<h2>Return Values</h2>
25<p>Current key information</p>
26<p>In response to prohibited input, such as simultaneous presses of either (1) UP and DOWN or (2) LEFT and RIGHT on the +Control Pad, a filter is applied so that only UP will considered to have been pressed in the former case, and only LEFT will be considered to have been pressed in the latter case.</p>
27
28<H2>Description</H2>
29<P>Gets the information for pressed keys or buttons. The key/button information is the logical sum of the following values.
30
31</P>
32<TABLE>
33  <TBODY>
34    <TR>
35<TH>Value (Definition)</TH>
36<TH>State</TH>
37<TH>Value (Value)</TH>
38    </TR>
39    <TR>
40<TD bgcolor="#eeeeee"><CODE>PAD_BUTTON_A</CODE></TD>
41<TD bgcolor="#eeeeee">A Button is being pressed</TD>
42<TD><CODE>0x0001</CODE></TD>
43    </TR>
44    <TR>
45<TD bgcolor="#eeeeee"><CODE>PAD_BUTTON_B</CODE></TD>
46<TD bgcolor="#eeeeee">B Button is being pressed.</TD>
47<TD><CODE>0x0002</CODE></TD>
48    </TR>
49    <TR>
50<TD bgcolor="#eeeeee"><CODE>PAD_BUTTON_SELECT</CODE></TD>
51<TD bgcolor="#eeeeee">SELECT is being pressed.</TD>
52<TD><CODE>0x0004</CODE></TD>
53    </TR>
54    <TR>
55<TD bgcolor="#eeeeee"><CODE>PAD_BUTTON_START</CODE></TD>
56<TD bgcolor="#eeeeee">START is being pressed.</TD>
57<TD><CODE>0x0008</CODE></TD>
58    </TR>
59    <TR>
60<TD bgcolor="#eeeeee"><CODE>PAD_KEY_RIGHT</CODE></TD>
61<TD bgcolor="#eeeeee">+Control Pad Right key is being pressed.</TD>
62<TD><CODE>0x0010</CODE></TD>
63    </TR>
64    <TR>
65<TD bgcolor="#eeeeee"><CODE>PAD_KEY_LEFT</CODE></TD>
66<TD bgcolor="#eeeeee">+Control Pad Left key is being pressed.</TD>
67<TD><CODE>0x0020</CODE></TD>
68    </TR>
69    <TR>
70<TD bgcolor="#eeeeee"><CODE>PAD_KEY_UP</CODE></TD>
71<TD bgcolor="#eeeeee">+Control Pad Up key is being pressed.</TD>
72<TD><CODE>0x0040</CODE></TD>
73    </TR>
74    <TR>
75<TD bgcolor="#eeeeee"><CODE>PAD_KEY_DOWN</CODE></TD>
76<TD bgcolor="#eeeeee">+Control Pad Down key is being pressed.</TD>
77<TD><CODE>0x0080</CODE></TD>
78    </TR>
79    <TR>
80<TD bgcolor="#eeeeee"><CODE>PAD_BUTTON_R</CODE></TD>
81<TD bgcolor="#eeeeee">R Button is being pressed.</TD>
82<TD><CODE>0x0100</CODE></TD>
83    </TR>
84    <TR>
85<TD bgcolor="#eeeeee"><CODE>PAD_BUTTON_L</CODE></TD>
86<TD bgcolor="#eeeeee">L Button is being pressed.</TD>
87<TD><CODE>0x0200</CODE></TD>
88    </TR>
89    <TR>
90<TD><CODE>PAD_BUTTON_X</CODE></TD>
91<TD>X Button is being pressed.</TD>
92<TD><CODE>0x0400</CODE></TD>
93    </TR>
94    <TR>
95<TD><CODE>PAD_BUTTON_Y</CODE></TD>
96<TD>Y Button is being pressed.</TD>
97<TD><CODE>0x0800</CODE></TD>
98    </TR>
99    <TR>
100<TD><CODE>PAD_BUTTON_DEBUG</CODE></TD>
101<TD>DEBUG Button is being pressed.</TD>
102<TD><CODE>0x2000</CODE></TD>
103    </TR>
104  </TBODY>
105</TABLE>
106<P><BR>The X and Y Buttons can be read from ARM9 because ARM7 checks a general purpose port and writes in a shared region. Therefore, if the ARM7 read module is not operating, the X and Y Buttons cannot be read.<BR><BR> <CODE>PAD_BUTTON_MASK</CODE> is defined as the logical sum of all buttons (<CODE>PAD_BUTTON_...</CODE>), and <CODE>PAD_PLUS_KEY_MASK</CODE> is defined as the logical sum of all keys (<CODE>PAD_KEY_...</CODE>). <CODE>PAD_ALL_MASK</CODE> is defined as the sum of all buttons and keys. <BR><BR> Only the sum of the X, Y, and DEBUG Buttons read by ARM7 will be defined as <CODE>PAD_RCNTPORT_MASK</CODE>. Sums of other buttons are defined as <code>PAD_KEYPORT_MASK</code>.<BR>
107</P>
108<TABLE border="1">
109  <TBODY>
110    <TR>
111<TH colspan="2">Bit</TH>
112      <TH>13</TH>
113      <TH>12</TH>
114      <TH>11</TH>
115      <TH>10</TH>
116      <TH>9</TH>
117      <TH>8</TH>
118      <TH>7</TH>
119      <TH>6</TH>
120      <TH>5</TH>
121      <TH>4</TH>
122      <TH>3</TH>
123      <TH>2</TH>
124      <TH>1</TH>
125      <TH>0</TH>
126      <TH></TH>
127    </TR>
128    <TR>
129      <TD colspan="2"></TD>
130<TD>D<br />e<br />b<br />u<br />g</TD>
131<TD>N<br />/<br />A
132      </TD>
133<TD>Y
134      </TD>
135<TD>X
136      </TD>
137<TD>L<BR>
138      </TD>
139<TD>R<BR>
140      </TD>
141<TD>D<br />o<br />w<br />n
142      </TD>
143<TD>U<br />p
144      </TD>
145<TD>L<br />e<br />f<br />t</TD>
146<TD>R<br />i<br />g<br />h<br />t</TD>
147<TD>S<br />t<br />a<br />r<br />t</TD>
148<TD>S<br />e<br />l<br />e<br />c<br />t</TD>
149<TD>B<BR>
150      </TD>
151<TD>A<BR>
152      </TD>
153<TD style="background-color : #ddddaa;">Value</TD>
154    </TR>
155    <TR>
156<TD colspan="2"><CODE>PAD_BUTTON_MASK</CODE></TD>
157      <TD style="background-color : #ffc0c0;">1</TD>
158      <TD>0</TD>
159      <TD style="background-color : #ffc0c0;">1</TD>
160      <TD style="background-color : #ffc0c0;">1</TD>
161      <TD style="background-color : #ffc0c0;">1</TD>
162      <TD style="background-color : #ffc0c0;">1</TD>
163      <TD>0</TD>
164      <TD>0</TD>
165      <TD>0</TD>
166      <TD>0</TD>
167      <TD style="background-color : #ffc0c0;">1</TD>
168      <TD style="background-color : #ffc0c0;">1</TD>
169      <TD style="background-color : #ffc0c0;">1</TD>
170      <TD style="background-color : #ffc0c0;">1</TD>
171<TD style="background-color : #ddddaa;" align="center"><CODE>0x2F0F</CODE></TD>
172    </TR>
173    <TR>
174<TD colspan="2"><CODE>PAD_PLUS_KEY_MASK</CODE></TD>
175      <TD>0</TD>
176      <TD>0</TD>
177      <TD>0</TD>
178      <TD>0</TD>
179      <TD>0</TD>
180      <TD>0</TD>
181      <TD style="background-color : #ffc0c0;">1</TD>
182      <TD style="background-color : #ffc0c0;">1</TD>
183      <TD style="background-color : #ffc0c0;">1</TD>
184      <TD style="background-color : #ffc0c0;">1</TD>
185      <TD>0</TD>
186      <TD>0</TD>
187      <TD>0</TD>
188      <TD>0</TD>
189<TD style="background-color : #ddddaa;" align="center"><CODE>0x00F0</CODE></TD>
190    </TR>
191    <TR>
192<TD colspan="2"><CODE>PAD_ALL_MASK</CODE></TD>
193      <TD style="background-color : #ffc0c0;">1</TD>
194      <TD>0</TD>
195      <TD style="background-color : #ffc0c0;">1</TD>
196      <TD style="background-color : #ffc0c0;">1</TD>
197      <TD style="background-color : #ffc0c0;">1</TD>
198      <TD style="background-color : #ffc0c0;">1</TD>
199      <TD style="background-color : #ffc0c0;">1</TD>
200      <TD style="background-color : #ffc0c0;">1</TD>
201      <TD style="background-color : #ffc0c0;">1</TD>
202      <TD style="background-color : #ffc0c0;">1</TD>
203      <TD style="background-color : #ffc0c0;">1</TD>
204      <TD style="background-color : #ffc0c0;">1</TD>
205      <TD style="background-color : #ffc0c0;">1</TD>
206      <TD style="background-color : #ffc0c0;">1</TD>
207<TD style="background-color : #ddddaa;" align="center"><CODE>0x2FFF</CODE></TD>
208    </TR>
209    <TR>
210<TD colspan="2"><CODE>PAD_RCNPORT_MASK</CODE></TD>
211      <TD style="background-color : #ffc0c0;">1</TD>
212      <TD>0</TD>
213      <TD style="background-color : #ffc0c0;">1</TD>
214      <TD style="background-color : #ffc0c0;">1</TD>
215      <TD>0</TD>
216      <TD>0</TD>
217      <TD>0</TD>
218      <TD>0</TD>
219      <TD>0</TD>
220      <TD>0</TD>
221      <TD>0</TD>
222      <TD>0</TD>
223      <TD>0</TD>
224      <TD>0</TD>
225<TD style="background-color : #ddddaa;" align="center"><CODE>0x2C00</CODE></TD>
226    </TR>
227    <TR>
228<TD colspan="2"><CODE>PAD_KEYPORT_MASK</CODE></TD>
229      <TD>0</TD>
230      <TD>0</TD>
231      <TD>0</TD>
232      <TD>0</TD>
233      <TD style="background-color : #ffc0c0;">1</TD>
234      <TD style="background-color : #ffc0c0;">1</TD>
235      <TD style="background-color : #ffc0c0;">1</TD>
236      <TD style="background-color : #ffc0c0;">1</TD>
237      <TD style="background-color : #ffc0c0;">1</TD>
238      <TD style="background-color : #ffc0c0;">1</TD>
239      <TD style="background-color : #ffc0c0;">1</TD>
240      <TD style="background-color : #ffc0c0;">1</TD>
241      <TD style="background-color : #ffc0c0;">1</TD>
242      <TD style="background-color : #ffc0c0;">1</TD>
243<TD style="background-color : #ddddaa;" align="center"><CODE>0x03FF</CODE></TD>
244    </TR>
245  </TBODY>
246</TABLE>
247<BR>
248<H3>For Example</H3>
249<BLOCKQUOTE style="background-color:#ffffcc;"><CODE>u16 padData = <FONT color="#ff0000">PAD_Read()</FONT>;<BR> <BR> if ( padData &amp; PAD_BUTTON_A )<BR> {<BR> OS_Printf( &quot;You're pushing the A Button\n&quot; );<BR> }<BR> <BR> if ( padData &amp; PAD_PLUS_KEY_MASK )<BR> {<BR> OS_Printf( &quot;You're pushing one of the +Control Pad keys\n&quot; );<BR> }</CODE></BLOCKQUOTE>
250<P>The <code>PAD_Read</code> function reads the <code>KEYINPUT IO</code> register internally, aligns with the value from the <code>RCNT</code> register of the generic port that ARM7 acquired, and returns a value with the Key/Button mask <code>PAD_ALL_MASK</code> applied.</P>
251<H3>DEBUG Button</H3>
252<P>The DEBUG Button can be used freely by an application for development purposes. With IS-NITRO-DEBUGGER, the Power Button of the DS connected to the debugger serves as the DEBUG Button. (It will not work as the Power Button.)</P>
253<P>The Power button of the TWL system connected to the debugger will also serve as the DEBUG button with IS-TWL-DEBUGGER. However, it will also function as an actual Power button, so its intended purpose is slightly different than that of IS-NITRO-DEBUGGER.</P>
254<h2>See Also</h2>
255<P><A href="PAD_DetectFold.html"><CODE>PAD_DetectFold</CODE></A></P>
256<H2>Revision History</H2>
257<P>2008/04/16 Added a description of the prohibited input filter.<BR> 2004/08/06 Removed <CODE>PAD_SetIrq</CODE> and <CODE>PAD_ClearIrq</CODE> from <B>See Also</B>.<BR> 2004/04/13 Added the DEBUG button.<BR> 2004/02/19 Added the X and Y Buttons.<BR> 2003/12/01 Initial version.</P>
258<hr><p>CONFIDENTIAL</p></body>
259</html>
260