Padscore.rpl

From WiiUBrew
Jump to: navigation, search

This library handles communication with controllers other than the Gamepad. It includes functions for the Wii Remote (WPAD), the Wii Balance Board (WBC -or- WUD), 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.

Contents

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 connections
WPADStartSyncDevice bool WPADStartSyncDevice( void ); Begins the pairing process required to use the Wii remote
WPADStartSyncDeviceEx bool WPADStartSyncDeviceEx( void ); Begins the pairing process required to use the Wii remote (Ex version)
WPADCancelSyncDevice bool WPADCancelSyncDevice( void ); Cancels the current device sync function
WPADStartClearDevice void WPADStartClearDevice( void ); Removes all traces of wii remote from wii-U
WPADClearDeviceCallback void WPADClearDeviceCallback ( s32 ); Sets the callback to call if the device information is completely deleted.
WPADSyncDeviceCallback void WPADSyncDeviceCallback( s32 result, s32 num ); Set the callback if the sync button is pressed

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 */

Tables

List of Functions (Ioctl/Ioctlv/IoctlAsync/IoctlvAsync)

Command Function Ioctl Ioctlv IoctlAsync IoctlvAsync Notes
0x00 Unknown                                    X
0x01 Unknown     X                          
0x02 Unknown     X                          X
0x03 Unknown     X                          
0x04 WPADStartSyncDevice                                  X        
0x06 WPADPurgeBtDb                                  X
0x07 Unknown     X                          
0x08 WPADCancelSyncDevice     X                          X
0x09 WPADSetDisableChannelImm     X                          X
0x0A WPADStartClearDevice     X                          X
0x0B WUDSetVisibility                                  X WUD is Balance Board (aka WBC)
0x0C WUDSetSniffMode                                  X
0x0E WPADSetClearDeviceCallback                                  X
0x11 WUDSerialFlashUpdate                                  X
0x12 WUDSerialFlashTestMode                                  X
0x13 WUDSerialFlashTestWrite                                  X
0x14 WUDSerialFlashTestRead                                  X          
0x17 WPADStartSyncDeviceEx                                  X
0x1A WPADDeleteControllerOrder                                  X
0x1B WPADSetSyncDeviceCallback                                  X
0x1C Unknown                                  X

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox