#include <cafe/pads/kpad/kpad.h>

s32 KPADRead( s32 chan, KPADStatus samplingBufs[ ], u32 length );


chan One of the WPAD_CHANn values.
samplingBufs Pointer to the KPADStatus structure.
length Maximum number of data sets to store. If you use the KPADInit function, this number cannot exceed KPAD_RING_BUFS. If you use the KPADInitEx function, this value cannot exceed the sum of KPAD_RING_BUFS and one-quarter the array length passed to the KPADInitEx function.

Return Values

Returns the number of data sets that are stored.

Because the Wii U console and Wii remote use wireless communication, cases exist where signal interference in the surroundings would block any data being transmitted between prior and current calls, and the function would return zero. Even in these circumstances the Wii U console and Wii remote maintain their connection status, so their connection status cannot be determined from the return value of this function. To determine connection status, use the WPADProbe or WPADSetConnectCallback function. It is also possible to use the return value of the KPADReadEx function. KPAD_READ_ERR_NO_DATA is used as the return value when data cannot be received. KPAD_READ_ERR_NO_CONTROLLER is used as the return value when not connected.


This function reads data in the KPADStatus structure type for each controller channel. The assumption is that this function will be called for each game frame. The buffer specified by the argument stores, from newest to oldest, the data sampled from the previous call's time to the current call's time (that is, the newest data is always stored at the beginning of the buffer). However, for button information only, if the button processing method obtained using the KPADGetButtonProcMode function is KPAD_BUTTON_PROC_MODE_LOOSE, only the most recent values are accessed when the KPADRead or KPADReadEx functions are called, and those values are copied into all the current-frame sampling buffers.

The buffer specified by samplingBufs is occasionally used internally as a work area. Because of this, it is possible for buffer contents to be overwritten even when there was no data.

When a Wii remote is connected to a Wii U console, the type of the external extension controller (if any) is not immediately known because recognition of the external extension controller only occurs after the Wii remote has completed its connection. Accordingly, the dev_type and KPADStatus contents obtained by the KPADRead/KPADReadEx function changes over time. Immediately after the Wii remote is connected, the dev_type returns WPAD_DEV_CORE. 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 dev_type may be WPAD_DEV_UNKNOWN. Following verification, the dev_type returns a value such as WPAD_DEV_FREESTYLE or WPAD_DEV_CLASSIC, depending on the type.

Do Not Call From

Background Do not call this function from the background.
Interrupt handler Do not call this function from any interrupt handler.
Exception handler Do not call this function from any exception handler.
Multiple Cores Do not call this function from more than one Core.

See Also


Revision History

2014/10/23 Separated KPADReadEx.
2013/08/30 Merge with KPADReadEx and clarify the recognition process.
2013/05/08 Automated cleanup pass.
2010/05/28 Added a note about the continual return of 0 for a set period of time.
2009/01/07 Added a description of KPADReadEx.
2008/06/13 Revised the explanation of length. Added explanation of the differences caused by different button processing methods.
2008/06/03 Deleted error codes.
2008/04/17 Revised the description of length. Added error codes.
2007/08/27 Explained that this function's return value cannot be used to judge connection status, and to use prior obtained values when the return value is zero.
2006/10/25 Revised the description to match KPAD version 2.
2006/08/01 Added a link under See Also.
2006/03/01 Initial version.