KPADReadEx

Syntax

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

#define KPAD_READ_ERR_NONE           0
#define KPAD_READ_ERR_NO_DATA       -1
#define KPAD_READ_ERR_NO_CONTROLLER -2
#define KPAD_READ_ERR_SETUP         -3
#define KPAD_READ_ERR_LOCKED        -4
#define KPAD_READ_ERR_INIT          -5

s32 KPADReadEx( s32 chan, KPADStatus samplingBufs[ ], u32 length, s32 *err );

Parameters

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.
err Pointer to the variable for passing the error code.

Return Values

Returns the number of data sets that are stored.

Description

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. But if and only if KPAD_READ_ERR_NO_DATA is returned, then the contents at the start of the sampling buffer have not changed.

The following error codes are passed to err:

KPAD_READ_ERR_NONE There is sampling data.
KPAD_READ_ERR_NO_DATA No sampling data.
KPAD_READ_ERR_NO_CONTROLLER The Wii remote is not connected.
KPAD_READ_ERR_SETUP WPAD library initialization is not complete.
KPAD_READ_ERR_LOCKED Duplicate calls caused failure to obtain permission to process.
KPAD_READ_ERR_INIT The KPADInit function (or the KPADInitEx function) has not been called.
NOTE:
In certain circumstances, the KPADReadEx function returns 0 for a fixed period of time. (This indicates that it failed to obtain the data.)

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

KPADStatus
KPADRead

Revision History

2014/10/23 Recreated man page.
2013/05/08 Automated cleanup pass.
2010/05/28 Added note about the continual return of 0 for a fixed period of time.
2008/06/13 Revised the description of length. Added explanation of the differences caused by different button processing methods. Added mention that the newest data values are guaranteed protected.
2008/06/03 Initial version.


CONFIDENTIAL