|
libjoybus
Joybus implementation for 32-bit MCUs
|
Common definitions for GameCube controllers. More...
#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | joybus_gcn_controller_state |
| GameCube controller input/origin state. More... | |
Macros | |
| #define | JOYBUS_GCN_BUTTON_A (1 << 0) |
| GameCube controller button bitmask flags. | |
| #define | JOYBUS_GCN_BUTTON_B (1 << 1) |
| #define | JOYBUS_GCN_BUTTON_X (1 << 2) |
| #define | JOYBUS_GCN_BUTTON_Y (1 << 3) |
| #define | JOYBUS_GCN_BUTTON_START (1 << 4) |
| #define | JOYBUS_GCN_NEED_ORIGIN (1 << 5) |
| #define | JOYBUS_GCN_ERROR_LATCH (1 << 6) |
| #define | JOYBUS_GCN_ERROR (1 << 7) |
| #define | JOYBUS_GCN_BUTTON_LEFT (1 << 8) |
| #define | JOYBUS_GCN_BUTTON_RIGHT (1 << 9) |
| #define | JOYBUS_GCN_BUTTON_DOWN (1 << 10) |
| #define | JOYBUS_GCN_BUTTON_UP (1 << 11) |
| #define | JOYBUS_GCN_BUTTON_Z (1 << 12) |
| #define | JOYBUS_GCN_BUTTON_R (1 << 13) |
| #define | JOYBUS_GCN_BUTTON_L (1 << 14) |
| #define | JOYBUS_GCN_USE_ORIGIN (1 << 15) |
| #define | JOYBUS_GCN_BUTTON_MASK 0x7F1F |
Enumerations | |
| enum | joybus_gcn_analog_mode { JOYBUS_GCN_ANALOG_MODE_0 , JOYBUS_GCN_ANALOG_MODE_1 , JOYBUS_GCN_ANALOG_MODE_2 , JOYBUS_GCN_ANALOG_MODE_3 , JOYBUS_GCN_ANALOG_MODE_4 } |
| Analog modes for packing GameCube controller input state. More... | |
| enum | joybus_gcn_motor_state { JOYBUS_GCN_MOTOR_STOP , JOYBUS_GCN_MOTOR_RUMBLE , JOYBUS_GCN_MOTOR_STOP_HARD } |
| GameCube controller motor states. More... | |
Functions | |
| struct joybus_gcn_controller_state | __attribute__ ((packed)) |
Variables | |
| uint16_t | buttons |
| Button state. | |
| uint8_t | stick_x |
| Main stick x-axis position. | |
| uint8_t | stick_y |
| Main stick y-axis position. | |
| uint8_t | substick_x |
| C-stick x-axis position. | |
| uint8_t | substick_y |
| C-stick y-axis position. | |
| uint8_t | trigger_left |
| Left analog trigger position. | |
| uint8_t | trigger_right |
| Right analog trigger position. | |
| uint8_t | analog_a |
| Analog A button value. | |
| uint8_t | analog_b |
| Analog B button value. | |
| enum joybus_gcn_analog_mode | __attribute__ |
Common definitions for GameCube controllers.
| #define JOYBUS_GCN_BUTTON_A (1 << 0) |
GameCube controller button bitmask flags.
These test the buttons field of joybus_gcn_controller_state. Bits 0-7 correspond to the first button byte of the wire input state, bits 8-15 to the second.
Analog modes for packing GameCube controller input state.
The "read" command used by games expects 8-byte responses, this is presumably so it fits in a nice round multiple of 32-bit words. The full input state is 10 bytes long, so there are various ways to "pack" the input state into 8 bytes. Depending on the analog mode, either one pair of analog inputs can be omitted, or two pairs of analog inputs can be truncated to 4 bits.
All production games, with the exception of Luigi's Mansion, use analog mode 3. This mode omits the analog A/B inputs, and sends the substick X/Y and triggers at full precision. Analog A/B buttons were only present in pre-production GameCube controllers.