libdragon
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
joypad.h File Reference

Joypad Subsystem. More...

Go to the source code of this file.

Data Structures

union  joypad_buttons_t
 Joypad Buttons. More...
 
struct  joypad_inputs_t
 Joypad Inputs Unified State Structure. More...
 

Macros

#define JOYPAD_PORT_COUNT   4
 Count of Joypad ports.
 
#define JOYPAD_PORT_FOREACH(iterator_token)
 Convenience macro to iterate through all Joypad ports.
 
Joybus analog value ranges

#define JOYPAD_RANGE_N64_STICK_MAX   90
 Maximum range of a Nintendo 64 controller analog stick.
 
#define JOYPAD_RANGE_GCN_STICK_MAX   100
 Maximum range of a GameCube controller analog stick.
 
#define JOYPAD_RANGE_GCN_CSTICK_MAX   76
 Maximum range of a GameCube controller analog C-stick.
 
#define JOYPAD_RANGE_GCN_TRIGGER_MAX   200
 Maximum range of a GameCube controller analog trigger.
 

Enumerations

enum  joypad_port_t { JOYPAD_PORT_1 = 0 , JOYPAD_PORT_2 = 1 , JOYPAD_PORT_3 = 2 , JOYPAD_PORT_4 = 3 }
 Joypad Port Numbers. More...
 
enum  joypad_style_t { JOYPAD_STYLE_NONE = 0 , JOYPAD_STYLE_N64 , JOYPAD_STYLE_GCN , JOYPAD_STYLE_MOUSE }
 Joypad Styles enumeration. More...
 
enum  joypad_accessory_type_t {
  JOYPAD_ACCESSORY_TYPE_NONE = 0 , JOYPAD_ACCESSORY_TYPE_UNKNOWN , JOYPAD_ACCESSORY_TYPE_CONTROLLER_PAK , JOYPAD_ACCESSORY_TYPE_RUMBLE_PAK ,
  JOYPAD_ACCESSORY_TYPE_TRANSFER_PAK , JOYPAD_ACCESSORY_TYPE_BIO_SENSOR , JOYPAD_ACCESSORY_TYPE_SNAP_STATION
}
 Joypad Accessories enumeration. More...
 
enum  joypad_axis_t {
  JOYPAD_AXIS_STICK_X = offsetof(joypad_inputs_t, stick_x) , JOYPAD_AXIS_STICK_Y = offsetof(joypad_inputs_t, stick_y) , JOYPAD_AXIS_CSTICK_X = offsetof(joypad_inputs_t, cstick_x) , JOYPAD_AXIS_CSTICK_Y = offsetof(joypad_inputs_t, cstick_y) ,
  JOYPAD_AXIS_ANALOG_L = offsetof(joypad_inputs_t, analog_l) , JOYPAD_AXIS_ANALOG_R = offsetof(joypad_inputs_t, analog_r)
}
 Joypad Axis enumeration values. More...
 
enum  joypad_2d_t {
  JOYPAD_2D_STICK = (1 << 0) , JOYPAD_2D_DPAD = (1 << 1) , JOYPAD_2D_C = (1 << 2) , JOYPAD_2D_LH = (JOYPAD_2D_STICK | JOYPAD_2D_DPAD) ,
  JOYPAD_2D_RH = (JOYPAD_2D_STICK | JOYPAD_2D_C) , JOYPAD_2D_ANY = (JOYPAD_2D_STICK | JOYPAD_2D_DPAD | JOYPAD_2D_C)
}
 Joypad 2D axes enumeration. More...
 
enum  joypad_8way_t {
  JOYPAD_8WAY_NONE = -1 , JOYPAD_8WAY_RIGHT = 0 , JOYPAD_8WAY_UP_RIGHT = 1 , JOYPAD_8WAY_UP = 2 ,
  JOYPAD_8WAY_UP_LEFT = 3 , JOYPAD_8WAY_LEFT = 4 , JOYPAD_8WAY_DOWN_LEFT = 5 , JOYPAD_8WAY_DOWN = 6 ,
  JOYPAD_8WAY_DOWN_RIGHT = 7
}
 Joypad 8-way directional enumeration. More...
 

Functions

void joypad_init (void)
 Initialize the Joypad subsystem.
 
void joypad_close (void)
 Close the Joypad subsystem.
 
void joypad_poll (void)
 Fetch the current Joypad input state.
 
bool joypad_is_connected (joypad_port_t port)
 Whether a Joybus device is plugged in to a Joypad port.
 
joybus_identifier_t joypad_get_identifier (joypad_port_t port)
 Get the Joybus device identifier for a Joypad port.
 
joypad_style_t joypad_get_style (joypad_port_t port)
 Get the Joypad style for a Joypad port.
 
joypad_accessory_type_t joypad_get_accessory_type (joypad_port_t port)
 Get the Joypad accessory type for a Joypad port.
 
bool joypad_get_rumble_supported (joypad_port_t port)
 Is rumble supported for a Joypad port?
 
bool joypad_get_rumble_active (joypad_port_t port)
 Is rumble active for a Joypad port?
 
void joypad_set_rumble_active (joypad_port_t port, bool active)
 Activate or deactivate rumble on a Joypad port.
 
joypad_inputs_t joypad_get_inputs (joypad_port_t port)
 Get the current Joypad inputs state for a Joypad port.
 
joypad_buttons_t joypad_get_buttons (joypad_port_t port)
 Get the current Joypad buttons state for a Joypad port.
 
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.
 
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.
 
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.
 
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.
 
int joypad_get_axis_pressed (joypad_port_t port, joypad_axis_t axis)
 Get the direction of a "press" of an axis on a Joypad port.
 
int joypad_get_axis_released (joypad_port_t port, joypad_axis_t axis)
 Get the direction of a "release" of an axis on a Joypad port.
 
int joypad_get_axis_held (joypad_port_t port, joypad_axis_t axis)
 Get the direction that an axis is held on a Joypad port.
 

Detailed Description

Joypad Subsystem.

Author
Christopher Bonhage me@ch.nosp@m.rist.nosp@m.opher.nosp@m.bonh.nosp@m.age.c.nosp@m.om