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

Interface for implementing Joybus targets (controllers). More...

Topics

 GameCube Controller Target
 GameCube controller Joybus target.
 N64 Controller Target
 N64 controller Joybus target.

Data Structures

struct  joybus_target_api
struct  joybus_target
 A Joybus target, a device on the Joybus that can respond to commands. More...

Macros

#define JOYBUS_TARGET(target)
 Macro to cast a concrete Joybus target instance to a generic Joybus target instance.

Typedefs

typedef void(* joybus_target_response_cb_t) (const uint8_t *response, uint8_t len, void *user_data)
 Callback type for sending responses from target command handlers.

Functions

static int joybus_target_byte_received (struct joybus_target *target, const uint8_t *command, uint8_t byte_idx, joybus_target_response_cb_t send_response, void *user_data)
 Handle a received command byte for a Joybus target.

Detailed Description

Interface for implementing Joybus targets (controllers).

Macro Definition Documentation

◆ JOYBUS_TARGET

#define JOYBUS_TARGET ( target)
Value:
((struct joybus_target *)(target))
A Joybus target, a device on the Joybus that can respond to commands.
Definition target.h:45

Macro to cast a concrete Joybus target instance to a generic Joybus target instance.

Typedef Documentation

◆ joybus_target_response_cb_t

typedef void(* joybus_target_response_cb_t) (const uint8_t *response, uint8_t len, void *user_data)

Callback type for sending responses from target command handlers.

Parameters
responsethe response data to send
lenthe length of the response data
user_datauser data passed to the command handler

Function Documentation

◆ joybus_target_byte_received()

int joybus_target_byte_received ( struct joybus_target * target,
const uint8_t * command,
uint8_t byte_idx,
joybus_target_response_cb_t send_response,
void * user_data )
inlinestatic

Handle a received command byte for a Joybus target.

Parameters
targetthe target to handle the command
commandthe command buffer
byte_idxthe index of the byte that was just received
send_responsea callback function to send the response
user_datauser data to pass to the response callback
Returns
positive number of bytes still expected, 0 if no more bytes expected, negative error code on failure