wut v1.8.0
Wii U Toolchain
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions

KPAD is a high-level library over WPAD. More...

Collaboration diagram for KPAD:

Data Structures

struct  KPADVec2D
 2D vector. More...
 
struct  KPADVec3D
 3D vector. More...
 
struct  KPADStatus
 A structure containing the Wii Remote data. More...
 
struct  KPADUnifiedWpadStatus
 Storage type for the internal KPAD ring buffer. More...
 
union  KPADStatus.__unnamed46__
 Extension data, check with extensionType to see what is valid to read. More...
 
struct  KPADStatus.__unnamed46__.nunchuk
 Structure to use when extensionType is set to WPAD_EXT_NUNCHUK. More...
 
struct  KPADStatus.__unnamed46__.classic
 Structure to use when extensionType is set to WPAD_EXT_CLASSIC. More...
 
struct  KPADStatus.__unnamed46__.pro
 Structure to use when extensionType is set to WPAD_EXT_PRO_CONTROLLER. More...
 
struct  KPADStatus.__unnamed46__.balance
 Structure to use when extensionType is set to WPAD_EXT_BALANCE_BOARD. More...
 
struct  KPADStatus.mplus
 Structure to use when MotionPlus is enabled. More...
 
union  KPADUnifiedWpadStatus.__unnamed53__
 

Typedefs

typedef enum WPADChan KPADChan
 Wii Remote channel.
 
typedef enum WPADDataFormat KPADDataFormat
 Data format.
 
typedef enum WPADExtensionType KPADExtensionType
 Extension type.
 
typedef enum WPADMplsMode KPADMplsMode
 MotionPlus Mode.
 
typedef struct KPADStatus KPADStatus
 
typedef struct KPADUnifiedWpadStatus KPADUnifiedWpadStatus
 
typedef struct KPADVec2D KPADVec2D
 
typedef struct KPADVec3D KPADVec3D
 
typedef enum KPADError KPADError
 Error.
 
typedef enum KPADControlMplsStatus KPADControlMplsStatus
 Status codes for KPADControlMplsCallback.
 
typedef WPADConnectCallback KPADConnectCallback
 
typedef WPADSamplingCallback KPADSamplingCallback
 
typedef void(* KPADControlMplsCallback) (KPADChan chan, KPADControlMplsStatus status)
 Callback used for KPADSetControlMplsCallback().
 

Enumerations

enum  KPADError {
  KPAD_ERROR_OK = 0 ,
  KPAD_ERROR_NO_SAMPLES = -1 ,
  KPAD_ERROR_INVALID_CONTROLLER = -2 ,
  KPAD_ERROR_WPAD_UNINIT = -3 ,
  KPAD_ERROR_BUSY = -4 ,
  KPAD_ERROR_UNINITIALIZED = -5
}
 Error. More...
 
enum  KPADControlMplsStatus {
  KPAD_CONTROL_MPLS_STATUS_STARTED = 0 ,
  KPAD_CONTROL_MPLS_STATUS_FINISHED = 1 ,
  KPAD_CONTROL_MPLS_STATUS_FAILED_MPLS_ONLY = -1 ,
  KPAD_CONTROL_MPLS_STATUS_FAILED_MPLS_NUNCHUK = -2 ,
  KPAD_CONTROL_MPLS_STATUS_FAILED_MPLS_CLASSIC = -3
}
 Status codes for KPADControlMplsCallback. More...
 

Functions

void KPADInit (void)
 Initialises the KPAD library for use.
 
void KPADInitEx (KPADUnifiedWpadStatus *buffer, uint32_t count)
 Initializes the KPAD library with extra buffers.
 
void KPADShutdown (void)
 Cleans up and frees the KPAD library.
 
uint32_t KPADRead (KPADChan chan, KPADStatus *data, uint32_t size)
 Read data from the desired controller.
 
uint32_t KPADReadEx (KPADChan chan, KPADStatus *data, uint32_t size, KPADError *error)
 Read data from the desired controller.
 
void KPADGetUnifiedWpadStatus (KPADChan chan, KPADUnifiedWpadStatus *buffer, uint32_t count)
 Read a number of entries from the internal buffer.
 
