libjoybus
Joybus implementation for 32-bit MCUs
Loading...
Searching...
No Matches
GameCube Controller Target

Joybus target implementation for standard GameCube controllers and WaveBird receivers. More...

Data Structures

struct  joybus_target_gcn_controller
 GameCube controller Joybus target. More...

Macros

#define JOYBUS_TARGET_GCN_CONTROLLER(target)
 Macro to cast from a generic Joybus target to a GameCube controller target.

Typedefs

typedef void(* joybus_target_gcn_controller_reset_cb) (struct joybus_target_gcn_controller *controller)
 Callback type for GameCube controller reset events.
typedef void(* joybus_target_gcn_controller_motor_cb) (struct joybus_target_gcn_controller *controller, uint8_t state)
 Callback type for GameCube controller motor state change events.

Functions

void joybus_target_gcn_controller_init_with_type (struct joybus_target_gcn_controller *controller, uint16_t type)
 Initialize a GameCube controller target with a specific controller type.
static void joybus_target_gcn_controller_init (struct joybus_target_gcn_controller *controller)
 Initialize a GameCube controller target as a regular wired controller.
static void joybus_target_gcn_controller_init_wavebird (struct joybus_target_gcn_controller *controller)
 Initialize a GameCube controller target as a WaveBird receiver.
void joybus_target_gcn_controller_set_reset_cb (struct joybus_target_gcn_controller *controller, joybus_target_gcn_controller_reset_cb callback)
 Set the reset callback for the controller.
void joybus_target_gcn_controller_set_motor_cb (struct joybus_target_gcn_controller *controller, joybus_target_gcn_controller_motor_cb callback)
 Set the motor state change callback for the controller.
static bool joybus_target_gcn_controller_is_wireless (struct joybus_target_gcn_controller *controller)
 Check if the controller is a WaveBird controller.
void joybus_target_gcn_controller_set_wireless_id (struct joybus_target_gcn_controller *controller, uint16_t wireless_id)
 Set the wireless ID of the controller.
static uint16_t joybus_target_gcn_controller_get_wireless_id (struct joybus_target_gcn_controller *controller)
 Get the current wireless ID of the controller.
static bool joybus_target_gcn_controller_wireless_id_fixed (struct joybus_target_gcn_controller *controller)
 Determine if the wireless ID has been fixed.
static void joybus_target_gcn_controller_input_valid (struct joybus_target_gcn_controller *controller, bool valid)
 Mark the input state as valid.
void joybus_target_gcn_controller_set_origin (struct joybus_target_gcn_controller *controller, struct joybus_gcn_controller_state *new_origin)
 Update the origin of the controller.

Detailed Description

Joybus target implementation for standard GameCube controllers and WaveBird receivers.

Macro Definition Documentation

◆ JOYBUS_TARGET_GCN_CONTROLLER

#define JOYBUS_TARGET_GCN_CONTROLLER ( target)
Value:
((struct joybus_target_gcn_controller *)(target))
GameCube controller Joybus target.
Definition gcn_controller.h:41

Macro to cast from a generic Joybus target to a GameCube controller target.

Typedef Documentation

◆ joybus_target_gcn_controller_motor_cb

typedef void(* joybus_target_gcn_controller_motor_cb) (struct joybus_target_gcn_controller *controller, uint8_t state)

Callback type for GameCube controller motor state change events.

Parameters
controllerthe controller whose motor state changed
statethe new motor state

◆ joybus_target_gcn_controller_reset_cb

typedef void(* joybus_target_gcn_controller_reset_cb) (struct joybus_target_gcn_controller *controller)

Callback type for GameCube controller reset events.

Parameters
controllerthe controller that was reset

Function Documentation

◆ joybus_target_gcn_controller_get_wireless_id()

uint16_t joybus_target_gcn_controller_get_wireless_id ( struct joybus_target_gcn_controller * controller)
inlinestatic

Get the current wireless ID of the controller.

