8#ifndef __LIBDRAGON_CONTROLLER_H
9#define __LIBDRAGON_CONTROLLER_H
45#define CONTROLLER_1_INSERTED 0xF000
47#define CONTROLLER_2_INSERTED 0x0F00
49#define CONTROLLER_3_INSERTED 0x00F0
51#define CONTROLLER_4_INSERTED 0x000F
62#define ACCESSORY_NONE 0
64#define ACCESSORY_MEMPAK 1
66#define ACCESSORY_RUMBLEPAK 2
68#define ACCESSORY_VRU 3
70#define ACCESSORY_TRANSFERPAK 4
83#define ERROR_BAD_COMMAND 0x1
85#define ERROR_NOT_PRESENT 0x2
97typedef struct SI_condat
111 unsigned int data : 32;
144 unsigned C_right : 1;
162typedef struct SI_condat_gc
174 unsigned origin_unchecked : 1;
180 unsigned unused2 : 1;
188 unsigned stick_x : 8;
189 unsigned stick_y : 8;
191 unsigned cstick_x : 8;
192 unsigned cstick_y : 8;
193 unsigned analog_l : 8;
194 unsigned analog_r : 8;
208 struct SI_condat_gc data;
223typedef struct controller_data
226 struct SI_condat c[4];
228 struct SI_condat_gc gc[4];
237typedef struct controller_origin_data
249__attribute__((deprecated(
"use joybus_exec_cmd instead")))
250void execute_raw_command(
255 const
void *send_data,
260void controller_read( struct controller_data * data );
263void controller_read_gc( struct controller_data * data, const uint8_t rumble[4] );
265__attribute__((deprecated("use joypad subsystem instead")))
266void controller_read_gc_origin( struct controller_origin_data * data);
268__attribute__((deprecated("use
joypad_init instead")))
269void controller_init(
void );
271__attribute__((deprecated("use
joypad_poll instead")))
272void controller_scan(
void );
275struct controller_data get_keys_down(
void );
278struct controller_data get_keys_up(
void );
281struct controller_data get_keys_held(
void );
284struct controller_data get_keys_pressed(
void );
287int get_controllers_present(
void );
290int get_accessories_present( struct controller_data * data );
293int identify_accessory(
int controller );
296int get_dpad_direction(
int controller );
299int read_mempak_address(
int controller, uint16_t address, uint8_t *data );
302int write_mempak_address(
int controller, uint16_t address, uint8_t *data );
305void rumble_start(
int controller );
308void rumble_stop(
int controller );
unsigned err
Status of the last command.
Definition controller.h:102
SI GameCube controller origin data for all controller ports.
Definition controller.h:238
SI controller data for all controller ports.
Definition controller.h:224
SI GameCube controller origin data.
Definition controller.h:207
SI Nintendo 64 controller data.
Definition controller.h:98
SI GameCube controller data.
Definition controller.h:163
int joybus_accessory_read(int port, uint16_t addr, uint8_t *data)
Synchronously perform a Joybus N64 accessory read command.
Definition joybus_accessory.c:132
int joybus_accessory_write(int port, uint16_t addr, const uint8_t *data)
Synchronously perform a Joybus N64 accessory write command.
Definition joybus_accessory.c:146
void joypad_set_rumble_active(joypad_port_t port, bool active)
Activate or deactivate rumble on a Joypad port.
Definition joypad.c:918
joypad_8way_t joypad_get_direction(joypad_port_t port, joypad_2d_t axes)
Get the 8-way direction for a Joypad port's directional axes.
Definition joypad.c:1106
joypad_inputs_t joypad_read_n64_inputs(joypad_port_t port)
Read the inputs from a Nintendo 64 controller synchronously.
Definition joypad.c:687
joypad_inputs_t joypad_get_inputs(joypad_port_t port)
Get the current Joypad inputs state for a Joypad port.
Definition joypad.c:940
joypad_accessory_type_t joypad_get_accessory_type(joypad_port_t port)
Get the Joypad accessory type for a Joypad port.
Definition joypad.c:876
void joypad_init(void)
Initialize the Joypad subsystem.
Definition joypad.c:713
joypad_buttons_t joypad_get_buttons_released(joypad_port_t port)
Get the Joypad buttons that were released since the last time Joypads were read for a Joypad port.
Definition joypad.c:964
void joypad_poll(void)
Fetch the current Joypad input state.
Definition joypad.c:750
joypad_buttons_t joypad_get_buttons_held(joypad_port_t port)
Get the Joypad buttons that are held down since the last time Joypads were read for a Joypad port.
Definition joypad.c:973
joypad_buttons_t joypad_get_buttons_pressed(joypad_port_t port)
Get the Joypad buttons that were pressed since the last time Joypads were read for a Joypad port.
Definition joypad.c:955
joybus_identifier_t joypad_get_identifier(joypad_port_t port)
Get the Joybus device identifier for a Joypad port.
Definition joypad.c:862
Joybus accessory utilities.