int32_t KPADSetMaxControllers (uint32_t maxControllers)
 Set the maximum amount of controllers which can be connected to the system.
 
uint32_t KPADGetMaxControllers (void)
 Get the maximum amount of controllers which can be connected to the system.
 
uint32_t KPADGetGameMaxControllers (void)
 Get the maximum amount of controllers which can be connected, as reported by IOS-PAD.
 
KPADConnectCallback KPADSetConnectCallback (KPADChan chan, KPADConnectCallback callback)
 Set a callback for when a controller connection status changes.
 
KPADSamplingCallback KPADSetSamplingCallback (KPADChan channel, KPADSamplingCallback callback)
 Same usage as , except compatible with other KPAD functions.
 
uint32_t KPADGetMplsWorkSize (void)
 Returns the amount of memory needed for KPADSetMplsWorkarea().
 
void KPADSetMplsWorkarea (void *buf)
 Sets the extra memory KPAD will use to process MotionPlus data.
 
void KPADSetControlMplsCallback (KPADChan chan, KPADControlMplsCallback callback)
 Set a callback for when the MotionPlus extension is configured.
 
void KPADEnableMpls (KPADChan channel, KPADMplsMode mode)
 Sets MotionPlus for the controller in specified mode.
 
void KPADDisableMpls (KPADChan channel)
 Disables MotionPlus for the controller.
 
KPADMplsMode KPADGetMplsStatus (KPADChan chan)
 Get MotionPlus mode.
 
void KPADResetMpls (KPADChan chan)
 Resets the MotionPlus state.
 
void KPADEnableDPD (KPADChan chan)
 Enable IR pointing.
 
void KPADDisableDPD (KPADChan chan)
 Disable IR pointing.
 
void KPADResetWbcZeroPoint (void)
 Resets the Balance Board's zero.
 
void KPADResetWbcTgcWeight (void)
 Recalculate the Balance Board's TGC coefficients and zero.
 

Detailed Description

KPAD is a high-level library over WPAD.


Data Structure Documentation

◆ KPADVec2D

struct KPADVec2D

2D vector.

Definition at line 64 of file kpad.h.

Data Fields
float x x.
float y y.

◆ KPADVec3D

struct KPADVec3D

3D vector.

Definition at line 76 of file kpad.h.

Data Fields
float x x.
float y y.
float z z.

◆ KPADStatus

struct KPADStatus

A structure containing the Wii Remote data.

Definition at line 91 of file kpad.h.

Data Fields
uint32_t hold Indicates what KPADButtons are held down.
uint32_t trigger Indicates what KPADButtons have been pressed since last sample.
uint32_t release Indicates what KPADButtons have been released since last sample.
KPADVec3D acc Indicates the value of the acceleration sensor.
float accMagnitude Indicates the magnitude of acceleration.
float accVariation Indicates the variation in acceleration.
KPADVec2D pos Indicates the position where the Wii Remote is pointing; positive for right and down.
KPADVec2D posDiff Difference from previous pos.
float posDiffMagnitude Magnitude of posDiff.
KPADVec2D angle Angle: horizon vector (+x is right, +y is down.)
KPADVec2D angleDiff Difference from previous angle.
float angleDiffMagnitude Magnitude of angleDiff.
float dist Distance to the sensor bar, in meters.
float distDiff Difference from previous dist.
float distDiffMagnitude Absolute value of distDiff.
KPADVec2D down The "down" vector from accelerometer: when down.y is negative, wiimote is facing down.
uint8_t extensionType Value from KPADExtensionType.
int8_t error Value from KPADError.
int8_t posValid Validity of the pos field.
uint8_t format Value from KPADDataFormat.
union KPADStatus.__unnamed46__ __unnamed__ Extension data, check with extensionType to see what is valid to read.
struct KPADStatus.mplus mplus Structure to use when MotionPlus is enabled.

◆ KPADUnifiedWpadStatus

struct KPADUnifiedWpadStatus

Storage type for the internal KPAD ring buffer.

See also

Definition at line 318 of file kpad.h.

