wut  v1.5.0
Wii U Toolchain
Data Structures | Macros | Typedefs | Enumerations | Functions
Nn_hpad_hpad

Functions for using the USB Gamecube Controller Adapter. More...

Collaboration diagram for Nn_hpad_hpad:

Data Structures

struct  HPADStatus
 
struct  HPADGGGGStatus
 

Macros

#define HPAD_STICK_AXIS_MIN   -56
 The minimum value of the stick axis. More...
 
#define HPAD_STICK_AXIS_MAX   56
 The maximum value of the stick axis. More...
 
#define HPAD_SUBSTICK_AXIS_MIN   -44
 The minimum value of the substick axis. More...
 
#define HPAD_SUBSTICK_AXIS_MAX   44
 The maximum value of the substick axis. More...
 
#define HPAD_TRIGGER_MIN   0
 The minimum value of the trigger. More...
 
#define HPAD_TRIGGER_MAX   150
 The maximum value of the trigger. More...
 

Typedefs

typedef struct HPADStatus HPADStatus
 
typedef struct HPADGGGGStatus HPADGGGGStatus
 
typedef enum HPADChan HPADChan
 
typedef enum HPADGGGGChan HPADGGGGChan
 
typedef enum HPADButtons HPADButtons
 
typedef enum HPADMotorCommand HPADMotorCommand
 
typedef void(* HPADConnectCallback) (HPADChan chan, int32_t status)
 
typedef void(* HPADGGGGConnectCallback) (HPADGGGGChan chan, BOOL connected)
 
typedef void(* HPADPowerSupplyCallback) (HPADGGGGChan chan, BOOL connected)
 
typedef void(* HPADSamplingCallback) (HPADGGGGChan chan)
 
typedef void(* HPADResetCallback) (HPADGGGGChan chan, int32_t status)
 

Enumerations

enum  HPADChan {
  HPAD_CHAN_0 = 0 ,
  HPAD_CHAN_1 = 1 ,
  HPAD_CHAN_2 = 2 ,
  HPAD_CHAN_3 = 3 ,
  HPAD_CHAN_4 = 4 ,
  HPAD_CHAN_5 = 5 ,
  HPAD_CHAN_6 = 6 ,
  HPAD_CHAN_7 = 7
}
 
enum  HPADGGGGChan {
  HPAD_GGGG_CHAN_0 = 0 ,
  HPAD_GGGG_CHAN_1 = 1
}
 
enum  HPADButtons {
  HPAD_BUTTON_A = 0x0001 ,
  HPAD_BUTTON_B = 0x0002 ,
  HPAD_BUTTON_X = 0x0004 ,
  HPAD_BUTTON_Y = 0x0008 ,
  HPAD_BUTTON_LEFT = 0x0010 ,
  HPAD_BUTTON_RIGHT = 0x0020 ,
  HPAD_BUTTON_DOWN = 0x0040 ,
  HPAD_BUTTON_UP = 0x0080 ,
  HPAD_BUTTON_START = 0x0100 ,
  HPAD_TRIGGER_Z = 0x0200 ,
  HPAD_TRIGGER_R = 0x0400 ,
  HPAD_TRIGGER_L = 0x0800 ,
  HPAD_STICK_EMULATION_LEFT = 0x00001000 ,
  HPAD_STICK_EMULATION_RIGHT = 0x00002000 ,
  HPAD_STICK_EMULATION_DOWN = 0x00004000 ,
  HPAD_STICK_EMULATION_UP = 0x00008000 ,
  HPAD_SUBSTICK_EMULATION_LEFT = 0x00010000 ,
  HPAD_SUBSTICK_EMULATION_RIGHT = 0x00020000 ,
  HPAD_SUBSTICK_EMULATION_DOWN = 0x00040000 ,
  HPAD_SUBSTICK_EMULATION_UP = 0x00080000
}
 
enum  HPADMotorCommand {
  HPAD_MOTOR_COMMAND_STOP = 0 ,
  HPAD_MOTOR_COMMAND_RUMBLE = 1 ,
  HPAD_MOTOR_COMMAND_STOP_HARD = 2
}
 

Functions

int32_t HPADInit (void)
 Initializes the HPAD library. More...
 
int32_t HPADShutdown (void)
 Shuts down the HPAD library. More...
 
int32_t RPLWRAP() HPADRead (HPADChan chan, HPADStatus *buffers, int32_t count)
 Reads status buffers from a specified HPAD channel. More...
 
int32_t HPADControlMotor (HPADChan chan, HPADMotorCommand command)
 Sends a motor/rumble command to the specified HPAD channel. More...
 
int32_t HPADRecalibrate (HPADChan chan)
 Invalidates calibration data of the specified HPAD channel. More...
 
HPADConnectCallback HPADSetConnectCallback (HPADChan chan, HPADConnectCallback callback)
 Sets a callback for once the specified HPAD channel is connected. More...
 
int32_t HPADGetGGGGStatus (HPADGGGGChan chan, HPADGGGGStatus *status)
 Get the status of the specified GGGG channel (GC Adapter). More...
 
