1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3<head>
4<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
5<meta name="ProgId" content="FrontPage.Editor.Document">
6<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css">
8<base target="main">
9<title>WPAD API Introduction</title>
10</head>
11
12<body>
13
14<h1>WPAD API</h1>
15
16<h2>Introduction</h2>
17<p>
18The Wii console communicates with its standard controller, the Wii Remote, using wireless technology in the 2.4 GHz band. The Wii Remote includes a Rumble motor, Pointer, Motion Sensor, speaker, Player Indicator, and external extension connector. When external extension controllers are connected to the external extension connector, a variety of user interfaces become available.
19</p>
20<p>
21The Wii Balance Board communicates with the Wii console using the 2.4 GHz wireless band in the same manner as the Wii Remote. However, the Wii Balance Board does not have parts such as the Rumble motor, Pointer, Motion Sensor, speaker, or external extension connector. Instead, it has pressure sensors specialized for measuring weight and center of gravity placed on each of its four corners.
22</p>
23
24<h2>Libraries</h2>
25<ul><li>Library Organization</li></ul>
26<blockquote>
27The WPAD library, which includes a higher-level library (KPAD), is implemented as follows. The WBC library is a high-level WPAD library that calculates weight from the values obtained by the WPAD library for the Wii Balance Board's pressure sensors. The KPAD library is a high-level WPAD library designed to make it easier for games to use input data obtained from the WPAD library. The KPAD library can handle weight data if the WBC library has been linked.
28
29<table border="0" width="200">
30  <tbody>
31	<tr height="25">
32	  <td colspan="2" align="center" bgcolor="khaki">KPAD API</td>
33	</tr>
34	<tr height="25">
35	  <td align="center" bgcolor="palegreen">WPAD API</td><td align="center" bgcolor="lightblue" width="50%">WBC API</td>
36	</tr>
37	<tr height="25">
38	  <td colspan="2" align="center" bgcolor="palegreen">WPAD API</td>
39	</tr>
40  </tbody>
41</table>
42</blockquote>
43
44<ul><li>Relationship Between the Library and External Extension Controllers</li></ul>
45<blockquote>
46The WPAD library detects the Nunchuk and Classic Controller by default. The WPAD library can detect other external extension controllers and the Wii Balance Board if a special library is linked for each device. If these special libraries are not linked, whenever an external extension controller is connected, it is recognized as <code>WPAD_DEV_FUTURE</code>. A Wii Balance Board cannot be connected if the WBC library is not linked.<br><br>
47
48Shown below are controllers and the libraries required for the WPAD library to detect them.
49<table class="arguments" border="1">
50  <tbody>
51	<tr>
52	  <th>WPAD_DEV_BALANCE_CHECKER</th>
53<td>WBC library</td>
54	</tr>
55	<tr>
56	  <th>WPAD_DEV_GUITAR</th>
57<td>WPADGtr library</td>
58	</tr>
59	<tr>
60	  <th>WPAD_DEV_DRUM</th>
61<td>WPADDrm library</td>
62	</tr>
63	<tr>
64	  <th>WPAD_DEV_TAIKO</th>
65<td>WPADTko library</td>
66	</tr>
67	<tr>
68	  <th>WPAD_DEV_TRAIN</th>
69<td>WPADTrn library</td>
70	</tr>
71	<tr>
72	  <th>WPAD_DEV_TAIKO</th>
73<td>WPADTko library</td>
74	</tr>
75  </tbody>
76</table>
77
78<font color="red"><b> Libraries other than <code>WBC</code> are not included with the standard Revolution SDK. Developers who require these libraries should contact Nintendo.</b></font>
79</blockquote>
80
81<h2>Initialization</h2>
82<h3>Registering Work Memory</h3>
83<p>
84Begin initialization of the WPAD library by calling the <a href="./WPADRegisterAllocator.html"><code>WPADRegisterAllocator</code></a> function; this registers the allocator function used to obtain work memory during initialization. Be sure to implement the allocator in such a way that work memory can be acquired from MEM2. To retrieve the total size of work memory allocated by the library, use the <a href="WPADGetWorkMemorySize.html"><code>WPADGetWorkMemorySize</code></a> function.
85</p>
86<h3>Notes on Initializing Wii Balance Board-Compatible Applications</h3>
87<p>
88Wii Balance Board registration data could not be saved to the console while the Japanese version of Wii Fit was under development, so it is saved with Wii Fit's save data. Consequently, <font color="red">Japanese applications that use the Wii Balance Board</font> should use the <a href="./WPADRegisterBLCWorkarea.html"><code>WPADRegisterBLCWorkarea</code></a> function to register a buffer for the library to get Wii Balance Board registration data from the Wii Fit save data. There is no need for applications to register the buffer in regions outside Japan because Wii Balance Board registration data can now be saved to the console.
89</p>
90<h3>Library Initialization</h3>
91<p>
92After registering the work memory, call the <a href="WPADInit.html"><code>WPADInit</code></a> function to initialize the WPAD library. Because it takes time to initialize the WPAD library, periodically call the <a href="./WPADGetStatus.html"><code>WPADGetStatus</code></a> function to check when initialization is complete. After initialization is complete, the buffer registered by the <a href="./WPADRegisterBLCWorkarea.html"><code>WPADRegisterBLCWorkarea</code></a> function is not used and may be deleted.
93</p>
94
95<h2>Registering and Removing Devices</h2>
96<p>
97For devices to communicate with the Wii console, both the Wii console and the device must first be registered with each other. This registration process is called <I>pairing</I>. The Wii console and the device can each register only a fixed number of corresponding devices or consoles. If more than this number are paired to either one, information for those already paired are overwritten. In addition, all pairing information maintained by the Wii console is automatically deleted if the SYNC button on the Wii console is pressed for 10 or more seconds. (However, this information is not automatically deleted if a callback has been registered using the <a href="./WPADSetClearDeviceCallback.html"><code>WPADSetClearDeviceCallback</code></a> function.) Note that doing so does not delete the pairing information maintained by the Wii Remote.
98</p>
99<h3>Adding and Removing Wii Remotes</h3>
100<p>
101There are two methods of registering Wii Remotes with a Wii console: normal pairing and simple pairing. The pairing information of a normal-paired Wii Remote remains registered even after the Wii console power has been turned OFF, and with a normal-paired Wii Remote, Wii console power can also be turned ON or OFF using the Wii Remote Power Button. However, if the Wii Remote has been simple-paired and the Wii console is reset or turned OFF, the pairing information maintained by the Wii console is deleted. Also, power to the Wii console cannot be turned ON or OFF using the power button on a simple-paired Wii Remote. The reason for this is that normal pairing is intended to be used when a user pairs their own Wii Remote to their own Wii console, but simple pairing is intended to be used when a user pairs their Wii Remote to a Wii console owned by a friend.
102</p>
103<p>
104<font color="red"><B>Note:</B> The specification for simple pairing has been changed. The pairing information for a simple-paired Wii Remote is now maintained until the Wii console power is turned OFF.</font>As a result, simple-paired Wii Remotes can remain connected to Wii even when applications are reset and when the user moves between Wii Menu and various Wii Channels. <font color="red"><b>However, applications built with SDK versions SDK2.4 patch6 or earlier use the old specification for simple pairing. Thus, when you move to one of these applications, the simple-paired Wii Remote's connection will be dropped. </b></font>Furthermore, if simple pairing is conducted while this kind of application is running, the connection will be dropped even if the process later moves to an application that uses the new specification for simple pairing.
105</p>
106
107<ul>
108<li><b>Paired device count</b></li>
109</ul>
110<blockquote>
111For Wii Remotes, a Wii console can store 10 normal pairings and 6 simple pairings. A single Wii Remote will be treated as paired through one of these two methods. For Wii consoles, a Wii Remote can store both one standard pairing and one simple pairing. A single Wii console will be treated as paired through one of these two methods.
112</blockquote>
113<blockquote>
114When a normal pairing is performed on a simple-paired device, that device is then treated as normal-paired. However, when a simple pairing is performed on a normal-paired device, that device continues to be treated as normal-paired.
115</blockquote>
116
117<ul>
118<li><b>Normal pairing</b></li>
119</ul>
120<blockquote>
121Normal pairing is performed by pressing SYNCHRO on the front of the Wii console, or by calling the <a href="./WPADStartSyncDevice.html"><code>WPADStartSyncDevice</code></a> or <a href="./WPADStartFastSyncDevice.html"><code>WPADStartFastSyncDevice</code></a> function and pressing SYNCHRO inside the battery cover of the Wii Remote. When the pairing completes, the Wii Remote information will be stored in the Wii console. In the same way, the Wii console information will be stored in the Wii Remote.
122</blockquote>
123<blockquote>
124By calling the <a href="WPADSetSyncDeviceCallback.html"><code>WPADSetSyncDeviceCallback</code></a> function and setting a user callback function in advance, game applications can determine when SYNCHRO on the Wii console is pressed. If a callback function has been set, pairing will not occur automatically when SYNCHRO is pressed; in such cases you must begin the pairing by calling the <a href="WPADStartSyncDevice.html"><code>WPADStartSyncDevice</code></a> function. The registered callback function will also be called again after pairing is complete, and it will send notification of how many Wii Remotes were successfully paired.
125</blockquote>
126
127<ul>
128<li><b>Simple pairing</b></li>
129</ul>
130<blockquote>
131The simple pairing remains effective only until the Wii console is shut down. Game applications can start a simple pairing by calling the <a href="./WPADStartSimpleSync.html"><code>WPADStartSimpleSync</code></a> or <a href="./WPADStartFastSimpleSync.html"><code>WPADStartFastSimpleSync</code></a> function. Simple pairing occurs when the Wii Remote 1 and 2 Buttons are pressed at the same time. However, if a Wii console is already registered, the Wii Remote will attempt to connect with that Wii console when the buttons are pressed. If that connection fails, simple pairing will start.</font><br><br>Simple pairing will be executed repeatedly until either four Wii Remotes have been connected, or the application stops the simple pairing by calling the <a href="./WPADStopSimpleSync.html"><code>WPADStopSimpleSync</code></a> function. If a callback is registered, the callback function is called as soon as the pairing process completes, and it sends notification of the number of paired Wii Remotes.
132</blockquote>
133
134<ul>
135<li><b>Attempting to pair different pairing types for the Wii console and Wii Remote</b></li>
136</ul>
137<blockquote>
138Pairing fails when the two devices attempt to perform fundamentally different pairing. However, it can be successful in the following cases:
139</blockquote>
140<blockquote>
141<ul>
142<li>When the Wii console is simple-pairing and the Wii Remote is normal-pairing, the existing pairing information will not be updated and the two will be connected as they are.</li>
143<li>When the Wii console is normal-pairing and the Wii Remote is simple-pairing, in some cases the Wii Remote becomes connected before it even begins to perform simple pairing.</li>
144</ul>
145</blockquote>
146
147<ul>
148<li><b>Repeatedly pairing an already-paired Wii Remote</b></li>
149</ul>
150<blockquote>
151<ul>
152<li>When a Wii console is already normal-paired to a Wii Remote and then attempts to perform simple pairing with that Remote, the pairing will succeed as normal pairing.</li>
153<li>When a Wii console is already simple-paired to a Wii Remote and then attempts to perform normal pairing with that Remote, the simple pairing is eliminated and replaced by a normal pairing.</li>
154</ul>
155</blockquote>
156
157<ul>
158<li><b>Deleting</b></li>
159</ul>
160<blockquote>
161If the Wii console's SYNC button is pressed for 10 or more seconds, all information on Wii Remotes paired to that Wii console is deleted. The game application can get this event by calling the <a href="WPADSetClearDeviceCallback.html"><code>WPADSetClearDeviceCallback</code></a> function and setting a user callback function in advance. When a callback function has been set, deletion of the pairing information will not occur automatically; in such cases you must start the deletion by calling the <a href="WPADStartClearDevice.html"><code>WPADStartClearDevice</code></a> function. The registered callback function will be called again when the deletion is complete. <br><br>Neither normal pairing nor simple pairing can be carried out while the Wii Remote's pairing information is being deleted.
162</blockquote>
163
164<h3>Adding and Removing Wii Balance Boards</h3>
165<p>
166The Wii Balance Board can use only normal pairing. While the Wii Balance Board is paired, up to nine Wii Remote pairings can be stored. Wii Balance Boards are paired, and their pairing information deleted, in the same manner as a Wii Remote.
167</p>
168<ul>
169<li><b>Synchronizing with the Japanese Version of Wii Fit</b></li>
170</ul>
171<blockquote>
172Although also mentioned in <B>Notes on Initializing Wii Balance Board-Compatible Applications</B>, the Japanese version of Wii Fit is the only application with a different way of handling pairing information for the Wii Balance Board. Although pairing information is usually stored in the Wii console's system configuration file, in the case of the Japanese version of Wii Fit, it is stored inside the Wii Fit save data because of circumstances surrounding development. Because the Wii Balance Board pairing information is also subsequently recorded in the Wii console's system configuration file, Wii Balance Board-compatible applications intended for Japan must synchronize the pairing information in Wii Fit save data with that in the system configuration file. This synchronization process is carried out internally by the library. Because a large work memory is required for the synchronization process during initialization, be sure to register a work memory using the <a href="./WPADRegisterBLCWorkarea.html"><code>WPADRegisterBLCWorkarea</code></a> function. The work memory is not required after initialization.
173</blockquote>
174<ul>
175<li><b>Synchronization Process During Pairing</b></li>
176</ul>
177<blockquote>
178When you pair a Wii Balance Board to a Wii console, the Wii Balance Board's pairing information is stored in the system configuration file. If save data for the Japanese version of Wii Fit is present on the Wii console, the pairing information is also stored in that save data.
179</blockquote>
180<ul>
181<li><b>Synchronization Process During Removal</b></li>
182</ul>
183<blockquote>
184Pairing information in the system configuration file is deleted by holding down the Wii console SYNC button for 10 or more seconds. If save data for the Japanese version of Wii Fit is present on the Wii console, its pairing information is deleted. However, because of Wii Fit specifications, pairing information is not completely deleted.
185</blockquote>
186
187
188<h2>Controller Power Button</h2>
189<p>
190A Wii console's power can be turned ON or OFF with the Wii Remote Power Button. If the console is currently turned OFF, it is turned ON by pressing the Power Button. If the console is currently turned ON, pressing the Power Button for approximately one second will send a power-OFF signal to the console, and the callback registered by the <a href="../os/Resetbutton/OSSetPowerCallback.html"><code>OSSetPowerCallback</code></a> function will be called.
191</p>
192<p>
193The power ON/OFF operation cannot be performed with a simple-paired Wii Remote, only with a normal-paired Remote.
194</p>
195
196<h2>Controller Status Confirmation</h2>
197<p>
198Game applications can call the <a href="./WPADProbe.html"><code>WPADProbe</code></a> function to get the connection status of each controller by its number. If an external extension controller is plugged into a Wii Remote, this function also returns the current type of the external extension controller. Because this function confirms the insertion and removal of an external extension controller, we recommend that the game application call this function at least once within the main loop. To determine if a controller has been connected or disconnected, use the <a href="./WPADSetConnectCallback.html"><code>WPADSetConnectCallback</code></a> function to register a callback function in advance. To detect the insertion and removal of an external extension controller, use the <a href="./WPADSetExtensionCallback.html"><code>WPADSetExtensionCallback</code></a> function to register a callback function in advance.
199</p>
200<p>
201When a Wii Remote which already has an external extension controller inserted is connected to a Wii console, the type of the external extension controller is not immediately known, because recognition of the external extension controller only occurs after the Wii Remote has completed its connection. Accordingly, the status obtained by the <a href="./WPADProbe.html"><code>WPADProbe</code></a> function changes over time. Immediately after the Wii Remote is connected, the function returns <code>WPAD_DEV_CORE</code>. After that, the Wii Remote notifies the console that it has an external extension controller attached, and the library checks the external extension controller's type. In the period between notification and verification of the controller's type, the function returns <code>WPAD_DEV_UNKNOWN</code>.  Following verification, the function returns a value such as <code>WPAD_DEV_FREESTYLE</code> or <code>WPAD_DEV_CLASSIC</code>, depending on the type.
202</p>
203<p>
204The <a href="./WPADGetInfo.html"><code>WPADGetInfo(Async)</code></a> function can also be called to get the current information about the controller (remaining battery power, Player LED status, and so on).
205</p>
206
207<h2>Controller Control</h2>
208<p>
209Game applications can perform a variety of controls on the Wii Remote, including changing the format of the received data, obtaining the status of a Remote, and starting and stopping the Pointer. However, these controls must wait for an ACK to be received from the Wii Remote, and must be processed exclusive of one another. Furthermore, when the ACK is returned only the Wii Remote's button information (out of all the controller information normally returned) is returned along with it. Be aware that if the Motion Sensor, Pointer, or an external extension controller is being used, it will not be possible to obtain their inputs.
210</p>
211<p>
212The WPAD library maintains separate command queues internally for each channel, and requests from the game application are managed by these queues. When the WPAD library cannot add a new request, <code>WPAD_ERR_BUSY</code> is returned; when this error is returned to the game application, the request should be issued again after waiting.
213</p>
214<p>
215Be aware that the WPAD library uses these queues internally immediately after attaching, detaching, or connecting an external extension controller.
216</p>
217
218<h2>Specifying the Received Data Format</h2>
219<p>
220The Wii Remote can use its buttons, Pointer, and Motion Sensor. In addition, external extension controller input can be used by attaching an external extension controller like the Nunchuk. However, because of the wireless specifications, not all of this data can be sent. Thus, the game application must call the <a href="./WPADSetDataFormat.html"><code>WPADSetDataFormat</code></a> function to select the format for the controller information according to its application. The following formats for controller information are available.
221</p>
222
223<TABLE class="arguments" border="1" >
224  <tbody>
225  <tr>
226<th>WPAD_FMT_CORE</th>
227<td>Wii Remote buttons only.</td>
228  </tr>
229  <tr>
230<th>WPAD_FMT_CORE_ACC</th>
231<td>Wii Remote buttons and Motion Sensor.</td>
232  </tr>
233  <tr>
234<th>WPAD_FMT_CORE_ACC_DPD</th>
235<td>Wii Remote buttons, Motion Sensor, and Pointer (coordinate data and size).</td>
236  </tr>
237  <tr>
238<th>WPAD_FMT_FREESTYLE</th>
239<td>Wii Remote buttons and the Nunchuk.</td>
240  </tr>
241  <tr>
242<th>WPAD_FMT_FREESTYLE_ACC</th>
243<td>Wii Remote buttons, Motion Sensor, and the Nunchuk.</td>
244  </tr>
245  <tr>
246<th>WPAD_FMT_FREESTYLE_ACC_DPD</th>
247<td>Wii Remote buttons, Motion Sensor, Pointer (coordinate data), and the Nunchuk.</td>
248  </tr>
249  <tr>
250<th>WPAD_FMT_CLASSIC</th>
251<td>Wii Remote buttons and the Classic Controller.</td>
252  </tr>
253  <tr>
254<th>WPAD_FMT_CLASSIC_ACC</th>
255<td>Wii Remote buttons, Motion Sensor, and the Classic Controller.</td>
256  </tr>
257  <tr>
258<th>WPAD_FMT_CLASSIC_ACC_DPD</th>
259<td>Wii Remote buttons, Motion Sensor, Pointer (coordinate data), and the Classic Controller.</td>
260  </tr>
261  <tr>
262<th>WPAD_FMT_CORE_ACC_DPD_FULL</th>
263<td>Wii Remote buttons, Motion Sensor, and Pointer (coordinate data, size, object radius, pixel value, and range).<font color="red"><B>Note:</B> The sampling rate is half of the rate for other formats.</font></td>
264  </tr>
265  <tr>
266<th>WPAD_FMT_TRAIN</th>
267<td>Wii Remote buttons and the Master Controller.</td>
268  </tr>
269  <tr>
270<th>WPAD_FMT_GUITAR</th>
271<td>Wii Remote buttons, Motion Sensor, Pointer (coordinate data), and Guitar Controller.</td>
272  </tr>
273  <tr>
274<th>WPAD_FMT_DRUM</th>
275<td>Wii Remote buttons, Motion Sensor, Pointer (coordinate data), and the Drum Controller.</td>
276  </tr>
277  <tr>
278<th>WPAD_FMT_TAIKO</th>
279<td>Wii Remote buttons, Motion Sensor, Pointer (coordinate data), and the Taiko Controller.</td>
280  </tr>
281  <tr>
282<th>WPAD_FMT_BALANCE_CHECKER</th>
283<td>Wii Balance Board.</td>
284  </tr>
285  <tr>
286<th>WPAD_FMT_MPLS</th>
287<td>Wii Remote buttons, Motion Sensor, Pointer (coordinate data), and Wii MotionPlus. <font color="red">Use this format when the format is MotionPlus Style, Nunchuk/MotionPlus Style, or Classic/MotionPlus Style. In addition, when using Nunchuk/MotionPlus Style or Classic/MotionPlus Style, the Wii MotionPlus sampling rate and the Nunchuk or Classic Controller sampling rate is half the normal rate.<b> Classic/MotionPlus Style is not supported by Wii MotionPlus PP2.</b></font></td>
288  </tr>
289  </tbody>
290</table>
291
292<p>
293<font color="red"><B>Note:</B> When selecting a format that uses the Pointer, before calling <a href="./WPADSetDataFormat.html"><code>WPADSetDataFormat</code></a>, call the <a href="./WPADControlDpd.html"><code>WPADControlDpd</code></a> function to start the Pointer.</font>
294</p>
295
296<h2>Getting Controller Information</h2>
297<p>
298There are two ways to obtain controller information.
299<ul>
300<li>Get only the most recent controller information.</li>
301</ul>
302<blockquote>
303Use the <a href="./WPADRead.html"><code>WPADRead</code></a> function to get the most recent controller information for the Wii Remote on the specified channel.
304</blockquote>
305
306<ul>
307<li>Periodically use auto-sampling to store the controller information to the buffer provided by the application.</li>
308</ul>
309<blockquote>
310To set the buffer for periodically storing controller information, use the <a href="./WPADSetAutoSamplingBuf.html"><code>WPADSetAutoSamplingBuf</code></a> function. Buffers are used internally as ring buffers. The buffer index that stored the most recent controller information can be obtained with the <a href="./WPADGetLatestIndexInBuf.html"><code>WPADGetLatestIndexInBuf</code></a> function.
311</blockquote>
312<p>
313The <a href="./WPADRead.html"><code>WPADRead</code></a> and <a href="./WPADSetAutoSamplingBuf.html"><code>WPADSetAutoSamplingBuf</code></a> functions can be used together.
314</p>
315<p>
316The type of the controller information that can be obtained with the <a href="./WPADRead.html"><code>WPADRead</code></a> and <a href="./WPADSetAutoSamplingBuf.html"><code>WPADSetAutoSamplingBuf</code></a> functions is recorded in a structure type that corresponds to the data format specified by the <a href="./WPADSetDataFormat.html"><code>WPADSetDataFormat</code></a> function. For information on controller types, data formats, and corresponding structure types, see the section about the <a href="./WPADSetDataFormat.html"><code>WPADSetDataFormat</code></a> function. If the data is recorded in a structure type that does not match the data format, it may not be possible to get valid data.
317</p>
318<p>
319Use the <a href="./WPADSetSamplingCallback.html"><code>WPADSetSamplingCallback</code></a> function to register the callback function called every time the data is received from a Wii Remote at a specified channel.
320</p>
321
322<h2>Processing +Control Pad Restrictions</h2>
323<p>
324Prohibition processing for the +Control Pads of the Wii Remote and the Classic Controller is performed internally by the WPAD library. If the +Control Pad physically breaks and its input is in a state that is ordinarily impossible, such as simultaneous presses of Left and Right, the library processes it as valid input of Left. Similarly, if Up and Down are simultaneously pressed, the library takes the valid input to be Up.
325</p>
326
327<h2>Attaching and Detaching External Extension Controllers</h2>
328<p>
329A variety of external extension controllers can be attached to the Wii Remote through the external extension connector, even while the Wii Remote is communicating. The game application can detect the insertion or removal of an external extension controller. It does this by polling with the <a href="./WPADProbe.html"><code>WPADProbe</code></a> function or by registering a callback function in advance using the <a href="./WPADSetExtensionCallback.html"><code>WPADSetExtensionCallback</code></a> function. Immediately after an External Extension Controller has been inserted in the Wii console, however, it is impossible to know what has been inserted. Therefore <code>WPAD_DEV_UNKNOWN</code> is used as the device type at the time of detection. Later, as soon as the type of External Extension Controller is known, the device type is updated (for example, <code>WPAD_DEV_FREESTYLE</code> or <code>WPAD_DEV_CLASSIC</code>). Also, if an external extension controller is inserted or removed during communications, the Wii Remote stops sending controller information. Therefore, when a plug insertion or removal is detected, use the <a href="./WPADSetDataFormat.html"><code>WPADSetDataFormat</code></a> function to reset the controller information's data format according to the situation. Once the settings are complete, controller information will be sent from the Wii Remote.
330</p>
331
332<h2>Rumble Feature Controls</h2>
333<p>
334The Rumble feature of the Wii Remote can be turned ON or OFF. The ON/OFF setting is stored internally within the library. When the library is initialized, the ON/OFF setting for the Rumble feature is set by default to the value in the console settings. When the Rumble feature is turned ON, the <a href="./WPADControlMotor.html"><code>WPADControlMotor</code></a> function can be used to control the vibration of the Wii Remote on a specified channel. In addition, the <a href="./WPADStartMotor.html"><code>WPADStartMotor</code></a> and <a href="./WPADStopMotor.html"><code>WPADStopMotor</code></a> functions are available as macro functions.
335</p>
336<p>
337The status of the Rumble feature's ON/OFF setting maintained within the library can be obtained with the <a href="./WPADIsMotorEnabled.html"><code>WPADIsMotorEnabled</code></a> function. Although the <a href="./WPADEnableMotor.html"><code>WPADEnableMotor</code></a> function can turn the Rumble feature ON or OFF, do not enable the Rumble Feature when it has been turned OFF in the console settings.
338
339The value maintained by the library can be saved to the console settings using the <a href="./WPADSaveConfig.html"><code>WPADSaveConfig</code></a> function, but do not call this function from an application.
340</p>
341
342<h2>Speaker Controls</h2>
343<ul>
344<li><b>Outputting Audio Through the Speaker</b></li>
345</ul>
346<blockquote>
347Use the <a href="./WPADControlSpeaker.html"><code>WPADControlSpeaker</code></a> function to control the speaker of the Wii Remote on the specified channel. Activate the speaker using the function <a href="./WPADControlSpeaker.html"><code>WPADControlSpeaker</code></a>. Once activated, audio can be output from the speaker by sending audio data using the <a href="./WPADSendStreamData.html"><code>WPADSendStreamData</code></a> function. Due to the audio specifications of the audio processor of the Wii Remote, 20 bytes of audio data must be sent three times every 20 ms in order to achieve correct audio playback.
348</blockquote>
349<ul>
350<li><b>Adjusting the Speaker Volume</b></li>
351</ul>
352<blockquote>
353To set the speaker volume of the Wii Remote on a specified channel, use the <a href="./WPADSetSpeakerVolume.html"><code>WPADSetSpeakerVolume</code></a> function. However, because this volume change is not enabled until the speaker is restarted with the <a href="./WPADControlSpeaker.html"><code>WPADControlSpeaker</code></a> function, the volume of the Wii Remote speaker's currently playing audio will not change. In order to alter the volume of the currently playing audio, change the volume of the audio data source. The volume configured using this function can be saved in the Wii console using the <a href="./WPADSaveConfig.html"><code>WPADSaveConfig</code></a> function.
354</blockquote>
355<ul>
356<li><b>Starting and Stopping the Speaker</b></li>
357</ul>
358<blockquote>
359In order to avoid wearing down the batteries in scenes where no audio is output through the Wii Remote speaker for a period of time, use the <a href="./WPADControlSpeaker.html"><code>WPADControlSpeaker</code></a> function to send the <code>WPAD_SPEAKER_OFF</code> command whenever possible to stop the speaker. However, starting or stopping the speaker will prevent you from being able to obtain several samples' worth of input from the Motion Sensor, Pointer, and external extension controller of the Wii Remote. Accordingly, in scenes in which audio is output frequently, there is no need to start and stop the speaker often. In such scenes, keep the speaker ON the whole time, and instead of starting and stopping the speaker, use the <a href="WPADControlSpeaker.html"><code>WPADControlSpeaker</code></a> function to send a <code>WPAD_SPEAKER_MUTE</code> or <code>WPAD_SPEAKER_MUTE_OFF</code> command to turn muting ON/OFF.
360</blockquote>
361<ul>
362<li><b>Broken or Skipping Audio</b></li>
363</ul>
364<blockquote>
365Due to the audio processor and wireless communication specifications of the Wii console and the Wii Remote, there are times when the audio will break or skip. Broken audio (crackling and popping) occurs when the state of the encoder on the Wii console side and the decoder on the Wii Remote side are out of sync with each other. The audio will break up as long as the encoder and decoder are out of sync. In order to synchronize the state of the encoder and decoder, you must restart the speaker. Audio skipping occurs when a sample on the Wii Remote side could not be processed. Consequently, even if you do not take any specific action, there are no problems with subsequent playback.<br /> <br /> Due to the audio processor specifications, audio played with the Wii Remote's speaker <font color="red"><b>may break or skip if audio is played back continuously for eight minutes or longer.</b></font>To avoid this, do one of the following:
366<ul>
367<li>Restart the speaker using the <a href="WPADControlSpeaker.html"><code>WPADControlSpeaker</code></a> function within 8 minutes of beginning audio playback.</li>
368<li>Refrain from playing audio for one second or more within eight minutes after beginning audio playback.</li>
369</ul>
370
371In addition, due to the specifications for wireless communication, it has been confirmed that the Wii Remote speaker <font color="red"><b>will break up audio in the following situations.</b></font> To avoid broken audio in the following cases, call the <a href="./WPADCanSendStreamData.html"><code>WPADCanSendStreamData</code></a> function when sending audio in order to make sure the audio can be sent and played without breaking up.
372<ul>
373<li>When packet loss due to external noise goes above a certain amount</li>
374<li>When an External Extension Controller is inserted</li>
375<li>When attempting to pair another Wii Remote to the Wii console (regardless of whether the pairing succeeds or fails)</li>
376<li>When a command is sent (especially when accessing internal memory)</li>
377</ul>
378</blockquote>
379
380<h2>Configuring Controller Features</h2>
381<p>
382The Rumble feature ON/OFF setting and speaker volume setting for Wii Remotes can be saved on the Wii console. Values set with the <a href="./WPADEnableMotor.html"><code>WPADEnableMotor</code></a> and <a href="./WPADSetSpeakerVolume.html"><code>WPADSetSpeakerVolume</code></a> functions can be saved on the Wii console using the <a href="./WPADSaveConfig.html"><code>WPADSaveConfig</code></a> function.
383</p>
384<p><font color="red"><b>However, do not allow these settings to be changed outside the HOME Menu in the release version.</b></font></p>
385
386<h2>Wii Remote Memory</h2>
387<p>
388The memory built into the Wii Remote is called Wii Remote memory. The Wii Remote memory allocates only one slot for the saving of game data. Although 4000 bytes are allocated for this slot, the library uses the first 112 bytes to manage file information. Thus, the application actually has access to only 3888 bytes for the saving of game data. Applications can freely read and write the area between the 112th and 4000th byte using the <a href="./WPADReadGameData.html"><code>WPADReadGameData</code></a> and <a href="./WPADWriteGameData.html"><code>WPADWriteGameData</code></a> functions. Note, however, that the file information is updated whenever game data is written to this region.
389</p>
390<p>
391The file information contains the following.
392</p>
393<table border="1">
394<tbody>
395<tr>
396<th>Title Name</th>
397<td>A string of up to 16 characters, UTF-16 encoded. Use the <a href="./WPADSetGameTitleUtf16.html"><code>WPADSetGameTitleUtf16</code></a> function to configure this string.</td>
398</tr>
399<tr>
400<th>Time of Last Update</th>
401<td>The file information can store the time when the game data was last updated as an <code>OSTime</code> type. Get this information with the <a href="./WPADGetGameDataTimeStamp.html"><code>WPADGetGameDataTimeStamp</code></a> function. The obtained value can be converted to the Western calendar using the <a href="../os/Time/OSTicksToCalendarTime.html"><code>OSTicksToCalendarTime</code></a> function.</td>
402</tr>
403<tr>
404<th>Game Code</th>
405<td>Stores the game code of the application that wrote the game data. This value is used internally by the library.</td>
406</tr>
407</tbody>
408</table>
409<p>
410To read details about the error codes that are returned when reading and writing game data, see the descriptions for the <a href="./WPADReadGameData.html"><code>WPADReadGameData</code></a> and <a href="./WPADWriteGameData.html"><code>WPADWriteGameData</code></a> functions. Also see the guidelines to read about other notes and precautions.
411</p>
412
413<h2>Handling Wii Remote Acceleration Noise</h2>
414<p>
415If your application makes use of very small acceleration values, be sure to keep in mind the existence of Wii Remote acceleration noise.<br><br> For more information, see the <I>Wii Controller Overview</I>.<br>
416</p>
417
418<h2>Wii MotionPlus</h2>
419<h3>What Is Wii MotionPlus?</h3>
420<p>
421The Wii MotionPlus is equipped with a rate gyroscope that can measure angular velocity in the pitch, yaw, and roll directions. If a Wii Remote starts in a neutral horizontal position, rotation in the <I>pitch</I> direction moves the button side of the Wii Remote from facing up to facing toward or away from the player. Rotation in the <I>yaw</I> direction moves the tip of the remote left or right, while the button side of the Wii Remote remains facing up. Rotation in the <I>roll</I> direction spins the button side of the Wii Remote from facing upward to facing left or right.
422</p>
423<div align="center">
424<img src="./WPADMotionPlus_direction.gif" width="808" height="332" />
425</div>
426<p>
427Sign conventions follow the right-hand rule: the thumb of the right hand indicates the direction of the rotation vector and the curled fingers of the same hand indicate the positive direction of rotation.
428</p>
429<div align="center">
430<img src="./WPADMotionPlus_sign.gif" width="570" height="372">
431</div>
432<p>
433When the user points the Wii MotionPlus in a given direction, the motion of pointing translates into some measurable value of angular velocity around each of the three axes. It is possible to use the angular velocity values to update the direction that the Wii MotionPlus is known to be pointing in. If this pointing direction is updated in each frame with the current angular velocities, the orientation of the Wii Remote being used can be reproduced on the screen.
434</p>
435<h3>Characteristics of the Wii MotionPlus</h3>
436<p>
437The Wii MotionPlus has the following characteristics.
438</p>
439<ul>
440<li>There is one rate sensor for each axis, and each is guaranteed to measure angular velocity up to 1500 dps. (The actual measurable range is closer to 1600 dps.)</li>
441<li>The analog values (voltage) that are output from the rate gyroscopes are converted into 14-bit digital values (0-16384), one per each component axis.</li>
442<li>Each analog value is subjected to two types of digital conversion having different resolutions. The hardware then automatically selects the most precise value and passes it to the Wii console.</li>
443<li>To later convert values for each axis to actual angular velocities, calibration readings are measured and written to the MotionPlus while it is held still (at-rest or zero point values) and while it is rotated at constant velocity (constant-velocity rotation values).</li>
444<li>The Wii MotionPlus has three operating modes, and its mode can be changed by the application.</li>
445<li>The Wii MotionPlus has a connector that the Nunchuk or Classic Controller can be plugged into.</li>
446<li>At-rest (zero point) values are subject to the &quot;temperature drift&quot; phenomenon during use.</li>
447<li>Some mismatch (accumulated error) arises as the Wii Remote's pointing direction continues to be updated using Wii MotionPlus values.</li>
448<li>Calibration values may include an error of maximum ±3 percent.</li>
449</ul>
450<h3>Digital Conversion</h3>
451<p>
452Because each directional component is expressed with 14 bits (0-16384), the resolution is relatively poor when the entire range of detectable velocity (±1500 dps) is digitally converted into 14 bits. This poor resolution is especially obvious at lower velocity. To improve this resolution, the sensor's analog output is converted into digital output in two ways: one for the low-velocity range of output from the sensor (approximately ±400 dps), and one for the entire range of output (±1500 dps). The Wii MotionPlus decides automatically which conversion value to provide, using the upper limit of the (0-16384) low-velocity range as a threshold. In the previous figure, the increase/decrease directions for both conversion values are shown for a Wii MotionPlus PP2. However, the Roll increase/decrease direction is reversed for a Wii MotionPlus PP3. (Multiple types of boards exist.) When calculating the angular velocity, however, the directions of increase/decrease are as shown in the previous figure regardless of the board. This is because the calibration value written to such devices is also reversed.
453</p>
454<p>
455For example, if the low-velocity conversion value is 3 when the user rotates the Wii MotionPlus at -400 dps around the yaw axis, the MotionPlus passes the low-velocity conversion value. However, if the low-velocity conversion value is 0 when the user rotates the Wii MotionPlus at -450 dps around the yaw axis, the MotionPlus selects the entire-range conversion value and passes that to the Wii console.
456</p>
457<p>
458<font color="red"><B>Note:</B> The values given here were chosen for ease of explanation. The same values are not necessarily obtained if Wii MotionPlus is actually rotated at the velocity given.</font>
459</p>
460<p>
461You can check which conversion value the Wii MotionPlus has selected by looking at the value of the <code>stat</code> member in the <a href="./WPADStatus.html"><code>WPADMPStatus</code></a> structure.
462</p>
463<h3>Calibration</h3>
464<p>
465The characteristics of the Wii MotionPlus rate gyroscopes vary by device. These individual differences mean that the values passed from more than one Wii MotionPlus do not necessarily match even when they are at rest or rotated at the same velocity. When using a Wii MotionPlus, be sure to perform calibration first to cover variations of each device.
466</p>
467<p>
468Depending on the device, the at-rest (zero-point) value when the Wii MotionPlus is operational may drift greatly from the ideal value (near the center of the converted range). Therefore, be sure to execute zero-point reset for the hardware as early as possible when a Wii MotionPlus has been started. Perform a zero-point reset of the hardware by passing <code>WPAD_MPLS_ZRST</code> to the <a href="./WPADControlMpls.html"><code>WPADControlMpls</code></a> function. Only execute a zero-point reset while the Wii MotionPlus is at rest. If a zero-point reset is executed while the Wii MotionPlus is moving, the zero point may drift even more greatly. As stated in the hardware specifications, the zero point should not be reset after the Wii MotionPlus is started until 200 ms elapse. Note that if the zero point is reset before 200 ms have elapsed, the change is voided.
469</p>
470<p>
471Next, we recommend that you calibrate the value used to convert angular velocity values passed from the Wii MotionPlus. At-rest (zero point) values and constant-velocity rotation values are written to the Wii MotionPlus as calibration values. However, the Wii MotionPlus has a characteristic called &quot;temperature drift,&quot; where the zero-point drifts due to the temperature. Therefore, the value passed by the Wii MotionPlus does not always match the zero-point calibration value at such times. If the value passed differs greatly from the calibration value, we recommend that you perform a zero-point reset using the <a href="./WPADSetMplsCalibration.html"><code>WPADSetMplsCalibration</code></a> function while the Wii MotionPlus is at rest.
472</p>
473<p>
474You must take the values passed from the Wii MotionPlus and apply these calibration values to calculate the actual angular velocities that you will use. You can get the calibration values with the <a href="./WPADGetMplsCalibration.html"><code>WPADGetMplsCalibration</code></a> function. Use the following formula to convert Wii MotionPlus output values to angular velocity.</p>
475<p align="center">
476<code><b>Angular velocity = ( (output value obtained from Wii MotionPlus) - (at-rest zero point value) ) / (constant-speed rotation value) * (magnitude of the constant speed)</b></code>
477</p>
478<p>
479In addition, each Wii MotionPlus has two sets of calibration values. There is one set each for the two resolution values that are passed to the console. The value passed is the result of the automatic digital conversion and selection process previously described. Note that before calculating angular velocity, you need to check the value of the <code>stat</code> member of the <a href="./WPADStatus.html"><code>WPADMPStatus</code></a> structure to determine which conversion value is being used for the digital value passed from the Wii MotionPlus. Only once you know the type of conversion can you get the appropriate calibration values with the <a href="./WPADGetMplsCalibration.html"><code>WPADGetMplsCalibration</code></a> function.
480</p>
481<h3>Operating Modes</h3>
482<p>
483The Wii MotionPlus behaves differently from the Nunchuk, Classic Controller, and other normal external extension controllers. When a normal external extension controller is plugged into the Wii Remote, the Wii Remote recognizes that an external extension controller has been inserted and automatically sends notification to the Wii console. Once the WPAD library receives this notification, it can recognize the external extension controller. However, if a Wii MotionPlus is inserted into a Wii Remote, the Wii Remote does not automatically recognize it. To make the Wii Remote recognize the Wii MotionPlus, the application must explicitly send a startup command to the MotionPlus. The Wii MotionPlus is started explicitly in this way because it has multiple operating modes.
484</p>
485<ul>
486<li>Bypass mode</li>
487</ul>
488<p>
489In this state, the Wii MotionPlus is stopped. This is also the initial state of the Wii MotionPlus. When the Wii MotionPlus is in this state, the Wii Remote cannot detect that the MotionPlus has been inserted. If a Nunchuk, Classic Controller, or other external extension controller is plugged into the external extension controller connector on the Wii MotionPlus while the MotionPlus is in this state, the MotionPlus forms a bypass connecting the Nunchuk or other controller to the Wii Remote. For this reason, these external extension controllers are recognized by the Wii Remote and the WPAD library just as if they had been directly inserted into the Wii Remote.
490</p>
491<ul>
492<li>Normal mode</li>
493</ul>
494<p>
495In this state only the Wii MotionPlus is running. When in this mode, the Wii Remote sends the latest Wii MotionPlus values to the Wii console. Start the Wii MotionPlus in this mode by passing <code>WPAD_MPLS_STD</code> to the <a href="./WPADControlMpls.html"><code>WPADControlMpls</code></a> function. When the Wii MotionPlus is in this mode, Wii MotionPlus operations do not change even if an external extension controller is plugged into the connector of the Wii MotionPlus.
496</p>
497<ul>
498<li>Extension mode</li>
499</ul>
500<p>
501In this mode, the Wii MotionPlus and a Nunchuk or Classic Controller plugged into the connector for external extension controllers on the Wii MotionPlus can be used at the same time. When in this mode, if any device is plugged into the connector for external extension controllers on the Wii MotionPlus, the Wii Remote alternately sends the values for the Wii MotionPlus and values for the plugged-in device to the Wii console. However, when in this mode, only Nunchuk or Classic Controller data is valid as the external extension controller data sent to the Wii console. Other data is not processed. You can check whether external extension controller data is enabled using the <SPAN class="argument">stat</SPAN> member of the <a href="./WPADStatus.html"><code>WPADMPStatus</code></a> structure. If no devices are plugged into the Wii MotionPlus, the latest values for the Wii MotionPlus are sent to the Wii console just as in standard mode. Extension mode is further divided into two modes. The first mode is used when a Wii MotionPlus and Nunchuk are used at the same time. Start the Wii MotionPlus in this mode by passing <code>WPAD_MPLS_FS</code> to the <a href="./WPADControlMpls.html"><code>WPADControlMpls</code></a> function. The other mode is used when a Wii MotionPlus and Classic Controller are used at the same time. Start the Wii MotionPlus in this mode by passing <code>WPAD_MPLS_CL</code> to the <a href="./WPADControlMpls.html"><code>WPADControlMpls</code></a> function. <font color="red">However, these operations are supported starting with Wii MotionPlus PP3.</font> When in this mode, if a Nunchuk or Classic Controller is plugged in, the Wii MotionPlus alternately sends values for the Wii MotionPlus and values for the Nunchuck or Classic Controller to the Wii console. For this reason, be sure to note that the sampling rate is half the standard rate when using a Wii MotionPlus at the same time as a Nunchuk or Classic Controller. In addition, starting with the Wii MotionPlus PP3, the Wii MotionPlus does not need to be restarted. This is because continued use is possible even if a Nunchuk or Classic Controller is reconnected while running in this mode.
502</p>
503
504<p>
505A diagram showing the transitions between operating modes of the Wii MotionPlus is provided below. The <a href="./WPADControlMpls.html"><code>WPADControlMpls</code></a> function changes the operating mode. When the Wii MotionPlus is started, the WPAD library recognizes it with the same procedure it uses to recognize the Nunchuk and the Classic Controller. The current operating mode can be obtained with the <a href="./WPADGetMplsStatus.html"><code>WPADGetMplsStatus</code></a> function.
506</p>
507
508<div align="center">
509<img src="./mpls_state.GIF" width="824" height="615" />
510</div>
511
512<h3>Connectors for External Extension Controllers</h3>
513<p>
514The Wii MotionPlus has a connector for external extension controllers. The Nunchuk, Classic Controller, and other external extension controllers can be plugged into this connector, but another Wii MotionPlus cannot be plugged in. In the case of a Wii Remote connector, you can determine whether an external extension controller has been plugged in by using the <a href="./WPADProbe.html"><code>WPADProbe</code></a> or <a href="./WPADSetExtensionCallback.html"><code>WPADSetExtensionCallback</code></a> function. Starting with the Wii MotionPlus PP3, <font color="red">the status of the Wii MotionPlus connector can be obtained using these functions</font> just as with a Wii Remote. When a Wii MotionPlus is running, the device type returned by these functions is <code>WPAD_DEV_MPLS</code>. Therefore, if an external extension controller is plugged into the Wii MotionPlus, the device type changes as follows depending on the device that has been plugged in.
515</p>
516<table class="arguments" border="1">
517<tr>
518<th>Nunchuk</th><td><code>WPAD_DEV_MPLS_FREESTYLE</code></td>
519</tr>
520<tr>
521<th>Classic Controller</th><td><code>WPAD_DEV_MPLS_CLASSIC</code></td>
522</tr>
523<tr>
524<th>Other External Extension Controllers</th><td><code>WPAD_DEV_MPLS_FUTURE</code></td>
525</tr>
526</table>
527<p>
528For example, the device type <code>WPAD_DEV_FREESTYLE</code> results if a Wii MotionPlus is plugged into a Wii Remote and a Nunchuk is plugged into the Wii MotionPlus. If the Wii MotionPlus is started in this state, the device type changes as follows: <code>WPAD_DEV_CORE → WPAD_DEV_UNKNOWN → WPAD_DEV_MPLS → WPAD_DEV_MPLS_FREESTYLE</code>.
529</p>
530<p>
531Changes in the device type do not depend on the operational mode of the Wii MotionPlus. Whether the operational mode is standard mode or extension mode, the device type <code>WPAD_DEV_MPLS</code> results if only a Wii MotionPlus is plugged into the Wii Remote. In addition, the device type changes as shown in the table above when a Nunchuk, Classic Controller, or other external extension controller has been plugged in. If any of these extension controllers are unplugged from the Wii MotionPlus, the device type returns to <code>WPAD_DEV_MPLS</code>.
532</p>
533
534<h3>Accumulated Error</h3>
535<p>
536Over time, as the system updates the orientation of the Wii MotionPlus based on the angular velocity values it yields, this calculated orientation may gradually begin to differ from the actual orientation. This mismatch will increase over time. This phenomenon is caused by the accumulation of very small amounts of error from the calculations performed in each update cycle.
537</p>
538<h3>Calibration Value Error</h3>
539<p>
540As 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. You should design your game specification so that an error margin within this range does not cause any problems. To be more specific, if for example the angle of rotation is 90 degrees, the information should be obtained for 90 degrees ±8 percent (that is, 82.8 to 97.2 degrees).
541</p>
542<h3>Error Handling for Wii MotionPlus-Specific Controller Information</h3>
543<p>
544Usually, controller information obtained from the Wii Remote can be confirmed by checking the value of the <code>err</code> member of the <a href="./WPADStatus.html"><code>WPADStatus</code></a> structure, and also checking that there are no problems in the data content. In the case of a Wii MotionPlus, be sure to check the value of the <code>stat</code> member of the <a href="./WPADStatus.html"><code>WPADMPStatus</code></a> structure in addition to the value of the <code>err</code> member. This is recommended to distinguish cases where the Wii MotionPlus is operating in extension mode but its external extension controller has been unplugged, because in these cases some of the data that it provides can still be used normally.
545</p>
546
547<h3>Initialization Process</h3>
548<p>
549Initialization is required starting with the Wii MotionPlus PP3. Because the initialization process of the Wii MotionPlus takes time, initialization is executed in parallel with standard operations of the Wii MotionPlus. For this reason, the initialization process itself completes about 20 seconds after the Wii MotionPlus is started. Because commands are sent from the library to the Wii MotionPlus during the initialization process, the <a href="./WPADProbe.html"><code>WPADProbe</code></a> function sometimes returns <code>WPAD_ERR_BUSY</code>. Applications do not need to recognize this because the Wii MotionPlus functions normally except for this.
550</p>
551
552<h2>Classic Controller and Classic Controller Pro</h2>
553<p>
554The Classic Controller and the Classic Controller Pro differ in terms of the shapes of the LR analog buttons and the quantity of analog input. 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.
555</p>
556<p>
557<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.
558</p>
559
560<h2>Error Codes</h2>
561<p>
562The error codes returned from the WPAD library can be grouped into the following three categories.
563</p>
564<ul>
565<li>Returned by the <a href="./WPADProbe.html"><code>WPADProbe</code></a> function. Shows the Wii Remote status.</li>
566<li>Passed into the <SPAN class="argument">err</SPAN> member variable of the <a href="./WPADStatus.html"><code>WPADStatus</code></a> structure. Shows the status of the acquired input data.</li>
567<li>Returned from functions that control the Pointer, speaker, and so on. Shows whether the library was able to accept that processing.</li>
568</ul>
569<p>
570Because only the first and second categories of error codes will be described here, for the third category of errors, refer to the individual function descriptions.
571</p>
572<p>
573Among the error codes defined in the WPAD library, those returned by the <a href="./WPADProbe.html"><code>WPADProbe</code></a> function are described below.
574</p>
575
576<TABLE class="arguments" border="1" >
577  <tbody>
578  <tr>
579<th>WPAD_ERR_NONE</th>
580<td>The Wii Remote is connected, and control commands are not being sent from the Wii console to the Wii Remote.</td>
581  </tr>
582  <tr>
583<th>WPAD_ERR_NO_CONTROLLER</th>
584<td>The Wii Remote is disconnected.</td>
585  </tr>
586  <tr>
587<th>WPAD_ERR_BUSY</th>
588<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>
589  </tr>
590  </tbody>
591</table>
592
593<p>
594Shown below are the error codes that are passed to the <SPAN class="argument">err</SPAN> member variable of the <a href="./WPADStatus.html"><code>WPADStatus</code></a> structure, and the descriptions of those error codes.
595</p>
596
597<TABLE class="arguments" border="1" >
598  <tbody>
599  <tr>
600<th>WPAD_ERR_NONE</th>
601<td>Data with the specified data format was received.</td>
602  </tr>
603  <tr>
604<th>WPAD_ERR_NO_CONTROLLER</th>
605<td>Data has never been received.</td>
606  </tr>
607  <tr>
608<th>WPAD_ERR_INVALID</th>
609<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 Wii Remote and external extension controller data is invalid.)</td>
610  </tr>
611  <tr>
612<th>WPAD_ERR_CORRUPTED</th>
613<td>An external extension controller, such as the Nunchuk or Classic Controller, is partially inserted into the Wii Remote. Data for the external extension controller is corrupted. (However, Wii Remote data is not corrupted.)</td>
614  </tr>
615  </tbody>
616</table>
617
618<h2>Automatic Disconnect</h2>
619<p>
620If there has been no change in controller input for a fixed period of time, the WPAD library will disconnect. This prevents the Wii Remote's battery power from running out due to user neglect. The WPAD Library checks for input from the buttons, Motion Sensor, Pointer, and external extension controller. Consequently, even if the Wii Remote is left alone, its input may change if someone walks heavily around it, if the Pointer is facing the window, or in some other situations. Be aware that the Wii Remote may therefore not be disconnected after the set period of time.
621</p>
622<p>
623Although the initial setting is 5 minutes, it can be changed with the <a href="./WPADSetAutoSleepTime.html"><code>WPADSetAutoSleepTime</code></a> function. It is also possible to use the <a href="./WPADResetAutoSleepTimeCount.html"><code>WPADResetAutoSleepTimeCount</code></a> function to reset the elapsed time since input stopped changing.
624</p>
625
626<h2>Resetting the Analog Stick Origin</h2>
627<p>
628The analog stick origin of a Nunchuk or Classic Controller can be reset by holding down the A, B, +, and - Buttons on the Wii Remote or Classic Controller for three seconds. However, the origin cannot be reset with button combinations such as the A and B Buttons on the Wii Remote combined with the + and - Buttons on the Classic Controller.
629</p>
630
631<h2>Controller Port Mapping</h2>
632<p>
633The WPAD library keeps track of the last Wii Remote that connected to each controller port only while the Wii console is running. In other words, this information is cleared if the Wii console is shut down, but remains unchanged if the Wii console is reset. (Information recorded to each controller port is cleared immediately after the Wii console is started.)
634</p>
635<p>
636When a Wii Remote initiates a connection, its information is compared with the information for the last Wii Remote to be connected to each controller port. If the same information is found, the Wii Remote is assigned to that controller port. If the same information could not be found after checking all of the controller ports, it is assigned to the open controller port with the lowest number.
637</p>
638<p>
639Recorded Wii Remote information is cleared in the following situations. If the <a href="./WPADDisconnect.html"><code>WPADDisconnect</code></a> function is used to disconnect a Wii Remote, information is cleared for the Wii Remote on the disconnected controller port. If the <a href="./../os/Reset/OSShutdownSystem.html"><code>OSShutdownSystem</code></a> function is called or the Power Button is pressed and held to shut down the Wii console, the Wii Remote information for all controller ports is cleared.
640</P>
641<p>
642For example, the following shows the Wii console immediately after starting up.
643</p>
644<table border="1">
645<tr><th width="100px">Port 1</th><td width="100px" align="center">----</td></tr>
646<tr><th width="100px">Port 2</th><td width="100px" align="center">----</td></tr>
647<tr><th width="100px">Port 3</th><td width="100px" align="center">----</td></tr>
648<tr><th width="100px">Port 4</th><td width="100px" align="center">----</td></tr>
649</table>
650<p>
651If Wii Remotes A, B, and C are connected in order, the lowest-numbered open port is assigned to each Wii Remote in order because no Wii Remote information has been stored.
652</p>
653<table border="1">
654<tr><th width="100px" bgcolor="lightblue">Port 1</th><td width="100px" align="center">Wii Remote A</td></tr>
655<tr><th width="100px" bgcolor="lightblue">Port 2</th><td width="100px" align="center">Wii Remote B</td></tr>
656<tr><th width="100px" bgcolor="lightblue">Port 3</th><td width="100px" align="center">Wii Remote C</td></tr>
657<tr><th width="100px">Port 4</th><td width="100px" align="center">----</td></tr>
658</table>
659<p>
660Assume that Wii Remote A is disconnected due to a depleted battery and that Wii Remote B is disconnected after a fixed period of time without input. At this point, the information in Port 1 and Port 2 is kept unchanged.
661</p>
662<table border="1">
663<tr><th width="100px">Port 1</th><td width="100px" align="center">Wii Remote A</td></tr>
664<tr><th width="100px">Port 2</th><td width="100px" align="center">Wii Remote B</td></tr>
665<tr><th width="100px" bgcolor="lightblue">Port 3</th><td width="100px" align="center">Wii Remote C</td></tr>
666<tr><th width="100px">Port 4</th><td width="100px" align="center">----</td></tr>
667</table>
668<p>
669When Wii Remote B is reconnected after its battery has been replaced, it is assigned to Port 2 because its information is still recorded there.
670</p>
671<table border="1">
672<tr><th width="100px">Port 1</th><td width="100px" align="center">Wii Remote A</td></tr>
673<tr><th width="100px" bgcolor="lightblue">Port 2</th><td width="100px" align="center">Wii Remote B</td></tr>
674<tr><th width="100px" bgcolor="lightblue">Port 3</th><td width="100px" align="center">Wii Remote C</td></tr>
675<tr><th width="100px">Port 4</th><td width="100px" align="center">----</td></tr>
676</table>
677<p>
678When Wii Remote D is connected, its information has not been recorded anywhere, so it is assigned to the open port with the lowest number: Port 1. The information in Port 1 is replaced with Wii Remote D's information.
679</p>
680<table border="1">
681<tr><th width="100px" bgcolor="lightblue">Port 1</th><td width="100px" align="center">Wii Remote D</td></tr>
682<tr><th width="100px" bgcolor="lightblue">Port 2</th><td width="100px" align="center">Wii Remote B</td></tr>
683<tr><th width="100px" bgcolor="lightblue">Port 3</th><td width="100px" align="center">Wii Remote C</td></tr>
684<tr><th width="100px">Port 4</th><td width="100px" align="center">----</td></tr>
685</table>
686<p>
687When Port 1 is disconnected using the <a href="./WPADDisconnect.html"><code>WPADDisconnect</code></a> function, its information is cleared.
688</p>
689<table border="1">
690<tr><th width="100px">Port 1</th><td width="100px" align="center">----</td></tr>
691<tr><th width="100px" bgcolor="lightblue">Port 2</th><td width="100px" align="center">Wii Remote B</td></tr>
692<tr><th width="100px" bgcolor="lightblue">Port 3</th><td width="100px" align="center">Wii Remote C</td></tr>
693<tr><th width="100px">Port 4</th><td width="100px" align="center">----</td></tr>
694</table>
695<p>
696When the Wii console is shut down, all information is cleared.
697</p>
698<table border="1">
699<tr><th width="100px">Port 1</th><td width="100px" align="center">----</td></tr>
700<tr><th width="100px">Port 2</th><td width="100px" align="center">----</td></tr>
701<tr><th width="100px">Port 3</th><td width="100px" align="center">----</td></tr>
702<tr><th width="100px">Port 4</th><td width="100px" align="center">----</td></tr>
703</table>
704
705<h2>Termination Processing</h2>
706<p>
707The WPAD library's close process is now performed inside the OS library's reset function. When closing the library, call the OS library reset/shutdown function from the application.
708</p>
709<p>
710The <a href="./../os/Reset/OSShutdownSystem.html"><code>OSShutdownSystem</code></a> function disconnects all communicating Wii Remotes. Although the <a href="./../os/Reset/OSRestart.html"><code>OSRestart</code></a>, <a href="./../os/WiiMenu/OSReturnToMenu.html"><code>OSReturnToMenu</code></a>, and <a href="./../os/Reset/OSRebootSystem.html"><code>OSRebootSystem</code></a> functions disconnect all communicating Wii Remotes, the remotes are in an auto-reconnect state (reconnect without any button input) for about 15 to 20 seconds after disconnection. When a game application is restarted or moves to the Wii Menu, it is possible to restore the pre-reset state without any button input from the user.
711</p>
712
713<h2>Cautions When Using the Wireless LAN</h2>
714<p>
715The Wii console and the Wii Remote communicate using the 2.4-GHz band. Using a wireless LAN on the same 2.4-GHz band may cause interference, resulting in communication problems.  To avoid such interference, the SDK automatically switches the frequency band that it uses. The application no longer needs to be aware of this issue.
716</p>
717
718<h2>Interference from Other Wireless Devices</h2>
719<p>
720When the application is reset while the Wii Remote is attached, in some rare instances the Auto-Reconnect process does not work properly and the Wii Remote is not automatically connected.<br><br> This is because the process may occasionally fail if a rash of communication errors occur during the reconnection process (for example, due to jamming).<br><br> Because it is impossible for the application to do anything to avoid these symptoms when they occur, there is no specific workaround.
721</p>
722
723<h2>Revision History</h2>
724<p>
7252009/06/23  Explained the effect of interference from other wireless devices. Explained the Classic Controller and the Classic Controller Pro.<br>2009/06/05 Added a section on handling Wii Remote acceleration noise.<br>2009/03/06  Updated the explanation about the relation between external extension controllers and libraries.<br> 2009/01/22 Corrected the explanation about the margin of error for Wii MotionPlus calibration values. Explained that the zero point must not be reset until more than 200 ms have elapsed.<br> 2008/12/19 Added a description of the Drum Controller.<br /> 2008/12/08 Revised descriptions of Wii MotionPlus operational modes and device types.<br> 2008/12/03 Comprehensively revised the description of the Wii MotionPlus to match new specifications starting with PP3.<br>2008/12/02 Revised the description of error codes.<br />2008/11/26 Revised descriptions of external extension controllers and libraries.<br> 2008/09/30 Added explanations for the Wii MotionPlus.<br>2008/08/27 Revised the description of the Wii Balance Board.<br>2008/06/04 Revised the description of Wii Remote memory.<br>2008/05/29 Added a description of prohibition processing for the +Control Pad.<br>2008/05/19 Revised the description of controller port mapping and added specific examples.<br>2008/04/16 Added a note stating that external causes may stop automatic disconnection from occurring as configured. Added an explanation for resetting the time elapsed since input stopped changing. Added explanations for the Wii Balance Board. Added information on the relationship between the library and external extension controllers. Added the WBC library to the library structure. Revised error code descriptions.<br>2007/10/11 Updated the description for speaker controls.<br> 2007/06/07 Added explanation about the simple pairing specification change.<br>2007/04/03 Added error code descriptions.<br>2007/03/22 Added a supplemental explanation about turning the Rumble Feature ON and OFF.<br>2007/02/08 Noted that the Classic Controller can also reset its origin. Noted that Wii Remote pairing is not possible while pairing information is being deleted. Added text about stopping the Wii Remote speaker when it is not in use.<br>2006/11/09 Added explanation for the process of reconnecting while an external extension controller is attached.<br>2006/10/23 Changed explanations for pairing and termination processing.<br>2006/09/18 Added a description for avoiding wireless LAN interference internally. Deleted warnings for the bugs found in SDK 2.2. Added text about change in mapping table handling. Added explanation for controller registration.<br>2006/09/06 Reflected changes to specifications about turning the Rumble Feature ON/OFF and speaker volume settings. Described problems with controller controls and the speaker. Added information about simple registration, internal memory, automatic disconnect, controller port mapping, close operation, and Control Stick origin reset.<br>2006/07/04 Added speaker-related information.<br>2006/06/19 Deleted the object size restriction from the cautions specific to UI tools.<br>2005/11/10 Added description of DPD module's hardware bug.<BR>2005/11/09 Corrected warnings about the use of the GameCube standard controller. Changed the description of the PAD library treatment in the Nintendo GameCube SDK. Added bug report.<br>2005/11/01 To reflect the change of interface from EXI to SI, added a caution related to SI. Added links to functions. Added introduction text for the KPAD library. Added bug report.<br>2005/09/27 Changed the name to DPD. Deleted some hardware descriptions in <B>Introduction</B>.<br>2005/08/30 Modified description of buttons in <B>Introduction</B>; added a bug report.<br>2005/08/01 Initial version.
726</p>
727
728<hr><p>CONFIDENTIAL</p></body></html>