Data Fields
union KPADUnifiedWpadStatus.__unnamed53__ __unnamed__
uint8_t format One of WPADDataFormat.

◆ KPADStatus.__unnamed46__

union KPADStatus.__unnamed46__

Extension data, check with extensionType to see what is valid to read.

Definition at line 154 of file kpad.h.

Data Fields
struct KPADStatus.__unnamed46__.nunchuk nunchuk Structure to use when extensionType is set to WPAD_EXT_NUNCHUK.
struct KPADStatus.__unnamed46__.classic classic Structure to use when extensionType is set to WPAD_EXT_CLASSIC.
struct KPADStatus.__unnamed46__.pro pro Structure to use when extensionType is set to WPAD_EXT_PRO_CONTROLLER.
struct KPADStatus.__unnamed46__.balance balance Structure to use when extensionType is set to WPAD_EXT_BALANCE_BOARD.

Note: Balance Board support in KPAD seems to be incomplete, only weights and error members seem to hold useful data.

◆ KPADStatus.__unnamed46__.nunchuk

struct KPADStatus.__unnamed46__.nunchuk

Structure to use when extensionType is set to WPAD_EXT_NUNCHUK.

Definition at line 157 of file kpad.h.

Data Fields
KPADVec2D stick Position of the analog stick.
KPADVec3D acc Indicates the value of the acceleration sensor.
float accMagnitude Indicates the magnitude of acceleration.
float accVariation Indicates the variation in acceleration.
uint32_t hold Indicates what buttons are held down.
uint32_t trigger Indicates what buttons have been pressed since last sample.
uint32_t release Indicates what buttons have been released since last sample.

◆ KPADStatus.__unnamed46__.classic

struct KPADStatus.__unnamed46__.classic

Structure to use when extensionType is set to WPAD_EXT_CLASSIC.

Definition at line 176 of file kpad.h.

Data Fields
uint32_t hold Indicates what buttons are held down.
uint32_t trigger Indicates what buttons have been pressed since last sample.
uint32_t release Indicates what buttons have been released since last sample.
KPADVec2D leftStick Position of left analog stick.
KPADVec2D rightStick Position of right analog stick.
float leftTrigger Left trigger.
float rightTrigger Right trigger.

◆ KPADStatus.__unnamed46__.pro

struct KPADStatus.__unnamed46__.pro

Structure to use when extensionType is set to WPAD_EXT_PRO_CONTROLLER.

Definition at line 195 of file kpad.h.

Data Fields
uint32_t hold Indicates what buttons are held down.
uint32_t trigger Indicates what buttons have been pressed since last sample.
uint32_t release Indicates what buttons have been released since last sample.
KPADVec2D leftStick Position of left analog stick.
KPADVec2D rightStick Position of right analog stick.
int32_t charging Is charging flag.
int32_t wired Is wired flag.

◆ KPADStatus.__unnamed46__.balance

struct KPADStatus.__unnamed46__.balance

Structure to use when extensionType is set to WPAD_EXT_BALANCE_BOARD.

Note: Balance Board support in KPAD seems to be incomplete, only weights and error members seem to hold useful data.

Definition at line 219 of file kpad.h.

Data Fields
double avgTGCWeight Averaged corrected (total) weight, but it's always zero because calibration never completes.
double weights[WPAD_MAX_PRESSURE_SENSORS] Instantaneous uncorrected weights.
double avgWeights[WPAD_MAX_PRESSURE_SENSORS] Time-smoothed uncorrected weights, very slow to stabilize.
int32_t error Error generated from reading weights.
int32_t calibration Status of calibration: negative is error, otherwise is [0, 3], but KPAD never reaches level 3.

◆ KPADStatus.mplus

struct KPADStatus.mplus

Structure to use when MotionPlus is enabled.

Definition at line 237 of file kpad.h.

Data Fields
KPADVec3D acc Angular acceleration.
KPADVec3D angles Computed angles integrated from acceleration.
KPADVec3D dirX Computed X direction vector.
KPADVec3D dirY Computed Y direction vector.
KPADVec3D dirZ Computed Z direction vector.

◆ KPADUnifiedWpadStatus.__unnamed53__