HPADGGGGConnectCallback HPADSetGgggConnectCallback (HPADGGGGChan chan, HPADGGGGConnectCallback callback)
 Sets a callback for once the specified GGGG Adapter is connected. More...
 
HPADPowerSupplyCallback HPADSetPowerSupplyCallback (HPADGGGGChan chan, HPADPowerSupplyCallback callback)
 Sets a callback for once the power supply of the specified GGGG Adapter is connected. More...
 
HPADSamplingCallback HPADSetSamplingCallback (HPADGGGGChan chan, HPADSamplingCallback callback)
 Sets a callback for once a sample is received from the specified GGGG Adapter. More...
 
int32_t HPADResetDevice (HPADGGGGChan chan, HPADResetCallback callback)
 Resets the specified GGGG Adapter. More...
 

Detailed Description

Functions for using the USB Gamecube Controller Adapter.


Data Structure Documentation

◆ HPADStatus

struct HPADStatus

Definition at line 83 of file hpad.h.

Data Fields
int32_t hold Indicates what HPADButtons are held down.
int32_t trigger Indicates what HPADButtons have been pressed since last sample.
int32_t release Indicates what HPADButtons have been released since last sample.
int8_t stickX X-Position of the analog stick.
int8_t stickY Y-Position of the analog stick.
int8_t substickX X-Position of the analog substick/C-Stick.
int8_t substickY Y-Position of the analog substick/C-Stick.
uint8_t triggerL Position of the left analog trigger.
uint8_t triggerR Position of the right analog trigger.
uint8_t status Status of the controller.
int32_t error Read error, 0 for success.

◆ HPADGGGGStatus

struct HPADGGGGStatus

Definition at line 122 of file hpad.h.

Data Fields
BOOL connected TRUE if the adapeter is connected
BOOL powerSupplyConnected TRUE if the power supply is connected
BOOL active TRUE if the adapter is active/is sending samples

Macro Definition Documentation

◆ HPAD_STICK_AXIS_MIN

#define HPAD_STICK_AXIS_MIN   -56

The minimum value of the stick axis.

Definition at line 16 of file hpad.h.

◆ HPAD_STICK_AXIS_MAX

#define HPAD_STICK_AXIS_MAX   56

The maximum value of the stick axis.

Definition at line 18 of file hpad.h.

◆ HPAD_SUBSTICK_AXIS_MIN

#define HPAD_SUBSTICK_AXIS_MIN   -44

The minimum value of the substick axis.

Definition at line 20 of file hpad.h.

◆ HPAD_SUBSTICK_AXIS_MAX

#define HPAD_SUBSTICK_AXIS_MAX   44

The maximum value of the substick axis.

Definition at line 22 of file hpad.h.

◆ HPAD_TRIGGER_MIN

#define HPAD_TRIGGER_MIN   0

The minimum value of the trigger.

Definition at line 24 of file hpad.h.

◆ HPAD_TRIGGER_MAX

#define HPAD_TRIGGER_MAX   150

The maximum value of the trigger.

Definition at line 26 of file hpad.h.

Typedef Documentation

◆ HPADStatus

typedef struct HPADStatus HPADStatus

Definition at line 1 of file hpad.h.

◆ HPADGGGGStatus

Definition at line 1 of file hpad.h.

◆ HPADChan

typedef enum HPADChan HPADChan

◆ HPADGGGGChan

typedef enum HPADGGGGChan HPADGGGGChan

◆ HPADButtons

typedef enum HPADButtons HPADButtons

◆ HPADMotorCommand

◆ HPADConnectCallback

typedef void(* HPADConnectCallback) (HPADChan chan, int32_t status)

Definition at line 136 of file hpad.h.

◆ HPADGGGGConnectCallback

typedef void(* HPADGGGGConnectCallback) (HPADGGGGChan chan, BOOL connected)

Definition at line 137 of file hpad.h.

◆ HPADPowerSupplyCallback

typedef void(* HPADPowerSupplyCallback) (HPADGGGGChan chan, BOOL connected)

Definition at line 138 of file hpad.h.

◆ HPADSamplingCallback

typedef void(* HPADSamplingCallback) (HPADGGGGChan chan)

Definition at line 139 of file hpad.h.

◆ HPADResetCallback

typedef void(* HPADResetCallback) (HPADGGGGChan chan, int32_t status)

Definition at line 140 of file hpad.h.

Enumeration Type Documentation

◆ HPADChan

enum HPADChan
Enumerator
HPAD_CHAN_0 
HPAD_CHAN_1 
HPAD_CHAN_2 
HPAD_CHAN_3 
HPAD_CHAN_4 
HPAD_CHAN_5 
HPAD_CHAN_6 
HPAD_CHAN_7 

Definition at line 31 of file hpad.h.

◆ HPADGGGGChan

Enumerator
HPAD_GGGG_CHAN_0 

Adapter Channel 0.

HPAD_GGGG_CHAN_1 

Adapter Channel 1.

