PADStatus

C Specification

#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 with the PADSetAnalogMode function.

button If any button is depressed, 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)
analogB Analog input of the B Button. (see note)
err Controller error code:
PAD_ERR_NONE A GameCube Controller is connected to the controller port. The pad status contains valid data.
PAD_ERR_NO_CONTROLLER A GameCube Controller is not connected to the controller port. The pad status does not contain valid data (i.e., structure members other than err are all zeroed out). To restart the controller data sampling, the corresponding controller port 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 it is. 
PAD_ERR_NOT_READY The controller port is still being initialized from previous calls to PADInit, PADReset and PADRecalibrate. The controller status does not contain valid data (i.e., the structure members other than err are all zeroed out).
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() (i.e., the structure members other than err are all zeroed out).
Note: It may be suitable to continue using the previous valid controller 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 controller library WPAD does not support analog input values from the A and B Buttons.

See Also

Controller Functions, PADButtonDown, PADButtonUp, PADInit, PADRead, PADReset, PADSetAnalogMode

Revision History

03/01/2006 Initial version.