PADStatus

Syntax

#include <revolution/pad.h>

typedef struct PADStatus
{
    u16 button;                 // Or-ed PAD_BUTTON_* and PAD_TRIGGER_* bits
    s8  stickX;                 // -128 <= stickX       <= 127
    s8  stickY;                 // -128 <= stickY       <= 127
    s8  substickX;              // -128 <= substickX    <= 127
    s8  substickY;              // -128 <= substickY    <= 127
    u8  triggerLeft;            //    0 <= triggerLeft  <= 255
    u8  triggerRight;           //    0 <= triggerRight <= 255
    u8  analogA;                //    0 <= analogA      <= 255
    u8  analogB;                //    0 <= analogB      <= 255
    s8  err;                    // one of PAD_ERR_* number
} PADStatus;

#define PAD_MAX_CONTROLLERS     4

#define PAD_BUTTON_LEFT         0x0001
#define PAD_BUTTON_RIGHT        0x0002
#define PAD_BUTTON_DOWN         0x0004
#define PAD_BUTTON_UP           0x0008
#define PAD_TRIGGER_Z           0x0010
#define PAD_TRIGGER_R           0x0020
#define PAD_TRIGGER_L           0x0040
#define PAD_BUTTON_A            0x0100
#define PAD_BUTTON_B            0x0200
#define PAD_BUTTON_X            0x0400
#define PAD_BUTTON_Y            0x0800
#define PAD_BUTTON_START        0x1000

#define PAD_ERR_NONE            0
#define PAD_ERR_NO_CONTROLLER   -1
#define PAD_ERR_NOT_READY       -2
#define PAD_ERR_TRANSFER        -3

Description

The PADStatus data structure represents the status of a controller.
The resolution of the analog inputs can be controlled by the PADSetAnalogMode function.

button If any button is pressed, the corresponding bit (PAD_BUTTON_* or PAD_TRIGGER_*) is set to 1.
stickX Movement data given in terms of the x-axis of the Control Stick.
stickY Movement data given in terms of the y-axis of the Control Stick.
substickX Movement data given in terms of the x-axis of the C-Stick (sub analog stick).
substickY Movement data given in terms of the y-axis of the C-Stick.
triggerLeft Movement data of the L Button.
triggerRight Movement data of the R Button.
analogA Analog input of the A Button. (See Note below.)
analogB Analog input of the B Button. (See Note below.)
err Controller error code:
PAD_ERR_NONE A GameCube Controller is connected to the controller port. The controller status contains valid data.
PAD_ERR_NO_CONTROLLER A GameCube Controller is not connected to the controller port. The controller status does not contain valid data (that is, all structure members other than err have been zero-cleared). To restart controller data sampling, the corresponding Controller Socket must be reinitialized by using PADReset.
Note: Something other than a GameCube Controller might be connected to the controller port. If that is the case, call SIProbe to verify what is connected.
PAD_ERR_NOT_READY The Controller Socket is still being initialized by a previous call to PADInit, PADReset or PADRecalibrate. The controller status does not contain valid data (that is, all structure members other than err have been zero-cleared).
Note: The PAD_ERR_NOT_READY state does not continue more than a few video frames except due to programming error.
PAD_ERR_TRANSFER Due to external electrical noise, the prior sampling of Controller data failed. No valid data is available for the current PADRead (that is, all structure members other than err have been zero-cleared).
Note: It may often be suitable to continue using the previous valid pad status if PAD_ERR_TRANSFER is returned (rather than presuming the player might have released controller buttons during PAD_ERR_TRANSFER). The GameCube Controller normally recovers from the PAD_ERR_TRANSFER error state within a few frames. Unless the PAD_ERR_NO_CONTROLLER error is returned, the game program should not assume that the GameCube Controller has been unplugged.

Note: The GameCube Controller does not support analog input values (AnalogA/B) for the A and B Buttons. Also, the Revolution SDK controller library (WPAD) does not support analog input values from the A and B Buttons.

See Also

PADButtonDown, PADButtonUp, PADInit, PADRead, PADReset, PADSetAnalogMode

Revision History

2006/03/01 Initial version.


CONFIDENTIAL