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 http-equiv="Content-Style-Type" content="text/css">
6<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css">
7<title>KPAD Sample Demos (kpadsample)</title>
8</head>
9
10<body>
11
12<h1>kpadsample</h1>
13
14<h2>Location</h2>
15<p>
16<code>$REVOLUTION_SDK_ROOT/build/demos/kpaddemo</code>
17</p>
18
19<H2>Description</H2>
20<p>
21This sample program verifies KPAD library functionality. Using it, you can display onscreen any value that is possible to obtain from the library, and you can edit any value it is possible to modify in the library.<br>
22</p>
23
24<h3>Screen Display</h3>
25<TABLE border="1" cellpadding="3" width="95%">
26  <TBODY>
27    <TR>
28      <TD>POINTING</TD>
29      <TD>The scaling value used for determining the on-screen position; it is the factor by which you multiply the <SPAN class="argument">pos</SPAN> member variable of the <A HREF="../KPADStatus.html"><CODE>KPADStatus</CODE></A> structure. The blue frame displayed on the screen shows a range of +/-1 for <SPAN class="argument">pos</SPAN>.</TD>
30    </TR>
31    <TR>
32      <TD>INTERVAL</TD>
33      <TD>Indicates the interval (in meters) between the two sensors on the Sensor Bar.</TD>
34    </TR>
35    <TR>
36      <TD>POS HOR DIS ACC - PLAY SENS MODE</TD>
37      <TD>Shows the play radius (<code>play_radius</code>), sensitivity (<code>sensitivity</code>), and play mode (<CODE>play_mode</CODE>) set for the <SPAN class="argument">pos</SPAN>,<SPAN class="argument">horizon</SPAN>,<SPAN class="argument">dist</SPAN>, and <SPAN class="argument">acc</SPAN> in the <A HREF="../KPADStatus.html"><CODE>KPADStatus</CODE></A> structure.</TD>
38    </TR>
39    <TR>
40      <TD>RPT - DLAY PLUS</TD>
41      <TD>Indicates the repeat start time (<code>delay_sec</code>) and the repeat interval (<code>pulse_sec</code>) of the digital button.</TD>
42    </TR>
43    <TR>
44      <TD>HLD</TD>
45      <TD>Displays the binary value of the flag set when a digital button is held down (<code>hold</code>) .</TD>
46    </TR>
47    <TR>
48      <TD>TRG</TD>
49      <TD>Displays the binary value of the flag set when a digital button is pressed (<code>trig</code>).</TD>
50    </TR>
51    <TR>
52      <TD>REL</TD>
53      <TD>Displays the  binary value of the flag set when a digital button is released (<code>release</code>).</TD>
54    </TR>
55    <TR>
56      <TD>ACC</TD>
57      <TD>Indicates the <SPAN class="argument">acc</SPAN> information of the <A HREF="../KPADStatus.html"><CODE>KPADStatus</CODE></A> structure as a vector in the 2D XY plane and a vector in the 2D ZY plane (displayed as solid-line arrows). When a Nunchuk is installed, the <SPAN class="argument">fs.acc</SPAN> information of the <A HREF="../KPADEXStatus.html"><CODE>KPADEXStatus</CODE></A> structure is displayed the same way (displayed as dotted-line arrows).</TD>
58    </TR>
59    <TR>
60      <TD>VALID</TD>
61      <TD>Indicates the <SPAN class="argument">dpd_valid_fg</SPAN> value of the <A HREF="../KPADStatus.html"><CODE>KPADStatus</CODE></A> structure.</TD>
62    </TR>
63    <TR>
64      <TD>DIST</TD>
65      <TD>Indicates the <SPAN class="argument">dist</SPAN> value of the <A HREF="../KPADStatus.html"><CODE>KPADStatus</CODE></A> structure.</TD>
66    </TR>
67    <TR>
68      <TD>OBJ</TD>
69      <TD>Indicates the position of the object captured by the DPD. The rectangle is the sensor range.</TD>
70    </TR>
71    <TR>
72      <TD>DPDCB</TD>
73      <TD>It will be displayed together with the <SPAN class="argument">reason</SPAN> value when a callback registered with <A HREF="../KPADSetControlDpdCallback.html"><CODE>KPADSetControlDpdCallback</CODE></A> is called. The display from the last call will stay on the screen.</TD>
74    </TR>
75    <TR>
76      <TD>AIM</TD>
77      <TD>Displays the aiming mode.</TD>
78    </TR>
79    <TR>
80      <TD>CIRCLE CLAMP / CROSS CLAMP</TD>
81      <TD>Displays the stick clamp mode.</TD>
82    </TR>
83    <TR>
84      <TD>SMP.RATE</TD>
85      <TD>Displays how  many registered callbacks of the <a href="../KPADSetSamplingCallback.html"><CODE>KPADSetSamplingCallback</CODE></a> function are called per second.</TD>
86    </TR>
87  </TBODY>
88</TABLE>
89
90<h3>Parameter Adjustment</h3>
91<p>
92The values can be edited using the digital buttons. Use the +Control Pad to move the cursor; A Button to increment the value for that digit or to change <CODE>play_mode</CODE> to <code>KPAD_PLAY_MODE_TIGHT</code>; and B Button to decrement it or change <CODE>play_mode</CODE> to <code>KPAD_PLAY_MODE_LOOSE</code>.<br>
93
94</p>
95
96<h3>Calibration</h3>
97<p>
98Calibration is required if the Sensor Bar is not level or if the accelerometer returns values that are off by a large amount. One example of this is when the Wii Remote is held in a horizontal position but the acceleration sensor returns values that differ considerably from those of a horizontal position. The calibration process corrects the value of the <A HREF="../KPADStatus.html"><CODE>KPADStatus</CODE></A> structure's <SPAN class="argument">horizon</SPAN> member variable; the <SPAN class="argument">acc</SPAN> member variable is not affected.
99</p>
100<p>
101To activate calibration, press the + Button and - Button simultaneously. Be sure that the controller is in a horizontal position and that only two sensors are detected. If one or three sensors are detected, calibration will fail. If calibration succeeds, CALIBRATE is displayed on the screen; if calibration fails, ERROR is displayed.<br>
102</p>
103
104<h3>Nunchuk</h3>
105<p>
106When the Nunchuk's Control Stick is moved, the movement is displayed on the TV screen as a yellow, dashed-line arrow.
107</p>
108
109<h3>Classic Controller</h3>
110<p>
111The <I>kpadsample</I> demo supports the Classic Controller. When a Classic Controller is connected to a Wii Remote, the state of the digital buttons (pressed/not pressed) on the Classic Controller will be displayed in the lower part of the TV screen. Movements of the Classic Controller L Stick and R Stick are displayed on the screen using blue and green arrows, respectively.
112</p>
113
114<h3>DPD ON/OFF</h3>
115<p>
116To turn the DPD feature ON, press the 1 Button on the Wii Remote; to turn it OFF, press the 2 Button.
117</p>
118
119<h3>Aiming Mode ON/OFF</h3>
120<p>
121When HOME on the Wii Remote is pressed, the aiming mode, which can be set using the  <a href="../KPADEnableAimingMode.html"><CODE>KPADEnableAimingMode</CODE></a> and <a href="../KPADDisableAimingMode.html"><CODE>KPADDisableAimingMode</CODE></a> functions, is switched.
122</p>
123
124<h3>Stick Clamp Mode</h3>
125<p>
126Allows the switching of clamp mode of the Nunchuk or Classic Controller stick. The clamp mode is configured using the <a href="../KPADEnableStickCrossClamp.html"><CODE>KPADEnableStickCrossClamp</CODE></a> and <a href="../KPADDisableStickCrossClamp.html"><CODE>KPADDisableStickCrossClamp</CODE></a> functions. This is switched every time a C Button on the Nunchuk Unit or the -/SELECT Button on the Classic Controller is pressed. This is also switched while the Z Button on the Nunchuk or the +/START Button on the Classic Controller is pressed.
127</p>
128
129<h3>Switching the Button Processing Method</h3>
130<p>
131Pressing the Z Button on the Nintendo GameCube controller connected to 1P calls the <a href="../KPADSetBtnProcMode.html"><code>KPADSetButtonProcMode</code></a> function and changes the button-processing method. In the <CODE>kpadsample</CODE> demo, cursor movements utilize the button trigger information in the starting element of the sample buffer of the <a href="../KPADReadEx.html"><CODE>KPADReadEx</CODE></a> function. Note that when the button processing method is <code>KPAD_BUTTON_PROC_MODE_TIGHT</code>, there will be times when the cursor does not move even if the button is pressed because there is no button trigger information in the starting element of the sampling buffer.
132</p>
133
134<h3>Miscellaneous Test Features</h3>
135<p>
136Miscellaneous tests may be performed by connecting a Nintendo GameCube Controller to 1P.
137</p>
138<ul>
139<li>Pressing the A Button once will call the <a href="../KPADReset.html"><CODE>KPADReset</CODE></a> function.</li>
140<li>While the B Button is being pressed, the <a href="../KPADReadEx.html"><CODE>KPADReadEx</CODE></a> function will not be called from the main loop of the program.</li>
141<li>Pressing the X Button once will call the <a href="../KPADSetReviseMode.html"><CODE>KPADSetReviseMode</CODE></a> function; it will also turn ON or OFF the corrective processing that switches the position at which the Nunchuk motion sensor returns a horizontal value.</li>
142<li>Each press of the Y Button will alternately call the <a href="../KPADInitEx.html"><code>KPADInitEx</code></a> and <a href="../KPADShutdown.html"><code>KPADShutdown</code></a> functions, starting and stopping the KPAD library.</li>
143<li>Pressing the Z Button once calls the <a href="../KPADSetBtnProcMode.html"><code>KPADSetButtonProcMode</code></a> function and changes the button-processing method.</li>
144</ul>
145
146<h3>Source Code Files</h3>
147<TABLE border="1" cellpadding="3" width="95%">
148  <TBODY>
149    <TR>
150      <TD><CODE>main.h</CODE><BR><CODE>main.c</CODE></TD>
151      <TD>Contains the application startup and framework source. Controllers are initialized and loaded in these files.</TD>
152    </TR>
153    <TR>
154      <TD><CODE>sample.h</CODE><BR><CODE>sample.c</CODE></TD>
155      <TD>This application performs a variety of operations with the controller values. Contains the source for the CPU and rendering processes performed in each frame.</TD>
156    </TR>
157    <TR>
158      <TD><CODE>graphic.h</CODE><BR><CODE>graphic.c</CODE></TD>
159      <TD>The collection of subroutines for simple graphics drawing.</TD>
160    </TR>
161    <TR>
162      <TD><CODE>kfont.h</CODE><BR><CODE>kfont.c</CODE></TD>
163      <TD>The collection of subroutines that display text and values on the screen.</TD>
164    </TR>
165  </TBODY>
166</TABLE>
167
168<h2>See Also</h2>
169<P>None.</P>
170
171<H2>Revision History</H2>
172<P>
1732008/06/05 Added text regarding the addition of the button processing method test.<br>2008/04/25 Added mention of the new operation for alternately calling the <code>KPADInit</code> and <code>KPADShutdown</code> functions.<br>2007/07/12 Added the description for changing <CODE>play_mode</CODE>.<br>2007/06/04 Added the description for turning the Nunchuk Motion Sensor&rsquo;s corrective processing ON or OFF using the <CODE>KPADSetReviseMode</CODE> function.<br>2007/01/15 Revised such that the coordinate correction feature is enabled by default. As a result, revised the demo.<br>2006/10/25 Revised the description to match KPAD version 2.<br>2006/09/07 Added information about turning the aiming mode ON and OFF.<br>2006/08/30 Added information about operating the Nunchuk and Classic Controller.<br>2006/08/30 Added information about the ON/OFF operation of the DPD functionality.<br>2006/06/19 Changed the product name from tentative to official.<br>2006/03/01 Initial version.<br>
174</P>
175
176<hr><p>CONFIDENTIAL</p></body>
177</html>