Skip to content

About

A Raspberry Pi Pico based Gamecube controller

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry Pi Pico GameCube Controller Emulator

This PlatformIO project turns a Raspberry Pi Pico into a Nintendo GameCube controller. The Pico emulates the GameCube controller protocol, allowing it to be used with GameCube consoles or adapters.

Features

  • Full GameCube controller protocol implementation
  • Support for all buttons (A, B, X, Y, Start, Z, L, R, D-Pad)
  • Analog stick support (main stick and C-stick)
  • Analog trigger support (L and R triggers)
  • Precise timing using bit-banging on GPIO
  • 3.3V logic compatible (no level shifters needed!)

Hardware Requirements

  • Raspberry Pi Pico
  • GameCube controller cable or connector
  • Buttons/switches for controller inputs
  • Potentiometers for analog sticks (optional)
  • Resistors (1kΩ pullup recommended for data line)

Wiring

GameCube Connector Pinout

Looking at the controller port on the console (socket):

     ___
   /     \
  | 6   1 |
  | 5 3 2 |
   \ 4  /
    ---
  1. 5V - Not needed (Pico has own power)
  2. Data - Connect to GPIO 2 on Pico (with 1kΩ pullup to 3.3V)
  3. Ground - Connect to Pico GND
  4. Ground - Connect to Pico GND
  5. No connection
  6. 3.3V - Can be used to power Pico (or use USB)

Button Wiring (Customizable)

The default pin mapping in include/button_mapping.h:

Button GPIO Pin Notes
A 3 Active low with pullup
B 4 Active low with pullup
X 5 Active low with pullup
Y 6 Active low with pullup
Start 7 Active low with pullup
Z 8 Active low with pullup
L 9 Active low with pullup
R 10 Active low with pullup
D-Up 11 Active low with pullup
D-Down 12 Active low with pullup
D-Left 13 Active low with pullup
D-Right 14 Active low with pullup
Main Stick X 26 (ADC0) Analog input
Main Stick Y 27 (ADC1) Analog input
C-Stick X 28 (ADC2) Analog input
C-Stick Y 29 (ADC3) Analog input
L Analog 15 Digital or analog
R Analog 16 Digital or analog

Important Notes

  • All button pins use internal pullup resistors and are active low
  • Connect buttons between GPIO pin and GND
  • The GameCube data line requires a 1kΩ pullup resistor to 3.3V
  • GameCube uses 3.3V logic, perfect for the Pico (no level shifting needed)

Software Setup

Prerequisites

  1. Install Visual Studio Code
  2. Install the PlatformIO extension

Building and Uploading

  1. Open this folder in VS Code
  2. PlatformIO should automatically detect the project
  3. Connect your Raspberry Pi Pico while holding the BOOTSEL button
  4. The Pico should appear as a USB mass storage device
  5. Build the project: Click the checkmark (✓) in the PlatformIO toolbar
  6. Upload: Click the arrow (→) in the PlatformIO toolbar

Alternatively, use the command line:

pio run -t upload

Monitoring Serial Output

To see debug output:

  1. Connect via USB
  2. Click the plug icon in PlatformIO toolbar for Serial Monitor
  3. Or use: pio device monitor

Customization

Changing Pin Assignments

Edit include/button_mapping.h to change which GPIO pins are used for each button.

Adding Real Button Input

The current updateControllerState() function in src/main.cpp has demo code. Replace it with real button reading:

void updateControllerState() {
    // Read digital buttons
    controller_state.buttons1 = 0;
    if (readButton(PIN_BTN_START)) controller_state.buttons1 |= BTN_START;
    if (readButton(PIN_BTN_Y)) controller_state.buttons1 |= BTN_Y;
    if (readButton(PIN_BTN_X)) controller_state.buttons1 |= BTN_X;
    if (readButton(PIN_BTN_B)) controller_state.buttons1 |= BTN_B;
    if (readButton(PIN_BTN_A)) controller_state.buttons1 |= BTN_A;
    
    controller_state.buttons2 = 0;
    if (readButton(PIN_BTN_L)) controller_state.buttons2 |= BTN_L;
    if (readButton(PIN_BTN_R)) controller_state.buttons2 |= BTN_R;
    if (readButton(PIN_BTN_Z)) controller_state.buttons2 |= BTN_Z;
    if (readButton(PIN_BTN_DUP)) controller_state.buttons2 |= BTN_DUP;
    if (readButton(PIN_BTN_DDOWN)) controller_state.buttons2 |= BTN_DDOWN;
    if (readButton(PIN_BTN_DRIGHT)) controller_state.buttons2 |= BTN_DRIGHT;
    if (readButton(PIN_BTN_DLEFT)) controller_state.buttons2 |= BTN_DLEFT;
    
    // Read analog sticks
    controller_state.stick_x = adcToJoystick(analogRead(PIN_STICK_X));
    controller_state.stick_y = adcToJoystick(analogRead(PIN_STICK_Y));
    controller_state.cstick_x = adcToJoystick(analogRead(PIN_CSTICK_X));
    controller_state.cstick_y = adcToJoystick(analogRead(PIN_CSTICK_Y));
    
    // Read analog triggers
    controller_state.l_analog = readButton(PIN_L_ANALOG) ? 255 : 0;
    controller_state.r_analog = readButton(PIN_R_ANALOG) ? 255 : 0;
}

Protocol Details

The GameCube controller protocol uses a single bidirectional data line with precise timing:

  • Logic 0: 3μs low, 1μs high
  • Logic 1: 1μs low, 3μs high
  • Stop bit: 1μs low, 2μs high

Command Types

  • 0x00 or 0xFF: Initialize/Reset - Controller responds with ID
  • 0x40 or 0x41: Poll - Controller sends 8 bytes of state data
  • 0x42: Origin - Read calibration data (not fully implemented)

Data Format (8 bytes)

  1. Byte 0: Start, Y, X, B, A, -, -, -
  2. Byte 1: L, R, Z, D-Up, D-Down, D-Right, D-Left, -
  3. Byte 2: Main stick X (0-255, 128 = center)
  4. Byte 3: Main stick Y (0-255, 128 = center)
  5. Byte 4: C-stick X (0-255, 128 = center)
  6. Byte 5: C-stick Y (0-255, 128 = center)
  7. Byte 6: L trigger analog (0-255)
  8. Byte 7: R trigger analog (0-255)

Troubleshooting

Controller Not Detected

  1. Check the data line connection and pullup resistor
  2. Verify ground connections
  3. Check serial monitor for debug messages
  4. Ensure timing is accurate (try adjusting microsecond delays)

Buttons Not Working

  1. Verify pin assignments in button_mapping.h
  2. Check that buttons are wired correctly (active low)
  3. Uncomment button reading code in updateControllerState()

Analog Sticks Drifting

  1. Calibrate the center point of your potentiometers
  2. Add deadzone handling in the code
  3. Check ADC connections

Future Improvements

  • Use PIO state machines for more accurate timing
  • Add rumble motor support (requires additional hardware)
  • Implement origin/calibration command fully
  • Add USB HID mode to work as a PC game controller
  • Support for multiple controller profiles

References

License

This project is provided as-is for educational and hobbyist purposes. Nintendo and GameCube are trademarks of Nintendo Co., Ltd.

Contributing

Feel free to submit issues and pull requests to improve this project!

About

A Raspberry Pi Pico based Gamecube controller

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages