VPADRead

Syntax

#include <cafe/vpad.h>

s32 VPADRead( s32 chan, VPADStatus samplingBufs[ ], u32 length, s32* err );

Parameters

chan Controller number. 0 for DRC1, 1 for DRC2.
samplingBufs Pointer to the VPADStatus structure.
length Maximum number of data sets to store. If you use the VPADInit function, this number cannot exceed VPAD_RING_BUFS.
err Pointer to the variable for passing the error code.

Return Values

Returns the number of data sets that are stored.

Description

This function loads data of the VPADStatus structure type for each controller channel. It is assumed 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 time of the previous call to the time of the current call. (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 VPADGetButtonProcMode function is VPAD_BUTTON_PROC_MODE_LOOSE, only the most recent values are accessed when the VPADRead functions are called, and those values are copied into all the current-frame sampling buffers.

NOTE:
The buffer specified by samplingBufs may be used internally as a work area. Because of this, even if there is no data, the contents of the buffer may be rewritten. Even in this case, the newest data will not change.

The following error codes are passed to err:

VPAD_READ_ERR_NONE There is sampling data.
VPAD_READ_ERR_NO_DATA There is no sampling data.
VPAD_READ_ERR_NO_CONTROLLER The DRC is not connected.
VPAD_READ_ERR_LOCKED Duplicate calls caused failure to obtain permission to process.
VPAD_READ_ERR_INIT The VPADInit function has not been called.
NOTE:
In certain circumstances (mainly for the poor signal quality of the wireless connection between Wii U console and DRC), the VPADRead function returns 0 for a fixed period of time and the VPAD_READ_ERR_NO_DATA is passed to err. (This indicates that it failed to obtain the data.) The similar situation will occur when the TV control button on DRC is pressed to launch TV Remote function.

Do Not Call From

Background Do not call this function from the background.
Multiple threads This function is not thread-safe.
Multiple Cores Do not call this function from more than one Core.

See Also

VPADStatus

Revision History

2013/08/07 Modified the description of the error code.
2013/05/08 Automated cleanup pass.
2013/01/16 Modified the note in the description.
2012/10/04 Added the comment.
2011/03/30 Initial version.


CONFIDENTIAL