union KPADUnifiedWpadStatus.__unnamed53__

Definition at line 319 of file kpad.h.

Data Fields
WPADStatus core
WPADStatusNunchuk nunchuk
WPADStatusClassic classic
WPADStatusPro pro
WPADStatusBalanceBoard balance
WPADStatusTrain train

Typedef Documentation

◆ KPADChan

typedef enum WPADChan KPADChan

Wii Remote channel.

Definition at line 18 of file kpad.h.

◆ KPADDataFormat

Data format.

Definition at line 20 of file kpad.h.

◆ KPADExtensionType

Extension type.

Definition at line 22 of file kpad.h.

◆ KPADMplsMode

typedef enum WPADMplsMode KPADMplsMode

MotionPlus Mode.

Definition at line 24 of file kpad.h.

◆ KPADStatus

typedef struct KPADStatus KPADStatus

Definition at line 26 of file kpad.h.

◆ KPADUnifiedWpadStatus

Definition at line 27 of file kpad.h.

◆ KPADVec2D

typedef struct KPADVec2D KPADVec2D

Definition at line 28 of file kpad.h.

◆ KPADVec3D

typedef struct KPADVec3D KPADVec3D

Definition at line 29 of file kpad.h.

◆ KPADError

typedef enum KPADError KPADError

Error.

◆ KPADControlMplsStatus

Status codes for KPADControlMplsCallback.

◆ KPADConnectCallback

Definition at line 340 of file kpad.h.

◆ KPADSamplingCallback

Definition at line 341 of file kpad.h.

◆ KPADControlMplsCallback

typedef void(* KPADControlMplsCallback) (KPADChan chan, KPADControlMplsStatus status)

Callback used for KPADSetControlMplsCallback().

Definition at line 344 of file kpad.h.

Enumeration Type Documentation

◆ KPADError

enum KPADError

Error.

Enumerator
KPAD_ERROR_OK 

No error occurred, and data was written to the buffers.

KPAD_ERROR_NO_SAMPLES 

There was no sample new data available to write.

KPAD_ERROR_INVALID_CONTROLLER 

The requested controller or channel was invalid.

KPAD_ERROR_WPAD_UNINIT 

WPAD is uninitialized, shouldn't happen unless WPADShutdown() is manually called.

KPAD_ERROR_BUSY 

KPAD channel is busy, perhaps being accessed by another thread.

KPAD_ERROR_UNINITIALIZED 

KPAD is uninitialized, need to call KPADInit()

Definition at line 32 of file kpad.h.

◆ KPADControlMplsStatus

Status codes for KPADControlMplsCallback.

Enumerator
KPAD_CONTROL_MPLS_STATUS_STARTED 

When KPADEnableMpls() is called.

KPAD_CONTROL_MPLS_STATUS_FINISHED 

When MotionPlus mode was set correctly, or wiimote disconnected prematurely.

KPAD_CONTROL_MPLS_STATUS_FAILED_MPLS_ONLY 

When KPADEnableMpls(chan, WPAD_MPLS_MODE_MPLS_ONLY) failed.

KPAD_CONTROL_MPLS_STATUS_FAILED_MPLS_NUNCHUK 

When KPADEnableMpls(chan, WPAD_MPLS_MODE_MPLS_NUNCHUK) failed.

KPAD_CONTROL_MPLS_STATUS_FAILED_MPLS_CLASSIC 

When KPADEnableMpls(chan, WPAD_MPLS_MODE_MPLS_CLASSIC) failed.

Definition at line 49 of file kpad.h.

Function Documentation

◆ KPADInit()

void KPADInit ( void  )

Initialises the KPAD library for use.

Note: this calls KPADInitEx(NULL, 0).

◆ KPADInitEx()

void KPADInitEx ( KPADUnifiedWpadStatus buffer,
uint32_t  count 
)

Initializes the KPAD library with extra buffers.

◆ KPADShutdown()

void KPADShutdown ( void  )

Cleans up and frees the KPAD library.

◆ KPADRead()

uint32_t KPADRead ( KPADChan  chan,
KPADStatus data,
uint32_t  size 
)

