libdragon
Loading...
Searching...
No Matches
Modules | Files | Data Structures
Controller Subsystem

Controller and accessory interface. More...

Modules

 Controller Pak Filesystem Routines
 Managed Controller Pak interface.
 
 Transfer Pak interface
 Transfer Pak interface.
 

Files

file  controller.c
 Controller Subsystem.
 
file  controller.h
 Controller Subsystem.
 

Data Structures

struct  _SI_condat
 SI Nintendo 64 controller data. More...
 
struct  _SI_condat_gc
 SI GameCube controller data. More...
 
struct  SI_origdat_gc
 SI GameCube controller origin data. More...
 
struct  SI_controllers_state_t
 SI controller data for all controller ports. More...
 
struct  SI_controllers_origin_t
 SI GameCube controller origin data for all controller ports. More...
 
union  _SI_condat.__unnamed41__
 
struct  _SI_condat.__unnamed41__.__unnamed43__
 
struct  _SI_condat.__unnamed41__.__unnamed45__
 
union  _SI_condat_gc.__unnamed47__
 
struct  _SI_condat_gc.__unnamed47__.__unnamed49__
 
struct  _SI_condat_gc.__unnamed47__.__unnamed51__
 

Bitmasks for controller status

#define CONTROLLER_1_INSERTED   0xF000
 Controller 1 Inserted.
 
#define CONTROLLER_2_INSERTED   0x0F00
 Controller 2 Inserted.
 
#define CONTROLLER_3_INSERTED   0x00F0
 Controller 3 Inserted.
 
#define CONTROLLER_4_INSERTED   0x000F
 Controller 4 Inserted.
 

Accessory ID Values

#define ACCESSORY_NONE   0
 No accessory present.
 
#define ACCESSORY_MEMPAK   1
 Mempak present.
 
#define ACCESSORY_RUMBLEPAK   2
 Rumblepak present.
 
#define ACCESSORY_VRU   3
 VRU present.
 
#define ACCESSORY_TRANSFERPAK   4
 Transferpak present.
 

SI Error Values

#define ERROR_NONE   0x0
 No error occured.
 
#define ERROR_BAD_COMMAND   0x1
 Command not recognized or malformed.
 
#define ERROR_NOT_PRESENT   0x2
 Controller not present.
 

Detailed Description

Controller and accessory interface.

This module contains an old API to communicate with controllers and accessories. The API had several deficiencies, notably implementing partial support for GameCube controllers, but only supporting asynchronous reading of N64 controllers. It has been deprecated in favor of the Joypad Subsystem, which offers full support for both N64 and GameCube controllers, and implements asynchronous detection of controller port devices and accessories.

All controller subsystem functions are now implemented as thin compatibility shims that call the corresponding Joypad Subsystem functions. They will continue to work just as before, but there will be no further work on them. The functions have all been explicitly marked as deprecated, and will generate a warning at compile time. The warning suggests the alternative Joypad API to use instead. In most cases, the change should be straightforward.


Data Structure Documentation

◆ _SI_condat

struct _SI_condat

SI Nintendo 64 controller data.

Data structure for Joybus response to 0x01 (Read N64 controller state) command.

Data Fields
unsigned __pad0__: 16 Unused padding bits.
unsigned err: 2 Status of the last command.
unsigned __pad1__: 14 Unused padding bits.
union _SI_condat.__unnamed41__ __unnamed__

◆ _SI_condat_gc

struct _SI_condat_gc

SI GameCube controller data.

Data structure for Joybus response to 0x40 (Read GC controller state) command.

Data Fields
union _SI_condat_gc.__unnamed47__ __unnamed__

◆ SI_origdat_gc

struct SI_origdat_gc

SI GameCube controller origin data.

Data structure for Joybus response to 0x41 (Read GC controller origin) command.

Data Fields
struct SI_condat_gc data
uint8_t deadzone0
uint8_t deadzone1

◆ SI_controllers_state_t

struct SI_controllers_state_t

SI controller data for all controller ports.

When reading N64 controller state, only the c member array will be populated. When reading GC controller state, only the gc member array will be populated.

Data Fields
struct SI_condat c[4] Array of N64 controller state for each controller port.
struct SI_condat_gc gc[4] Array of GameCube controller state for each controller port.

◆ SI_controllers_origin_t

struct SI_controllers_origin_t

SI GameCube controller origin data for all controller ports.

Data Fields
struct SI_origdat_gc gc[4] Array of GameCube controller origin data for each controller port.

◆ _SI_condat.__unnamed41__

union _SI_condat.__unnamed41__
Data Fields
struct _SI_condat.__unnamed41__.__unnamed43__ __unnamed__
struct _SI_condat.__unnamed41__.__unnamed45__ __unnamed__

◆ _SI_condat.__unnamed41__.__unnamed43__

struct _SI_condat.__unnamed41__.__unnamed43__
Data Fields
unsigned int data: 32 32-bit data sent to or returned from SI

◆ _SI_condat.__unnamed41__.__unnamed45__

struct _SI_condat.__unnamed41__.__unnamed45__
Data Fields
unsigned A: 1 State of the A button.
unsigned B: 1 State of the B button.
unsigned Z: 1 State of the Z button.
unsigned start: 1 State of the start button.
unsigned up: 1 State of the up button.
unsigned down: 1 State of the down button.
unsigned left: 1 State of the left button.
unsigned right: 1 State of the right button.
unsigned __pad0__: 2 Unused padding bits.
unsigned L: 1 State of the L button.
unsigned R: 1 State of the R button.
unsigned C_up: 1 State of the C up button.
unsigned C_down: 1 State of the C down button.
unsigned C_left: 1 State of the C left button.
unsigned C_right: 1 State of the C right button.
signed x: 8 State of the analog stick (X axis)
signed y: 8 State of the analog stick (Y axis)

◆ _SI_condat_gc.__unnamed47__

union _SI_condat_gc.__unnamed47__

◆ _SI_condat_gc.__unnamed47__.__unnamed49__

struct _SI_condat_gc.__unnamed47__.__unnamed49__
Data Fields
uint64_t data 64-bit data sent to or returned from SI

◆ _SI_condat_gc.__unnamed47__.__unnamed51__

struct _SI_condat_gc.__unnamed47__.__unnamed51__
Data Fields
unsigned err: 2
unsigned origin_unchecked: 1
unsigned start: 1
unsigned y: 1
unsigned x: 1
unsigned b: 1
unsigned a: 1
unsigned unused2: 1
unsigned l: 1
unsigned r: 1
unsigned z: 1
unsigned up: 1
unsigned down: 1
unsigned right: 1
unsigned left: 1
unsigned stick_x: 8
unsigned stick_y: 8
unsigned cstick_x: 8
unsigned cstick_y: 8
unsigned analog_l: 8
unsigned analog_r: 8