Parameters
controllerthe controller to get the wireless ID from
Returns
the current 10-bit wireless ID

◆ joybus_target_gcn_controller_init()

void joybus_target_gcn_controller_init ( struct joybus_target_gcn_controller * controller)
inlinestatic

Initialize a GameCube controller target as a regular wired controller.

Parameters
controllerthe controller to initialize

◆ joybus_target_gcn_controller_init_wavebird()

void joybus_target_gcn_controller_init_wavebird ( struct joybus_target_gcn_controller * controller)
inlinestatic

Initialize a GameCube controller target as a WaveBird receiver.

Parameters
controllerthe controller to initialize

◆ joybus_target_gcn_controller_init_with_type()

void joybus_target_gcn_controller_init_with_type ( struct joybus_target_gcn_controller * controller,
uint16_t type )

Initialize a GameCube controller target with a specific controller type.

Parameters
controllerthe controller to initialize
typethe controller type flags

◆ joybus_target_gcn_controller_input_valid()

void joybus_target_gcn_controller_input_valid ( struct joybus_target_gcn_controller * controller,
bool valid )
inlinestatic

Mark the input state as valid.

When the input state is marked valid, we'll use the contents of controller->input when replying to poll commands, otherwise we'll use the origin state.

Parameters
controllerthe controller to set the input state for
validtrue if the input state is valid

◆ joybus_target_gcn_controller_is_wireless()

bool joybus_target_gcn_controller_is_wireless ( struct joybus_target_gcn_controller * controller)
inlinestatic

Check if the controller is a WaveBird controller.

Parameters
controllerthe controller to check
Returns
true if the controller is a WaveBird controller

◆ joybus_target_gcn_controller_set_motor_cb()

void joybus_target_gcn_controller_set_motor_cb ( struct joybus_target_gcn_controller * controller,
joybus_target_gcn_controller_motor_cb callback )

Set the motor state change callback for the controller.

NOTE: Motor state callbacks are called from interrupt context, do not perform any blocking operations within the callback.

Parameters
controllerthe controller to set the callback for
callbackthe callback function

◆ joybus_target_gcn_controller_set_origin()

void joybus_target_gcn_controller_set_origin ( struct joybus_target_gcn_controller * controller,
struct joybus_gcn_controller_state * new_origin )

Update the origin of the controller.

If the origin data differs from the current origin, the "need origin" flag is set.

Parameters
controllerthe controller to set the wireless origin for
new_originpointer to the new origin data (6 bytes)

◆ joybus_target_gcn_controller_set_reset_cb()

void joybus_target_gcn_controller_set_reset_cb ( struct joybus_target_gcn_controller * controller,
joybus_target_gcn_controller_reset_cb callback )

Set the reset callback for the controller.

NOTE: Reset callbacks are called from interrupt context, do not perform any blocking operations within the callback.

Parameters
controllerthe controller to set the callback for
callbackthe callback function

◆ joybus_target_gcn_controller_set_wireless_id()

void joybus_target_gcn_controller_set_wireless_id ( struct joybus_target_gcn_controller * controller,
uint16_t wireless_id )

Set the wireless ID of the controller.

Wireless IDs are 10-bit numbers used to identify a WaveBird controller. Although these IDs aren’t globally unique, they are assumed to be distinct enough so that it’s unlikely for a single user to have two controllers with the same ID. The ID helps bind a controller to a specific port after data reception.

Parameters
controllerthe controller to set the wireless ID for
wireless_idthe new 10-bit wireless ID

◆ joybus_target_gcn_controller_wireless_id_fixed()

bool joybus_target_gcn_controller_wireless_id_fixed ( struct joybus_target_gcn_controller * controller)
inlinestatic

Determine if the wireless ID has been fixed.

Fixing the wireless ID is used to bind a WaveBird controller to a specific receiver.

Parameters
controllerthe controller to check
Returns
true if the wireless ID is fixed