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

GameCube controller Joybus target. More...

Data Structures

struct  joybus_gc_controller
 GameCube controller Joybus target. More...

Macros

#define JOYBUS_GC_CONTROLLER(target)
 Macro to cast to a GameCube controller target.

Typedefs

typedef void(* joybus_gc_controller_reset_cb_t) (struct joybus_gc_controller *controller)
 Callback type for GameCube controller reset events.
typedef void(* joybus_gc_controller_motor_cb_t) (struct joybus_gc_controller *controller, uint8_t state)
 Callback type for GameCube controller motor state change events.

Functions

void joybus_gc_controller_init (struct joybus_gc_controller *controller, uint16_t type)
 Initialize a GameCube controller.
static bool joybus_gc_controller_is_wireless (struct joybus_gc_controller *controller)
 Check if the controller is a WaveBird controller.
void joybus_gc_controller_set_wireless_id (struct joybus_gc_controller *controller, uint16_t wireless_id)
 Set the wireless ID of the controller.
static uint16_t joybus_gc_controller_get_wireless_id (struct joybus_gc_controller *controller)
 Get the current wireless ID of the controller.
static bool joybus_gc_controller_wireless_id_fixed (struct joybus_gc_controller *controller)
 Determine if the wireless ID has been fixed.
static void joybus_gc_controller_input_valid (struct joybus_gc_controller *controller, bool valid)
 Mark the input state as valid.
void joybus_gc_controller_set_origin (struct joybus_gc_controller *controller, struct joybus_gc_controller_input *new_origin)
 Update the origin of the controller.

Detailed Description

GameCube controller Joybus target.

Macro Definition Documentation

◆ JOYBUS_GC_CONTROLLER

#define JOYBUS_GC_CONTROLLER ( target)
Value:
((struct joybus_gc_controller *)(target))
GameCube controller Joybus target.
Definition gc_controller.h:38

Macro to cast to a GameCube controller target.

Typedef Documentation

◆ joybus_gc_controller_motor_cb_t

typedef void(* joybus_gc_controller_motor_cb_t) (struct joybus_gc_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_gc_controller_reset_cb_t

typedef void(* joybus_gc_controller_reset_cb_t) (struct joybus_gc_controller *controller)

Callback type for GameCube controller reset events.

Parameters
controllerthe controller that was reset

Function Documentation

◆ joybus_gc_controller_get_wireless_id()

uint16_t joybus_gc_controller_get_wireless_id ( struct joybus_gc_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_gc_controller_init()

void joybus_gc_controller_init ( struct joybus_gc_controller * controller,
uint16_t type )

Initialize a GameCube controller.

This function sets up the initial state, and registers SI command handlers for OEM GameCube controller, and WaveBird controller commands.

Parameters
controllerthe controller to initialize
typethe device type flags

◆ joybus_gc_controller_input_valid()

void joybus_gc_controller_input_valid ( struct joybus_gc_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_gc_controller_is_wireless()

bool joybus_gc_controller_is_wireless ( struct joybus_gc_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_gc_controller_set_origin()

void joybus_gc_controller_set_origin ( struct joybus_gc_controller * controller,
struct joybus_gc_controller_input * 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_gc_controller_set_wireless_id()

void joybus_gc_controller_set_wireless_id ( struct joybus_gc_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_gc_controller_wireless_id_fixed()

bool joybus_gc_controller_wireless_id_fixed ( struct joybus_gc_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