WPADStatusEx

Syntax

#include <cafe/pads/wpad/wpad.h>
  
#define WPAD_DPD_MAX_OBJECTS        4

#define WPAD_BUTTON_LEFT            0x0001
#define WPAD_BUTTON_RIGHT           0x0002
#define WPAD_BUTTON_DOWN            0x0004
#define WPAD_BUTTON_UP              0x0008
#define WPAD_BUTTON_PLUS            0x0010
#define WPAD_BUTTON_2               0x0100
#define WPAD_BUTTON_1               0x0200
#define WPAD_BUTTON_B               0x0400
#define WPAD_BUTTON_A               0x0800
#define WPAD_BUTTON_MINUS           0x1000
#define WPAD_BUTTON_HOME            0x8000

// for FreeStyle
#define WPAD_BUTTON_Z               0x2000
#define WPAD_BUTTON_C               0x4000

// for ClassicStyle
#define WPAD_CL_BUTTON_UP           0x0001
#define WPAD_CL_BUTTON_LEFT         0x0002
#define WPAD_CL_TRIGGER_ZR          0x0004
#define WPAD_CL_BUTTON_ZR           WPAD_CL_TRIGGER_ZR
#define WPAD_CL_BUTTON_X            0x0008
#define WPAD_CL_BUTTON_A            0x0010
#define WPAD_CL_BUTTON_Y            0x0020
#define WPAD_CL_BUTTON_B            0x0040
#define WPAD_CL_TRIGGER_ZL          0x0080
#define WPAD_CL_BUTTON_ZL           WPAD_CL_TRIGGER_ZL
#define WPAD_CL_RESERVED            0x0100
#define WPAD_CL_TRIGGER_R           0x0200
#define WPAD_CL_BUTTON_R            WPAD_CL_TRIGGER_R
#define WPAD_CL_BUTTON_PLUS         0x0400
#define WPAD_CL_BUTTON_HOME         0x0800
#define WPAD_CL_BUTTON_MINUS        0x1000
#define WPAD_CL_TRIGGER_L           0x2000
#define WPAD_CL_BUTTON_L            WPAD_CL_TRIGGER_L
#define WPAD_CL_BUTTON_DOWN         0x4000
#define WPAD_CL_BUTTON_RIGHT        0x8000

// for compatibility
#define WPAD_BUTTON_SELECT          WPAD_BUTTON_MINUS
#define WPAD_BUTTON_START           WPAD_BUTTON_PLUS
#define WPAD_BUTTON_SMALL_B         WPAD_BUTTON_2
#define WPAD_BUTTON_SMALL_A         WPAD_BUTTON_1
#define WPAD_BUTTON_Z1              WPAD_BUTTON_Z
#define WPAD_BUTTON_Z2              WPAD_BUTTON_C

typedef struct WPADStatusEx
{
    u16       button;
    s16       accX;
    s16       accY;
    s16       accZ;
    DPDObject obj[WPAD_DPD_MAX_OBJECTS];
    u8        dev;
    s8        err;
    DPDObjEx  exp[WPAD_DPD_MAX_OBJECTS];
} WPADStatusEx;

typedef struct DPDObject
{
    s16 x;
    s16 y;
    u16 size;
    u8  traceId;
} DPDObject;

typedef struct DPDObjEx
{
    s16       range_x1;
    s16       range_y1;
    s16       range_x2;
    s16       range_y2;
    u16       pixel;
    s8        radius;
} DPDObjEx;

Elements

button When a button is pressed, the corresponding bit (WPAD_BUTTON_*) is set to 1.
accX Output of the Motion Sensor's x-component. The resolution is 1024. A value of 0 corresponds to weightlessness (0G). (Outputs in the range of -512 <= accX < 512.)
accY Output of the Motion Sensor's y-component. The resolution is the same as for accX.
accZ Output of the Motion Sensor's z-component. The resolution is the same as for accX.
obj[ ].x The x-coordinate of the center of mass for the object obtained with the Pointer. The resolution is 1024.
obj[ ].y The y-coordinate of the center of mass for the object obtained with the Pointer. The resolution is 768.
obj[ ].size The size of the object obtained with the Pointer. The resolution is 128*96.
obj[ ].traceId The trace ID of the object obtained with the Pointer.
dev The controller type.
err The controller error status.
exp[ ].range_x1 The top-right coordinate (x-axis) of the rectangle enclosing the object obtained by the pointer. Resolution is 1024.
exp[ ].range_y1 The top-right coordinate (y-axis) of the rectangle enclosing the object obtained by the pointer. Resolution is 768.
exp[ ].range_x2 The bottom-left coordinate (x-axis) of the rectangle enclosing the object obtained by the pointer. Resolution is 1024.
exp[ ].range_y2 The bottom-left coordinate (y-axis) of the rectangle enclosing the object obtained by the pointer. Resolution is 768.
exp[ ].pixel The number of pixels for the object obtained by the pointer. Resolution is 128*96.
exp[ ].radius The radius of the object obtained by the pointer. Values are calculated based on the size and are output in the range 0 <= exp[ ].radius <= 15.