Read data from the desired controller.

Parameters
chanThe channel of the controller to read from.
dataThe KPADStatus to fill.
sizeThe maximum number of data to read.
Returns
The number of data read.

◆ KPADReadEx()

uint32_t KPADReadEx ( KPADChan  chan,
KPADStatus data,
uint32_t  size,
KPADError error 
)

Read data from the desired controller.

Parameters
chanThe channel of the controller to read from.
dataThe KPADStatus to fill.
sizeThe maximum number of data to read.
errorA pointer to an error code.
Returns
The number of data read.

◆ KPADGetUnifiedWpadStatus()

void KPADGetUnifiedWpadStatus ( KPADChan  chan,
KPADUnifiedWpadStatus buffer,
uint32_t  count 
)

Read a number of entries from the internal buffer.

◆ KPADSetMaxControllers()

int32_t KPADSetMaxControllers ( uint32_t  maxControllers)

Set the maximum amount of controllers which can be connected to the system.

Parameters
maxControllersThe maximum amount of controllers. Must be 4 or 7.
Returns
0 on success.

◆ KPADGetMaxControllers()

uint32_t KPADGetMaxControllers ( void  )

Get the maximum amount of controllers which can be connected to the system.

Returns
The maximum amount of controllers.

◆ KPADGetGameMaxControllers()

uint32_t KPADGetGameMaxControllers ( void  )

Get the maximum amount of controllers which can be connected, as reported by IOS-PAD.

Returns
The maximum amount of controllers.

◆ KPADSetConnectCallback()

KPADConnectCallback KPADSetConnectCallback ( KPADChan  chan,
KPADConnectCallback  callback 
)

Set a callback for when a controller connection status changes.

Parameters
chanThe channel of the controller to set a callback for.
callbackPointer to a callback function.
Returns
The previous connect callback.

◆ KPADSetSamplingCallback()

KPADSamplingCallback KPADSetSamplingCallback ( KPADChan  channel,
KPADSamplingCallback  callback 
)

◆ KPADGetMplsWorkSize()

uint32_t KPADGetMplsWorkSize ( void  )

Returns the amount of memory needed for KPADSetMplsWorkarea().

◆ KPADSetMplsWorkarea()

void KPADSetMplsWorkarea ( void *  buf)

Sets the extra memory KPAD will use to process MotionPlus data.

Without this work area, the mplus field in KPADStatus will be filled with zeros.

Parameters
bufA memory buffer with size obtained from KPADGetMplsWorkSize().

◆ KPADSetControlMplsCallback()

void KPADSetControlMplsCallback ( KPADChan  chan,
KPADControlMplsCallback  callback 
)

Set a callback for when the MotionPlus extension is configured.

Parameters
chanController channel to set the callback for.
callbackPointer to callback functio that will be invoked.
See also

◆ KPADEnableMpls()

void KPADEnableMpls ( KPADChan  channel,
KPADMplsMode  mode 
)

Sets MotionPlus for the controller in specified mode.

Parameters
modeThe MotionPlus mode which should be used, the mode may be ignored and a different mode used, usually because the required extension is not connected. Make sure to check result with KPADGetMplsStatus
See also

◆ KPADDisableMpls()

void KPADDisableMpls ( KPADChan  channel)

Disables MotionPlus for the controller.

◆ KPADGetMplsStatus()

KPADMplsMode KPADGetMplsStatus ( KPADChan  chan)

Get MotionPlus mode.

identical to WPADiGetMplsStatus

◆ KPADResetMpls()

void KPADResetMpls ( KPADChan  chan)

Resets the MotionPlus state.

◆ KPADEnableDPD()

void KPADEnableDPD ( KPADChan  chan)

Enable IR pointing.

◆ KPADDisableDPD()

void KPADDisableDPD ( KPADChan  chan)

Disable IR pointing.

◆ KPADResetWbcZeroPoint()

void KPADResetWbcZeroPoint ( void  )

Resets the Balance Board's zero.

◆ KPADResetWbcTgcWeight()

void KPADResetWbcTgcWeight ( void  )

Recalculate the Balance Board's TGC coefficients and zero.