In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Difference between revisions of "Padscore.rpl"

From WiiUBrew
Jump to navigation Jump to search
m (→‎Wii Remote: Missed a few more 'bool' changes)
(Added info on WPADProbe - a function blindly located by Tueidj and I based on data from libogc.)
Line 15: Line 15:
 
|void WPADShutdown(void);
 
|void WPADShutdown(void);
 
|Cleans up after the library
 
|Cleans up after the library
 +
|-
 +
|WPADProbe
 +
|int WPADProbe(int chan, void * buffer);
 +
|This function checks if there is a controller connected to chan (between 0 and 3 for four total controllers). Possible return values include 0 (connection success), -1 (remote not connnected) and -2 (remote is pairing with the console). The values will sometimes flicker due to connection issues with the controller. Be sure to call this BEFORE WPADRead so that you can avoid reading fake data from disconnected controllers.
 
|-
 
|-
 
|WPADRead
 
|WPADRead

Revision as of 11:04, 21 April 2016

This library handles communication with controllers other than the Gamepad. It includes functions for the Wii Remote (WPAD), the Wii Balance Board (WBC), and a higher-level abstraction (KPAD). Unlike vpad.rpl for the Gamepad, this library appears to be optional, being loaded much closer to the application binary.

Functions

Wii Remote

Name Prototype Description
WPADInit void WPADInit(void); Initializes the library
WPADShutdown void WPADShutdown(void); Cleans up after the library
WPADProbe int WPADProbe(int chan, void * buffer); This function checks if there is a controller connected to chan (between 0 and 3 for four total controllers). Possible return values include 0 (connection success), -1 (remote not connnected) and -2 (remote is pairing with the console). The values will sometimes flicker due to connection issues with the controller. Be sure to call this BEFORE WPADRead so that you can avoid reading fake data from disconnected controllers.
WPADRead int WPADRead(int chan, void *buffer); Stores raw controller data for the specified Wii Remote in buffer
WPADIsMotorEnabled bool WPADIsMotorEnabled(void); Get's the status of the WPAD motor
WPADGetAcceptConnection bool WPADGetAcceptConnection(void); Returns true if we allow new wpad's to connect
WPADSetAcceptConnection bool WPADSetAcceptConnection(bool acceptConnections); Set's whenever or not we allow new connectins

Structures

Wii Remote Data

Can be gotten using WPADRead().

Name Prototype
WPADStatus
#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_Z     0x2000
#define WPAD_BUTTON_C     0x4000
#define WPAD_BUTTON_HOME  0x8000

#define WPAD_EXT_CORE          0
#define WPAD_EXT_NUNCHUK       1
#define WPAD_EXT_CLASSIC       2
#define WPAD_EXT_MPLUS         5
#define WPAD_EXT_MPLUS_NUNCHUK 6
#define WPAD_EXT_MPLUS_CLASSIC 7

#define WPAD_BATTERYLVL_CRIT   0
#define WPAD_BATTERYLVL_LOW    1
#define WPAD_BATTERYLVL_MEDIUM 2
#define WPAD_BATTERYLVL_HIGH   3
#define WPAD_BATTERYLVL_FULL   4

typedef struct {
    uint16 x;    /* Resolution is 1024 */
    uint16 y;    /* Resolution is 768 */
    uint16 size;
    uint8  ID;
    uint8  pad;
} IRObject;

typedef struct {
    uint16   buttons; /* See WPAD_BUTTON */
    uint16   accelX;  /* Resolution is 1024 */
    uint16   accelY;  /* Resolution is 1024 */
    uint16   accelZ;  /* Resolution is 1024 */
    IRObject IR[4];   /* Max number of objects */
    uint8    ext;     /* Extension, see WPAD_EXT */
    uint8    err;     /* Error codes */
} WPADStatus; /* Normal Wiimote */

typedef struct {
    uint16   buttons;  /* See WPAD_BUTTON */
    uint16   accelX;   /* Resolution is 1024 */
    uint16   accelY;   /* Resolution is 1024 */
    uint16   accelZ;   /* Resolution is 1024 */
    IRObject IR[4];    /* Max number of objects */
    uint8    ext;      /* Extension, see WPAD_EXT */
    uint8    err;      /* Error codes */
    uint16   ncAccX;   /* Resolution is 1024 */
    uint16   ncAccY;   /* Resolution is 1024 */
    uint16   ncAccZ;   /* Resolution is 1024 */
    uint16   ncStickX; /* Resolution is 256 */
    uint16   ncStickY; /* Resolution is 256 */
} WPADNCStatus; /* Nunchuk extension */

typedef struct {
    uint16   buttons; /* See WPAD_BUTTON */
    uint16   accelX;  /* Resolution is 1024 */
    uint16   accelY;  /* Resolution is 1024 */
    uint16   accelZ;  /* Resolution is 1024 */
    IRObject IR[4];   /* Max number of objects */
    uint8    ext;     /* Extension, see WPAD_EXT */
    uint8    err;     /* Error codes */
    uint16   pad[6];  /* Padding, Classic/Nunchuk? */
    uint8    status;  /* WiiMotionPlus */
    uint8    reserved;
    uint16   pitch;   /* WiiMotionPlus */
    uint16   yaw;     /* WiiMotionPlus */
    uint16   roll;    /* WiiMotionPlus */
} WPADMPStatus; /* WiiMotionPlus */

typedef struct {
    uint16 WPADData[20]; /* Default WPAD data isn't used */
    uint8  ext;          /* Extension, see WPAD_EXT */
    uint8  err;          /* Error codes */
    uint16 press[4];     /* 4 Pads for sensing balance */
    uint8  temp;         /* Temperature */
    uint8  battery;      /* Battery */
} WPADBLStatus; /* Balance Board */