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=utf-8"> 5<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css"> 6<base target="main"> 7<title>KPAD API Introduction</title> 8</head> 9 10<body> 11 12<h1>KPAD API</h1> 13 14<h2>Introduction</h2> 15<p> 16Starting with version 3.3 of the Revolution SDK, <CODE>KPADOld</CODE> can no longer be used.<br>Starting with version 3.2 of the Revolution SDK, Wii Balance Board information can be obtained <font color="red">by linking the WBC library</font>. 17</p> 18 19<p> 20The KPAD library is a high-level library located above the WPAD library. Compared to using the WPAD library directly, the use of the KPAD library can get coordinates for where the Wii Remote is pointing more easily. It also provides features such as reducing the effects of hand tremor and adjusting the sensitivity of the Wii Remote. Besides the Wii Remote controller data, the Classic Controller and Nunchuk controller data can also be retrieved. It is also now possible to get 3D attitude information of the Wii remote from Wii MotionPlus information by passing a dedicated work area to the KPAD library. 21</p> 22 23 24<p> 25A sample program for testing KPAD library features is in <code>$(REVOLUTION_SDK_ROOT)/build/demos/kpaddemo/</code>. When using these samples, we recommend placing the Wii Remote and the Sensor Bar at least 1.5 meters apart (the samples may not function well at a distance of 1.0 meter). 26</p> 27 28<p> 29The KPAD library is in the following path. 30</p> 31<ul> 32<li><CODE>$(REVOLUTION_SDK_ROOT)/RVL/lib/kpad[D].a </CODE> 33</ul> 34 35<p> 36Function declarations are in the <code>$(REVOLUTION_SDK_ROOT)/include/revolution/kpad.h</code> header file. 37</p> 38 39<h2>How to Use the WPAD Library from the KPAD Library</h2> 40<h3>Controller Data Sampling</h3> 41<p> 42Use the <a href="../wpad/WPADSetSamplingCallback.html"><CODE>WPADSetSamplingCallback</CODE></a> function to configure the sampling callback inside the KPAD Library. When this is done, the application cannot call the <a href="../wpad/WPADSetSamplingCallback.html"><CODE>WPADSetSamplingCallback</CODE></a> function. In its place, use the <a href="KPADSetSamplingCallback.html"><CODE>KPADSetSamplingCallback</CODE></a> function to set a user callback that is called from the sampling callback inside the KPAD library. 43</p> 44<p> 45Note that the callback registered through this function will not be released unless you either specify <CODE>NULL</CODE> as an argument to this function or call the <a href="./KPADShutdown.html"><code>KPADShutdown</code></a> function. Connecting or disconnecting a controller will not release the callback. 46</p> 47 48<h3>Connecting and Disconnecting a Controller</h3> 49<p> 50Because the <a href="../wpad/WPADSetConnectCallback.html"><code>WPADSetConnectCallback</code></a> function sets a callback inside the KPAD library, the application cannot call the <a href="../wpad/WPADSetConnectCallback.html"><code>WPADSetConnectCallback</code></a> function. The <a href="../wpad/WPADSetConnectCallback.html"><CODE>WPADSetConnectCallback</CODE></a> function can be used as usual when the KPAD library is not in use. Also, the callback function registered before the call to <a href="./KPADInit.html"><CODE>KPADInit</CODE></a> is now maintained within the KPAD library and is called when connecting or disconnecting. When the KPAD library is being used, use the <a href="./KPADSetConnectCallback.html"><CODE>KPADSetConnectCallback</CODE></a> function to register callbacks. 51</p> 52<p> 53Although callbacks registered by this function are released when <CODE>NULL</CODE> is given as the function argument or when the <a href="./KPADShutdown.html"><code>KPADShutdown</code></a> function is called, these actions do not clear callbacks that were registered before the use of the KPAD library. 54</P> 55<p> 56Check the connection status using the value returned by the <a href="../wpad/WPADProbe.html"><code>WPADProbe</code></a> function or the <a href="./KPADReadEx.html"><code>KPADReadEx</code></a> function. 57</p> 58 59<h2>The KPAD Library Specifications</h2> 60<h3>Changes in the <a href="./KPADStatus.html">KPADStatus</a> and <a href="./KPADEXStatus.html">KPADEXStatus</a> Structures</h3> 61<p> 62The size and order of some members of the <a href="./KPADStatus.html"><CODE>KPADStatus</CODE></a> and <a href="./KPADEXStatus.html"><CODE>KPADEXStatus</CODE></a> structures have changed. If the application writes to the members of these structures, revise the source code to match the new definition. While some members have been added, the source code should require minimal changes if only referencing the preexisting structure members. 63</p> 64 65<h3><a href="./KPADReset.html">KPADReset</a> Function Operation</h3> 66<p> 67Stops the rumble motor immediately. Internal works will not be reset with certain exceptions. The actual reset process is performed the next time the <a href="./KPADRead.html"><CODE>KPADRead</CODE></a> or <a href="./KPADReadEx.html"><code>KPADReadEx</code></a> function is called. 68</p> 69 70<h3>Addition of the <a href="./KPADInitEx.html">KPADInitEx</a> Function and Its Recommended Uses</h3> 71<p> 72The KPAD library uses a ring buffer to store the Wii Remote input data used for the internal processing of each channel in turn. A buffer of length <code>KPAD_RING_BUFS</code> is maintained for this purpose. The contents of this ring buffer are flushed every time the <a href="./KPADRead.html"><code>KPADRead</code></a> or <a href="./KPADReadEx.html"><code>KPADReadEx</code></a> function is called. 73</p> 74<p> 75When the <a href="./KPADInit.html">KPADInit</a> function is used, it uses this maintained ring buffer, but the old input data in the ring buffer can be lost if the interval between flushes is too long. In such cases, the length of the ring buffer can now be extended using the <a href="./KPADInitEx.html"><CODE>KPADInitEx</CODE></a> function. Pass the additional buffer (an array of <code>KPADUnifiedWpadStatus</code> structures) and its size as arguments to the <a href="./KPADInitEx.html"><CODE>KPADInitEx</CODE></a> function. This buffer is internally divided into four parts, and each is assigned for processing of a different channel, so make sure the size you specify is a multiple of 4. If additional buffer length is not necessary, pass <code>NULL</code> and zero. 76</p> 77<p> 78We recommend that you use the <a href="./KPADInitEx.html"><CODE>KPADInitEx</CODE></a> function for future development of applications. 79</p> 80 81<h3>Addition of the <a href="./KPADReadEx.html">KPADReadEx</a> Function and Its Recommended Uses</h3> 82<p> 83The <a href="./KPADRead.html">KPADRead</a> function returns the number of sets of sampling data, or zero if there are none. The <a href="./KPADReadEx.html"><CODE>KPADReadEx</CODE></a> function also returns the error code in the variable pointer passed as an argument, in addition to the same types of values. The error codes are as follows: 84 85<table border="1" class="arguments"> 86 <tr> 87<th>KPAD_READ_ERR_NONE</th> 88<td>There is sampling data.</td> 89 </tr> 90 <tr> 91<th>KPAD_READ_ERR_NO_DATA</th> 92<td>No sampling data.</td> 93 </tr> 94 <tr> 95<th>KPAD_READ_ERR_NO_CONTROLLER</th> 96<td>The Wii Remote is not connected.</td> 97 </tr> 98 <tr> 99<th>KPAD_READ_ERR_SETUP</th> 100<td>WPAD library initialization is not complete.</td> 101 </tr> 102 <tr> 103<th>KPAD_READ_ERR_LOCKED</th> 104<td>Duplicate calls caused failure to obtain permission to process.</td> 105 </tr> 106 <tr> 107<th>KPAD_READ_ERR_INIT</th> 108<td>The <a href="./KPADInit.html"><CODE>KPADInit</CODE></a> function (or the <a href="./KPADInitEx.html"><CODE>KPADInitEx</CODE></a> function) has not been called.</td> 109 </tr> 110</table> 111<p> 112Even when the <a href="./KPADRead.html">KPADRead</a> function returns zero, there is a possibility that the contents of the sampling buffer passed to it as an argument have changed. There is also a chance that the <a href="./KPADReadEx.html"><CODE>KPADReadEx</CODE></a> function will change the sampling buffer's contents, but if and only if <code>KPAD_READ_ERR_NO_DATA</code> is returned, then the contents at the start of the sampling buffer have not changed. 113</p> 114<p> 115We recommend that you use the <a href="./KPADReadEx.html"><CODE>KPADReadEx</CODE></a> function for future development of applications. 116</p> 117 118<h3>Error Codes for the KPADStatus Structure</h3> 119<p> 120The <SPAN class="argument">err</SPAN> member value of the <code>WPADStatus</code> structure that is obtained from the <a href="../wpad/WPADRead.html"><code>WPADRead</code></a> function will be copied into the <SPAN class="argument">wpad_err</SPAN> member of the <code>KPADStatus</code> structure. The error code passed into this member variable indicates the state of data received from the Wii Remote, as follows. 121</p> 122 123<TABLE class="arguments" border="1" > 124 <tbody> 125 <tr> 126<th>WPAD_ERR_NONE</th> 127<td>Data with the specified data format was received.</td> 128 </tr> 129 <tr> 130<th>WPAD_ERR_NO_CONTROLLER</th> 131<td>Data has never been received.</td> 132 </tr> 133 <tr> 134<th>WPAD_ERR_INVALID</th> 135<td>The format of incoming data is different from the format specified for the WPAD library. Values other than <SPAN class="argument">err</SPAN> and <SPAN class="argument">dev</SPAN> are undefined.<br>(In this case, the data for the Wii Remote and external extension controllers is invalid.)</td> 136 </tr> 137 <tr> 138<th>WPAD_ERR_CORRUPTED</th> 139<td>An external extension controller such as the Nunchuk or Classic Controller is partially inserted into the Wii Remote, and the data for the external extension controller is corrupted.<br>(However, in this case Wii Remote data has not been corrupted.)</td> 140 </tr> 141 </tbody> 142</table> 143 144<p> 145To get the Wii Remote status, use the <a href="../wpad/WPADProbe.html"><code>WPADProbe</code></a> function in the WPAD library. The error codes returned from the <a href="../wpad/WPADProbe.html"><code>WPADProbe</code></a> function are shown below, along with their descriptions. <font color="red"><B>Note:</B> You can also use the <a href="./KPADReadEx.html"><code>KPADReadEx</code></a> function to check if a Wii Remote is connected.</font> 146</p> 147<TABLE class="arguments" border="1" > 148 <tbody> 149 <tr> 150<th>WPAD_ERR_NONE</th> 151<td>The Wii Remote is connected, and control commands are not being sent from the Wii console to the Wii Remote.</td> 152 </tr> 153 <tr> 154<th>WPAD_ERR_NO_CONTROLLER</th> 155<td>The Wii Remote is disconnected.</td> 156 </tr> 157 <tr> 158<th>WPAD_ERR_BUSY</th> 159<td>A control command has been sent to a connected Wii Remote, and the system is waiting for an ACK from the Wii Remote.</td> 160 </tr> 161 </tbody> 162</table> 163 164<p><font color="red">The error code that can be obtained by the <a href="../wpad/WPADProbe.html"><code>WPADProbe</code></a> function and the error code passed to the <code>WPADStatus</code> structure's <span class="argument">err</span> member each have different meanings. Be aware that they are not synchronized.</font> 165</p> 166 167<h3>Multiple Calls to the KPADRead or KPADReadEx Functions</h3> 168<p> 169When the <a href="./KPADRead.html">KPADRead</a> or <a href="./KPADReadEx.html">KPADReadEx</a> functions are called, the ring buffer inside the KPAD library is flushed. For this reason, if data will be used by multiple threads, we recommend that you use a single thread and share the loaded data, rather than calling functions from multiple threads. 170</p> 171<p> 172When the functions are called multiple times, they will return zero when they fail to gain processing rights. The <a href="./KPADReadEx.html"><CODE>KPADReadEx</CODE></a> function will also return the error code <code>KPAD_READ_ERR_LOCKED</code>. 173</p> 174 175<h3>Clamp Processing for the Stick</h3> 176<p> 177Implemented as circular clamping as well as cross-shape clamping. Circular clamping is used by default. Select it through the <a href="./KPADEnableStickCrossClamp.html">KPADEnableStickCrossClamp</CODE></a> and <a href="./KPADDisableStickCrossClamp.html"><CODE>KPADDisableStickCrossClamp</CODE></a> functions. 178</p> 179 180<h3>Regarding Data Loss</h3> 181<p> 182The <a href="./KPADRead.html"><CODE>KPADRead</CODE></a> and <a href="./KPADReadEx.html"><CODE>KPADReadEx</CODE></a> functions are designed with the assumption that they will be called once every game frame. However, if the interval between calls to these functions grows too long due to a processing slowdown or some other reason, the KPAD library's internal ring buffer might go full circle, and data could be lost.<br><br> 183 184Conditions can sometimes be improved by increasing the ring buffer that is passed to the <a href="./KPADInitEx.html"><code>KPADInitEx</code></a> function. 185</p> 186 187<h2>Process Flow</h2> 188<h3>KPAD Initialization</h3> 189<p> 190The KPAD library is initialized by calling either the <a href="./KPADInit.html"><CODE>KPADInit</CODE></a> function or the <a href="./KPADInitEx.html"><code>KPADInitEx</code></a> function. Call the <a href="../wpad/WPADRegisterAllocator.html"><CODE>WPADRegisterAllocator</CODE></a> function to register the memory allocator function for getting and deallocating memory with the WPAD library before calling these functions because they invoke the <a href="../wpad/WPADInit.html"><CODE>WPADInit</CODE></a> function internally. After this, the KPAD library uses the WPAD library's <font color="#ff0000">sampling callback</font> to get data and the KPAD library's internal buffer is updated. 191</p> 192 193<h3>Getting Controller Information</h3> 194<p> 195To load the specified channel's controller information into the <a href="./KPADStatus.html"><CODE>KPADStatus</CODE></a> structure, use the <a href="./KPADRead.html"><CODE>KPADRead</CODE></a> or <a href="./KPADReadEx.html"><CODE>KPADReadEx</CODE></a> function. The controller information to be read may be adjusted by calling the following functions beforehand. 196</p> 197 198<ul> 199<li>When adjusting the sharpness of the Wii Remote response and the hand tremor reduction level, use the <a href="./KPADSetPosParam.html"><CODE>KPADSetPosParam</CODE></a>, <a href="./KPADSetHoriParam.html"><CODE>KPADSetHoriParam</CODE></a>, <a href="./KPADSetDistParam.html"><CODE>KPADSetDistParam</CODE></a>, and <a href="./KPADSetAccParam.html"><CODE>KPADSetAccParam</CODE></a> functions. 200<li>The digital button repeat may be adjusted through the <a href="./KPADSetBtnRepeat.html"><CODE>KPADSetBtnRepeat</CODE></a> function. 201<li>Use the <a href="./KPADSetSensorHeight.html"><CODE>KPADSetSensorHeight</CODE></a>, <a href="./KPADEnableAimingMode.html"><CODE>KPADEnableAimingMode</CODE></a>, and <a href="./KPADDisableAimingMode.html"><CODE>KPADDisableAimingMode</CODE></a> functions to adjust the feature used to correct the screen coordinates to which the Wii Remote points. The coordinate correction feature is enabled by default. </font>The <a href="./KPADEnableAimingMode.html"><CODE>KPADEnableAimingMode</CODE></a> function is automatically called from the <a href="KPADInit.html"><CODE>KPADInit</CODE></a> function. 202<li>The clamp processing of the Nunchuk and Classic Controller sticks are adjusted through the<a href="./KPADEnableStickCrossClamp.html"><CODE>KPADEnableStickCrossClamp</CODE></a> and <a href="./KPADDisableStickCrossClamp.html"><CODE>KPADDisableStickCrossClamp</CODE></a> functions. 203</ul> 204 205<h3>Other</h3> 206<p> 207In some cases, it might be effective to call the <a href="./KPADReset.html"><CODE>KPADReset</CODE></a> function, such as during a change in scenes. However, because the <a href="./KPADReset.html"><CODE>KPADReset</CODE></a> function will have an ill effect on button trigger processing, <font color="#ff0000">avoid calling the function where possible</font>. It does not also need to be called when swapping external extension controllers. 208</p> 209 210<h2>Notes</h2> 211<h3>Differences in Coordinate Systems</h3> 212<p> 213The coordinate system of the coordinates obtained with the KPAD library is different from that used in the WPAD library. For details, see the <a href="./KPADStatus.html"><CODE>KPADStatus</CODE></a> and <a href="./KPADEXStatus.html"><CODE>KPADEXStatus</CODE></a> structure pages. 214</p> 215 216<h3>Effects of Signal Interference</h3> 217<p> 218Because the Wii console and Wii Remote use wireless communication, poor signal conditions in the surrounding area can cause signal interference, and the Wii console may not be able to receive data from the Wii Remote. If these conditions persist, the <a href="./KPADRead.html"><code>KPADRead</code></a> function may return zero. Even in these circumstances the Wii console and Wii Remote maintain their connection status, so <font color="red">do not judge their connection status from the return value of this function</font>. To judge connection status, use the <a href="../wpad/WPADProbe.html"><code>WPADProbe</code></a> or <a href="../wpad/WPADSetConnectCallback.html"><code>WPADSetConnectCallback</code></a> function. It is also possible to use the return value of the <a href="./KPADReadEx.html"><code>KPADReadEx</code></a> function. <CODE>KPAD_READ_ERR_NO_DATA</code> is used as the return value when data cannot be received. <CODE>KPAD_READ_ERR_NO_CONTROLLER</code> is used as the return value when not connected. 219</p> 220 221<h2>Wii MotionPlus</h2> 222<h3>Overview</h3> 223<p> 224The sensors used in the Wii MotionPlus are rate sensors (gyroscopes). These rate sensors can get the angular velocity around the axes for pitch, yaw, and roll. The values for each axis are stored in the <a href="./KPADMPStatus.html"><CODE>KPADMPStatus</CODE></a> structure and obtained with the <a href="./KPADRead.html"><CODE>KPADRead</CODE></a> function. The <A><CODE>KPADMPStatus</CODE></A> structure has the members <code>mpls</code>, <code>angle</code>, and <code>dir</code>. The first two are defined as type <code>Vec</code>. The </code>Vec</code> type direction components are as follows: <SPAN class="argument">x</SPAN> is the pitch, <SPAN class="argument">y</SPAN> is the yaw, and <SPAN class="argument">z</SPAN> is the roll. The <code>mpls</code> member represents the angular velocity in each direction and stores a value where 1.0 corresponds to 360 dps (degrees per second). The <CODE>angle</CODE> member represents the angle in each direction and stores a value where 1.0 corresponds to 360 degrees. The <code>dir</code> member represents the 3D attitude expressed as a 3x3 matrix. 225</p> 226<p> 227See the WPAD library <a href="../wpad/intro.html">Introduction</a> for more detailed information on the Wii MotionPlus. 228</p> 229<h3>Starting and Stopping the Wii MotionPlus</h3> 230<p> 231The Wii MotionPlus does not start immediately after it is plugged into the Wii Remote. Start the Wii MotionPlus by sending it the start command. Start and stop the Wii MotionPlus using the <a href="./KPADEnableMpls.html"><code>KPADEnableMpls</code></a> and <a href="./KPADDisableMpls.html"><code>KPADDisableMpls</code></a> functions, respectively. When these functions are called, the KPAD library checks the device's current state against the specified state and operates to bring about the specified state. If the state is not the specified state (for example, the Wii MotionPlus is not attached), then <font color="red">the function continues to send a startup command until the specified state comes into being.</font> In addition, if you register a callback ahead of time using the <a href="./KPADSetControlMplsCallback.html"><code>KPADSetControlMplsCallback</code></a> function, the following notfications are used: <code>KPAD_STATE_CTRL_MPLS_START</code> is sent when processing to start or stop the Wii MotionPlus is started, and <code>KPAD_STATE_CTRL_MPLS_FINISHED</code> is sent when processing is finished. If an error occurs during processing, a <code>KPAD_STATE_CTRL_MPLS_FAILED_STD</code>, <code>KPAD_STATE_CTRL_MPLS_FAILED_FS</code>, or <code>KPAD_STATE_CTRL_FAILED_CL</code> notification is sent, depending on the state passed to the <a href="./KPADEnableMpls.html"><code>KPADEnableMpls</code></a> function. In addition to registering callbacks, you can also directly check the state of the Wii MotionPlus using the <a href="./KPADGetMplsStatus.html"><code>KPADGetMplsStatus</code></a> function. 232</p> 233<p> 234For example, suppose you pass <code>WPAD_MPLS_FS</code> to the <a href="./KPADEnableMpls.html"><code>KPADEnableMpls</code></a> function and call it while the Wii MotionPlus is running in normal mode. A <code>KPAD_STATE_CTRL_MPLS_START</code> notification is issued, and a Wii MotionPlus mode change is initiated because the current state (<CODE>WPAD_MPLS_STD</CODE>) differs from the specified state (<CODE>WPAD_MPLS_FS</CODE>). Because the Wii MotionPlus must be temporarily stopped when switching between normal mode and extension mode, the KPAD library first stops the Wii MotionPlus. Note that the device type obtained by the <a href="../wpad/WPADProbe.html"><code>WPADProbe</code></a> function at this point is <code>WPAD_DEV_CORE</code>. Once the Wii MotionPlus has stopped, the Wii MotionPlus can be started in extension mode. Unless the state specified in the <a href="./KPADEnableMpls.html"><code>KPADEnableMpls</code></a> or <a href="./KPADDisableMpls.html"><code>KPADDisableMpls</code></a> function is changed, the KPAD library performs this entire series of operations. 235</p> 236 237<h3>Wii MotionPlus Startup and the Wii Remote Speaker</h3> 238<p> 239To output audio from the Wii Remote speaker, audio output commands are sent to the Wii Remote. This process can be affected by processes sending other commands. This does not happen except when commands are being sent frequently. Note that because the <a href="./KPADEnableMpls.html"><code>KPADEnableMpls</code></a> function sends the startup command to the Wii MotionPlus until a specified condition is met, the Wii Remote speaker cannot output audio if the Wii MotionPlus is detached while this function is called. 240</p> 241 242<h3>HOME Menu</h3> 243<p> 244In some cases the Home Menu outputs audio from the Wii Remote speaker. If the Home Menu is started and the Wii MotionPlus is detached while the <CODE>KPADEnableMpls</CODE> function is called, the Wii Remote speaker cannot output audio. 245 246You can avoid this problem by stopping the Wii MotionPlus when the Home Menu is started. 247</p> 248 249<h3>Work Area for Wii MotionPlus Data Processing</h3> 250<p> 251A dedicated work area is required for the KPAD library to process Wii MotionPlus data. Be sure to first set the work area using the <a href="./KPADSetMplsWorkarea.html"><code>KPADSetMplsWorkarea</code></a> function if the KPAD library will be processing data. To get the amount of memory making up the work area, use the <a href="./KPADGetMplsWorkSize.html"><code>KPADGetMplsWorkSize</code></a> function. 252</p> 253<p> 254To deallocate the work area specified by the <a href="./KPADSetMplsWorkarea.html"><code>KPADSetMplsWorkarea</code></a> function, pass <code>NULL</code> to the function. Memory is destroyed if the work area is deallocated while even one Wii MotionPlus is operating, so do not deallocate the work area at such times. Before deallocation, verify that Wii MotionPlus is not operating on any Wii Remote. 255</p> 256 257<h3>Wii MotionPlus Calibration Settings</h3> 258<p> 259The Wii MotionPlus hardware maintains calibration values set during a constant-speed rotation and calibration values set at the zero point. However, it is necessary to reset the zero point as quickly as possible after startup because there is a possibility that the zero point after actual startup may differ from the calibrated value. The KPAD library therefore starts the calibration process after the Wii MotionPlus starts. The calibration process completes by momentarily stilling all motion of the Wii MotionPlus. Note that the calibration process does not complete if you keep moving the Wii MotionPlus. 260</p> 261<p> 262<font color="red">We strongly recommend that you use Wii MotionPlus information after the calibration process completes.</font> 263</p> 264<p> 265The calibration process can be started at any time using the <a href="./KPADStartMplsCalibration.html"><code>KPADStartMplsCalibration</code></a> function. 266</p> 267 268<h3>Getting Wii MotionPlus Data</h3> 269<p> 270Using the <a href="./KPADRead.html"><CODE>KPADRead</CODE></a> function, the specified channel's Wii MotionPlus status is read into a <a href="./KPADStatus.html"><code>KPADMPStatus</code></a> structure, a member of the <a href="./KPADStatus.html"><code>KPADStatus</code></a> structure. The <a href="./KPADRead.html"><CODE>KPADRead</CODE></a> function processes the <a href="../wpad/WPADStatus.html"><code>WPADMPStatus</code></a> structure in the order received and updates each member of the <a href="../wpad/WPADStatus.html"><code>WPADMPStatus</code></a> structure. Please note that attitude correction using acceleration and DPD is performed only on the latest status. 271</p> 272 273<h3>Correction Processing</h3> 274<p> 275The KPAD library can perform the following corrections on Wii MotionPlus data. 276</p> 277<ul> 278<li>Play tolerance settings around the zero point</li> 279<li>Zero-Point Drift Correction</li> 280<li>Attitude Correction for the Base Attitude</li> 281<li>Attitude Correction Using Acceleration</li> 282<li>Attitude Correction Using the DPD</li> 283</ul> 284<p> 285Excluding zero-point drift correction, these correction processes can each be freely enabled or disabled. (Zero-point drift correction is always enabled.) Parameters can be used to adjust the degree of drift correction. 286</p> 287<h3>Zero-Point Play Tolerance</h3> 288<p> 289If this feature is enabled, the system does not respond to small movements. This feature is effective in situations, for example, where you want to capture only large movements in a particular direction. Specifically, there is no response to motion smaller than <code>radius</code>, specified by the <a href="./KPADSetMplsZeroPlayParam.html"><code>KPADSetMplsZeroPlayParam</code></a> function. The closer the current angular velocity is to the specified <code>radius</code>, the closer to zero the return value of the <a href="./KPADIsEnableMplsZeroPlay.html"><code>KPADIsEnableMplsZeroPlay</code></a> function becomes. 290</p> 291<h3>Zero-Point Drift Correction</h3> 292<p> 293The zero point may drift due to effects such as temperature while the Wii MotionPlus is in use. This correction process works by first determining whether the Wii MotionPlus is stationary. This is done by checking whether the Wii MotionPlus continues to return the same value for some interval of time. If the device is deemed to be stationary, the zero point is corrected to reflect the value. Also, three types of determination criteria have been prepared. Any one of these may be applied. The zero point is constantly corrected based on information such as how well current acceleration and past angular acceleration being buffered internally fit in the specified determination criteria. Get information regarding how well data fits from the return value of the <a href="./KPADIsEnableMplsZeroDrift.html"><code>KPADIsEnableMplsZeroDrift</code></a> function. The closer the value is to 1, the better the fit. You can also assume that the closer to 1, the more stable the motion. 294</p> 295<p> 296<B>Note:</B> Because this type of processing is performed, <font color="red">this correction may also be performed unintentionally during constant, uniform motion.</font> Be sure to consider this issue in scenes that request precise movements from the player. In such scenes, this issue can be addressed either by making stricter determination criteria or by setting up a play tolerance around the zero point. 297</p> 298<h3>Attitude Correction for the Base Attitude</h3> 299<p> 300By configuring a certain attitude as the base attitude, even vigorous swinging that cannot be handled by other correction processing stops causing the attitude to shift very far from the base attitude. For example, this correction can be used when swinging a sword to set the <I>ready stance</I> as the base attitude. 301</p> 302<h3>Attitude Correction Using Acceleration</h3> 303<p> 304When this compensation is enabled, correction is applied using an acceleration value in cases where the acceleration obtained from the accelerometer fits inside the range given by the force of gravity plus <code>revise_range</code>, specified by the <a href="./KPADSetMplsAccReviseParam.html"><code>KPADSetMplsAccReviseParam</code></a> function. 305</p> 306<h3>Attitude Correction Using the DPD</h3> 307<p> 308If you enable this feature, correction processing is applied whenever the DPD detects and maintains sight of an object. Although this feature can apply precise corrections for the yaw and roll axes, corrections cannot be applied to the pitch axis because the position of the sensor bar differs by environment. 309</p> 310<h2>Temperature Drift and Integration Error</h2> 311<p> 312You can expect some degree of improvement in temperature drift when using the zero-point drift correction process. In addition, you should be able to mitigate drift to a certain degree by: correcting acceleration and DPD before the error becomes too large, and setting the base model beforehand for scenes in which motions are so small that these corrections are not triggered. 313</p> 314<h3>Calibration Value Errors</h3> 315<p> 316As stated in the specifications for Wii MotionPlus rate sensors, the scale value for the written calibration values can vary by as much as ±8 percent due to the effects of humidity, air temperature, and device age. This error cannot be mitigated by the KPAD library. When designing for the Wii MotionPlus, therefore, do not attempt to require an exact degree of accuracy. 317</p> 318<p> 319When the <a href="./KPADSetMplsMagnification.html"><code>KPADSetMplsMagnification</code></a> function operates internally to calculate angular speed, you can set a different scaling factor for each direction of motion. Because you can use this function to evaluate the impact that these errors in attitude and angle will actually have on calculations, use it when verifying that your game can be played within the range of error. 320</p> 321 322<h2>Classic Controller and Classic Controller Pro</h2> 323<p> 324The Classic Controller and the Classic Controller Pro have different shapes for the left and right analog buttons. The quantity of analog input also differs. However, the Classic Controller Pro is recognized as a regular Classic Controller when it is attached to the Wii remote, so applications cannot distinguish between the two. 325</p> 326<p> 327<font color="red">For this reason, from SDK 3.3 on, LR analog button input is not allowed and always returns zero.</font>Also, it is harder to send input from the LR buttons of the Classic Controller than from the Classic Controller Pro because the buttons must be pressed down. Now, even pressing the LR buttons a little is recognized as button input. 328</p> 329 330<H2>Revision History</H2> 331<P> 3322009/12/02 Revised the explanation of the Home Menu.<br>2009/10/21 Deleted the text regarding <code>KPADOld</code>. Explained Wii MotionPlus startup with respect to the Wii Remote speaker and Home Menu.<br>2009/06/23 Added an explanation about the Classic Controller and the Classic Controller Pro.<br>2009/01/30 Added a description of the <a href="./KPADReset.html"><code>KPADReset</code></a> function.<br> 2009/01/22 Explained the margin of error for Wii MotionPlus calibration values.<br> 2009/01/16 Explained the conditions for deallocating the work area used by Wii MotionPlus for data processing.<br>2009/01/07 Revised the description of signal interference.<br> 2008/12/04 Added a comprehensive description for the Wii MotionPlus.<br> 2008/10/01 Explained the Wii MotionPlus.<br>2008/06/05 Deleted a description of the <code>KPADSetObjInterval</code> function.<br>2008/06/03 Added an explanation for the <a href="./KPADReadEx.html"><code>KPADReadEx</code></a> function.<br>2008/05/29 Added explanations for the <a href="./KPADInitEx.html"><code>KPADInitEx</code></a> function.<br>2008/04/17 Mentioned that the Wii Balance Board is now supported. Revised differences with KPADOld.<br> 2007/08/27 Added a "Notes" item about the effects of signal interference.<BR>2007/01/15 Revised such that the coordinate correction feature is enabled by default. As a result, revised the demo.<br> 333 334Fixed the following bug: the button repeat interval would increase if the maximum number of stored data items passed to the <a href="./KPADRead.html"><CODE>KPADRead</CODE></a> function was smaller than <code>KPAD_MAX_READ_BUFS</code>.<br> 335 336Corrected errors in the manuals of the <a href="./KPADEnableStickCrossClamp.html"><CODE>KPADEnableStickCrossClamp</CODE></a> and <a href="./KPADDisableStickCrossClamp.html"><CODE>KPADDisableStickCrossClamp</CODE></a> functions. <br>2006/10/25 Revised the description to match KPAD version 2.<br>2006/06/19 Support for UI Tool version 4. Changed tentative product name to official name.<br>2006/05/15 Added to <B>Notes</B> methods to avoid loss of data when the intervals between calls of the <a href="./KPADRead.html"><CODE>KPADRead</CODE></a> function become too long.<br>2006/03/01 Initial version. 337</P> 338 339<hr><p>CONFIDENTIAL</p></body> 340</html> 341