14#include <joybus/target.h>
19#define JOYBUS_GC_CONTROLLER(target) ((struct joybus_gc_controller *)(target))
133 return (controller->id[1] & 0xC0) << 2 | controller->id[2];
Joybus command codes and utilities.
#define JOYBUS_ID_GCN_WIRELESS_ID_FIXED
Wireless ID has been fixed.
Definition commands.h:97
static uint16_t joybus_id_get_type(const uint8_t *id)
Get the controller type from an "identify" buffer.
Definition commands.h:127
#define JOYBUS_ID_GCN_WIRELESS
Controller is wireless.
Definition commands.h:104
static uint16_t joybus_gc_controller_get_wireless_id(struct joybus_gc_controller *controller)
Get the current wireless ID of the controller.
Definition gc_controller.h:131
void joybus_gc_controller_set_origin(struct joybus_gc_controller *controller, struct joybus_gc_controller_input *new_origin)
Update the origin of the controller.
Definition gc_controller.c:400
static bool joybus_gc_controller_is_wireless(struct joybus_gc_controller *controller)
Check if the controller is a WaveBird controller.
Definition gc_controller.h:106
void joybus_gc_controller_init(struct joybus_gc_controller *controller, uint16_t type)
Initialize a GameCube controller.
Definition gc_controller.c:352
void joybus_gc_controller_set_wireless_id(struct joybus_gc_controller *controller, uint16_t wireless_id)
Set the wireless ID of the controller.
Definition gc_controller.c:388
void joybus_gc_controller_set_motor_callback(struct joybus_gc_controller *controller, joybus_gc_controller_motor_cb_t callback)
Set the motor state change callback for the controller.
Definition gc_controller.c:382
static bool joybus_gc_controller_wireless_id_fixed(struct joybus_gc_controller *controller)
Determine if the wireless ID has been fixed.
Definition gc_controller.h:145
void(* joybus_gc_controller_reset_cb_t)(struct joybus_gc_controller *controller)
Callback type for GameCube controller reset events.
Definition gc_controller.h:26
static void joybus_gc_controller_input_valid(struct joybus_gc_controller *controller, bool valid)
Mark the input state as valid.
Definition gc_controller.h:159
void(* joybus_gc_controller_motor_cb_t)(struct joybus_gc_controller *controller, uint8_t state)
Callback type for GameCube controller motor state change events.
Definition gc_controller.h:34
void joybus_gc_controller_set_reset_callback(struct joybus_gc_controller *controller, joybus_gc_controller_reset_cb_t callback)
Set the reset callback for the controller.
Definition gc_controller.c:376
GameCube controller Joybus target.
Definition gc_controller.h:39
joybus_gc_controller_motor_cb_t on_motor_state_change
Callback for controller motor state change events.
Definition gc_controller.h:61
joybus_gc_controller_reset_cb_t on_reset
Callback for controller reset events.
Definition gc_controller.h:58
uint8_t packed_input[8]
Packed input state buffer.
Definition gc_controller.h:52
struct joybus_gc_controller_input input
Current input state.
Definition gc_controller.h:49
struct joybus_target base
Controller ID.
Definition gc_controller.h:40
struct joybus_gc_controller_input origin
Origin input state.
Definition gc_controller.h:46
bool input_valid
Whether the input state is valid.
Definition gc_controller.h:55
A Joybus target, a device on the Joybus that can respond to commands.
Definition target.h:45