Number of Standard Controllers

The maximum number of Wii remotes that can connect is defined as the macro constant below.

WPAD_MAX_CONTROLLERS The maximum number of Wii remotes that can connect.

Button Input

Button inputs are defined with the following macro constants.

WPAD_BUTTON_UP +Control Pad UP is being pressed.
WPAD_BUTTON_DOWN +Control Pad DOWN is being pressed.
WPAD_BUTTON_LEFT +Control Pad LEFT is being pressed.
WPAD_BUTTON_RIGHT +Control Pad RIGHT is being pressed.
WPAD_BUTTON_A The A Button is being pressed.
WPAD_BUTTON_B The B Button is being pressed.
WPAD_BUTTON_1 The 1 Button is being pressed.
WPAD_BUTTON_2 The 2 Button is being pressed.
WPAD_BUTTON_MINUS The - (minus) Button is being pressed.
WPAD_BUTTON_PLUS The + (plus) Button is being pressed.
WPAD_BUTTON_HOME HOME Button is being pressed.

Pointer

The pointer specifications are defined as macro constants.

WPAD_DPD_MAX_OBJECTS The maximum number of objects that the pointer can detect simultaneously.
WPAD_DPD_ANGLE The pointer view angle (in degrees).
WPAD_DPD_IMG_RESO_WX Pointer resolution along the x-axis.
WPAD_DPD_IMG_RESO_WY Pointer resolution along the y-axis.

Motion Sensor

The motion sensor specifications are defined by the macro constant below.

WPAD_ACC_RESO The motion sensor's resolution.

Controller Type

Controller types are defined with the following macro constants.

WPAD_DEV_NOT_FOUND Nothing is connected to the specified channel.
WPAD_DEV_CORE Wii remote.
WPAD_DEV_FREESTYLE Nunchuk Style.
WPAD_DEV_CLASSIC Classic Style.
WPAD_DEV_FUTURE A device that will be supported in the future. The device is legitimate, but this External Extension Controller cannot be used with this title. It may be operated as a Wii remote.
WPAD_DEV_NOT_SUPPORTED A device that cannot be used. This type is selected when device recognition fails or an illegal device is plugged in. It may be operated as a Wii remote.
WPAD_DEV_UNKNOWN Unknown device. This type is selected during the period between insertion of an External Extension Controller and completion of the recognition process. It may be operated as a Wii remote.

Error Status

Error statuses are defined with the following macro constants.

WPAD_ERR_NONE Indicates the Wii remote is connected. The WPADStatusEx structure maintains valid data.
WPAD_ERR_NO_CONTROLLER Indicates the Wii remote is not connected. The WPADStatusEx structure does not contain valid data. (Members other than err are undefined.)
WPAD_ERR_BUSY Processing is being carried out for the Wii remote. Only button information is valid for the WPADStatusEx structure.
WPAD_ERR_TRANSFER Indicates an issue occurred during communications. The WPADStatusEx structure does not contain valid data. (Members other than err are undefined.)
WPAD_ERR_INVALID The data format of data received from the Wii remote differs from that set by the WPADSetDataFormat function. (Structure members other than err are undefined.)
WPAD_ERR_CORRUPTED The data in the External Extension Controller is corrupted. The structure members of the External Extension Controller are undefined.

Description

The WPADStatus structure represents the status of the Wii remote. The tables above describe the information that is obtained.

The Wii remote is equipped with +Control Pad, A, B, 1, 2, - (minus), + (plus), and HOME digital buttons.

Object data items are stored in the obj array in the order in which they are detected by the Pointer. The pointer scans the image captured by the sensor internally from top left to bottom right and outputs object data in the order detected. At the same time, trace IDs are assigned in the order in which the objects are detected.

The trace IDs help to determine whether previously obtained data is the same as the currently obtained data. Consider a case where objects A (trace ID=0) and B (trace ID=1) are detected as A and B, respectively, by the previous scan, and then they are detected as B and A, respectively, after the pointer is moved. The output order for the current scan is the reverse of the previous one. However, the trace IDs are in the order of B (using the previously assigned trace ID of 1) and A (using the previously assigned trace ID of 0), and the fact that the data is the same is preserved.

Revision History

2013/05/08 Automated cleanup pass.
2011/12/19 Replaced wpad definitions WPAD_CL_TRIGGER_ZR, WPAD_CL_TRIGGER_ZL, WPAD_CL_TRIGGER_R, WPAD_CL_TRIGGER_L with WPAD_CL_BUTTON_ZR, WPAD_CL_BUTTON_ZL, WPAD_CL_BUTTON_R, WPAD_CL_BUTTON_L.
2006/09/22 Added WPAD_ERR_CORRUPTED.
2006/08/15 Initial version.


CONFIDENTIAL