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 demo program (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.<BR>Values obtained from the library can be displayed onscreen and values that can be modified by the library can be edited.<BR> 22</p> 23 24<h3>Screen Display</h3> 25<TABLE border="1" cellpadding="3" cellspacing="0.1"> 26 <TBODY> 27 <TR> 28<TD>POINTING</TD> 29<TD>Indicates the scaling value for determining the onscreen position using the factor with which to multiply the <CODE>pos</CODE> member variable of the <code><A HREF="../KPADStatus.html">KPADStatus</A></code> structure. The blue frame that is displayed onscreen shows a range of +/-1 for <CODE>pos</CODE>.</TD> 30 </TR> 31 <TR> 32<TD>INTERVAL</TD> 33<TD>Indicates in meters the interval between detection of the two Sensor Bar sensors.</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 <CODE>pos</CODE>, <CODE>horizon</CODE>, <CODE>dist</CODE>, and <CODE>acc</CODE> of the <CODE><A HREF="../KPADStatus.html">KPADStatus</A></CODE> 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>Indicates the flag as a binary value when a digital button is held down (<code>hold</code>).</TD> 46 </TR> 47 <TR> 48<TD>TRG</TD> 49<TD>Indicates the flag as a binary value at the instant when a digital button is pressed (<code>trig</code>).</TD> 50 </TR> 51 <TR> 52<TD>REL</TD> 53<TD>Indicates the flag as a binary value at the instant when a digital button is released (<code>release</code>).</TD> 54 </TR> 55 <TR> 56<TD>ACC</TD> 57<TD>Indicates the <CODE>acc</CODE> 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. (Arrows are solid lines.) When a Nunchuk controller is connected, the <code>fs.acc</code> information of the <A HREF="../KPADEXStatus.html"><code>KPADEXStatus</code></A> structure is displayed in the same way. (Arrows are dotted lines.)</TD> 58 </TR> 59 <TR> 60<TD>VALID</TD> 61<TD>Indicates the <code>dpd_valid_fg</code> value of the <code><A HREF="../KPADStatus.html">KPADStatus</A></code> structure.</TD> 62 </TR> 63 <TR> 64<TD>DIST</TD> 65<TD>Indicates the <CODE>dist</CODE> value of the <code><A HREF="../KPADStatus.html">KPADStatus</A></code> 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>Will be displayed together with the 'reason' 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><nobr>CIRCLE CLAMP</nobr> / <nobr>CROSS CLAMP</nobr></TD> 81<TD>Displays the stick clamp mode.</TD> 82 </TR> 83 <TR> 84<TD>SMP.RATE</TD> 85<TD>Displays the number of <a href="../KPADSetSamplingCallback.html"><CODE>KPADSetSamplingCallback</CODE></a> function registered callbacks 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. You can move the cursor with the +Control Pad, use the A Button to increment the value for that digit or change <CODE>play_mode</CODE> to <code>KPAD_PLAY_MODE_TIGHT</code>, and use the B Button to decrement the value 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 for some reason or if the accelerometer returns values that are off by a large magnitude (for example, when the Wii Remote is held in a horizontal position, but the acceleration sensor returns values that differ greatly from the values for a horizontal position). The calibration process corrects the value of the <CODE>horizon</CODE> member of the <code><A HREF="../KPADStatus.html">KPADStatus</A></code> structure (the <CODE>acc</CODE> member variable is not affected). 99</p> 100<p> 101Calibration is activated by pressing the + Button and - Button simultaneously. Be sure the controller is in a horizontal position and that only two sensors are detected. If one or three sensors are detected, calibration fails. If calibration succeeds, CALIBRATE is displayed onscreen. If calibration fails, ERROR is displayed onscreen. 102</p> 103 104<h3>Nunchuk</h3> 105<p> 106When the Control Stick on the Nunchuk is moved, the movement is displayed on the TV screen as a yellow, broken-line, arrow. 107</p> 108 109<h3>Classic Controller</h3> 110<p> 111The kpadsample demo supports the Classic Controller. When a Classic Controller is connected to the Wii Remote, the state of the digital buttons (pressed or not) on the Classic Controller will be displayed on the lower part of the TV screen. Movements of the Classic Controller L Stick and R Stick are displayed on-screen using blue and green arrows, respectively. 112</p> 113 114<h3>DPD ON/OFF</h3> 115<p> 116The DPD feature can be turned on by pressing the 1 Button on the Wii Remote and turned off by pressing the 2 Button. 117</p> 118 119<h3>Aiming Mode ON/OFF</h3> 120<p> 121Pressing HOME on the Wii Remote can switch the Aiming mode using the <a href="../KPADEnableAimingMode.html"><CODE>KPADEnableAimingMode</CODE></a> and <a href="../KPADDisableAimingMode.html"><CODE>KPADDisableAimingMode</CODE></a> functions. 122</p> 123 124<h3>Stick Clamp Mode</h3> 125<p> 126Allows switching of clamp mode of the Nunchuk or Classic Controller stick. The clamp mode is configured through <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>Miscellaneous Test Features</h3> 130<p> 131Miscellaneous tests may be performed by connecting the Nintendo GameCube Controller to Connector Socket 1. 132<ul> 133<li>Pressing the A Button once will call the <a href="../KPADReset.html"><CODE>KPADReset</CODE></a> function.</li> 134<li>While the B Button is being pressed, the <a href="../KPADRead.html"><CODE>KPADRead</CODE></a> will not be called from the program main loop.</li> 135<li>Pressing the X Button one time will call the <a href="../KPADSetReviseMode.html">KPADSetReviseMode</a> function, which toggles ON/OFF the correction for the position considered to be horizontal for the values returned by the Nunchuk's Motion Sensor.</li> 136</ul> 137</p> 138 139<h3>Source Code Files</h3> 140<TABLE border="1" cellpadding="3" cellspacing="0.1"> 141 <TBODY> 142 <TR> 143<TD><code>main.h</code>, <code>main.c</code></TD> 144<TD>Contains the application startup and framework source. Controller initialization and loading are performed in these files.</TD> 145 </TR> 146 <TR> 147<TD><code>sample.h</code>, <code>sample.c</code></TD> 148<TD>This application performs a variety of operations with the controller values. Contains the source for CPU and drawing processes performed in each frame.</TD> 149 </TR> 150 <TR> 151<TD><code>graphic.h</code>, <code>graphic.c</code></TD> 152<TD>The collection of subroutines for simple graphics drawing.</TD> 153 </TR> 154 <TR> 155<TD><code>kfont.h</code>, <code>kfont.c</code></TD> 156<TD>The collection of subroutines that displays text and values onscreen.</TD> 157 </TR> 158 </TBODY> 159</TABLE> 160 161<h2>See Also</h2> 162 163<H2>Revision History</H2> 164<P> 1652007/07/12 Added a note about the addition of operations to change play_mode.<br>2007/06/04 Added the information about how the correction process for the Nunchuk Motion Sensor is toggled On/Off by the <CODE>KPADSetReviseMode</CODE> function.<br>2007/01/15 Revised so that the coordinate correction function is enabled by default. Revised the sample demo along with this.<br>2006/10/25 Revised description to match KPAD version 2.<br>2006/09/07 Added information about turning Aiming mode ON/OFF.<br>2006/08/30 Added information about the operation of the Nunchuk and Classic Controller.<br>2006/08/30 Added information about the ON/OFF operation of the DPD function.<br>2006/06/19 Changed tentative product name to official name.<BR>2006/03/01 Initial version.<br> 166</P> 167 168<hr> 169<P>CONFIDENTIAL</p> 170</BODY> 171</HTML>