Definition at line 43 of file hpad.h.

◆ HPADButtons

Enumerator
HPAD_BUTTON_A 
HPAD_BUTTON_B 
HPAD_BUTTON_X 
HPAD_BUTTON_Y 
HPAD_BUTTON_LEFT 
HPAD_BUTTON_RIGHT 
HPAD_BUTTON_DOWN 
HPAD_BUTTON_UP 
HPAD_BUTTON_START 
HPAD_TRIGGER_Z 
HPAD_TRIGGER_R 
HPAD_TRIGGER_L 
HPAD_STICK_EMULATION_LEFT 
HPAD_STICK_EMULATION_RIGHT 
HPAD_STICK_EMULATION_DOWN 
HPAD_STICK_EMULATION_UP 
HPAD_SUBSTICK_EMULATION_LEFT 
HPAD_SUBSTICK_EMULATION_RIGHT 
HPAD_SUBSTICK_EMULATION_DOWN 
HPAD_SUBSTICK_EMULATION_UP 

Definition at line 51 of file hpad.h.

◆ HPADMotorCommand

Enumerator
HPAD_MOTOR_COMMAND_STOP 
HPAD_MOTOR_COMMAND_RUMBLE 
HPAD_MOTOR_COMMAND_STOP_HARD 

Definition at line 76 of file hpad.h.

Function Documentation

◆ HPADInit()

int32_t HPADInit ( void  )

Initializes the HPAD library.

Returns
0 on success.

◆ HPADShutdown()

int32_t HPADShutdown ( void  )

Shuts down the HPAD library.

Returns
0 on success.

◆ HPADRead()

static int32_t HPADRead ( HPADChan  chan,
HPADStatus buffers,
int32_t  count 
)
inline

Reads status buffers from a specified HPAD channel.

Warning
The count parameter is ignored and this function will always fill up to 16 sampling buffers. Make sure to always make space for 16 buffers.
Parameters
chanThe channel to read from.
buffersPointer to an array of HPADStatus buffers to fill.
countNumber of buffers to fill.
Returns
The amount of buffers read or a negative value on error.
Parameters
chanThe channel to read from.
buffersPointer to an array of HPADStatus buffers to fill.
countNumber of buffers to fill. Must be 16.
Returns
The amount of buffers read or a negative value on error.

Definition at line 200 of file hpad.h.

◆ HPADControlMotor()

int32_t HPADControlMotor ( HPADChan  chan,
HPADMotorCommand  command 
)

Sends a motor/rumble command to the specified HPAD channel.

Parameters
chanThe channel to send the command to.
commandThe motor command to send.
Returns
0 on success.

◆ HPADRecalibrate()

int32_t HPADRecalibrate ( HPADChan  chan)

Invalidates calibration data of the specified HPAD channel.

Parameters
chanThe channel to invalidate data.
Returns
0 on success.

◆ HPADSetConnectCallback()

HPADConnectCallback HPADSetConnectCallback ( HPADChan  chan,
HPADConnectCallback  callback 
)

Sets a callback for once the specified HPAD channel is connected.

Parameters
chanThe channel to set the callback.
callbackA pointer to the callback function.
Returns
A pointer to the previous callback or NULL.

◆ HPADGetGGGGStatus()

int32_t HPADGetGGGGStatus ( HPADGGGGChan  chan,
HPADGGGGStatus status 
)

Get the status of the specified GGGG channel (GC Adapter).

Parameters
chanThe channel to get the status from.
statusA pointer to write the status to.
Returns
0 on success.

◆ HPADSetGgggConnectCallback()

HPADGGGGConnectCallback HPADSetGgggConnectCallback ( HPADGGGGChan  chan,
HPADGGGGConnectCallback  callback 
)

Sets a callback for once the specified GGGG Adapter is connected.

Parameters
chanThe channel to set the callback.
callbackA pointer to the callback function.
Returns
A pointer to the previous callback or NULL.

◆ HPADSetPowerSupplyCallback()

HPADPowerSupplyCallback HPADSetPowerSupplyCallback ( HPADGGGGChan  chan,
HPADPowerSupplyCallback  callback 
)

Sets a callback for once the power supply of the specified GGGG Adapter is connected.

Parameters
chanThe channel to set the callback.
callbackA pointer to the callback function.
Returns
A pointer to the previous callback or NULL.

◆ HPADSetSamplingCallback()

HPADSamplingCallback HPADSetSamplingCallback ( HPADGGGGChan  chan,
HPADSamplingCallback  callback 
)

Sets a callback for once a sample is received from the specified GGGG Adapter.

Parameters
chanThe channel to set the callback.
callbackA pointer to the callback function.
Returns
A pointer to the previous callback or NULL.

◆ HPADResetDevice()

int32_t HPADResetDevice ( HPADGGGGChan  chan,
HPADResetCallback  callback 
)

Resets the specified GGGG Adapter.

Parameters
chanThe channel to reset.
callbackA pointer to a callback function after resetting is complete.
Returns
0 on success.