Sega Genesis gamepads - retronicdesign/USBJoystickAdapter_v3.2 GitHub Wiki

image

Sega Genesis (Mega Drive) gamepads comes in 3 or 6 buttons flavor. Method to read thoses controllers are different but retro-compatible. Our firmware can accept and auto-detect both type.

Sega Genesis gamepad pinout

image

PIN FUNCTION  
1 Up/Z Button  
2 Down/Y Button  
3 Left/X Button  
4 Right/Mode Button  
5 +5v  
6 A/B Button  
7 Select  
8 Gnd  
9 Start Button/C Button  


3-button operation mode

The standard 3-button controller is a simple, passive device that is easy to read. It has 8 total buttons: the Up, Down, Left, and Right directional buttons, plus the A, B, C, and Start buttons. The controller maintains two states (whether the select pin is set HIGH or LOW) and reading the buttons requires switching back and forth between those two states and reading the input pins.

Reading the 3-Button Controller

  1. Output LOW to the select pin.
  2. Read the six input pins according to the table (LOW = the button is being pressed).
  3. Output HIGH to the select pin.
  4. Read the six input pins according to the table (LOW = the button is being pressed).
Select (Pin 7) Pin 1 Pin 2 Pin 3 Pin 4 Pin 6 Pin 9
LOW     * * A Start
HIGH Up Down Left Right B C

*: These pins are set LOW together and indicate the presence of a controller.

6-button operation mode

The 6-button controller is more complicated to read, as it has to both report new buttons (X, Y, Z, and MODE) and yet still provide backwards compatibility with games expecting a 3-button controller. To report the extra buttons (and notify the host that the connected controller is in fact a 6-button controller), the controller maintains eight different states and it's up to the host to know how to read the input pins properly.

The logic works as follows:

  • The controller's state is maintained by a counter with 8 values (0-7).
  • When the select pin changes (HIGH to LOW or LOW to HIGH) the counter increments.
  • If more than 1.5 ms elapses with no change in the select pin, then the counter resets to 0.
  • Most games run at 60 frames per second and read the controller only once per frame. Reading just once every 16.6 ms gives enough time for the counter to reset to 0 before the next frame.
  • The first 4 states (0-3) report buttons like a 3-button controller. Games programmed to read a 3-button controller once per frame still work as expected.
  • The 5th state (4) reports that the controller is in fact a 6-button controller.
  • The 6th state (5) reports the buttons X, Y, Z and MODE.
  • The last two states (6-7) can be ignored for official controllers.

Reading the 6-Button Controller

  1. Loop through each state (0-7).
  2. If the state is even, output LOW to the select pin. If it's odd, output HIGH.
  3. Read the six input pins according to the table (LOW = the button is being pressed).
  4. After the loop, wait at least 1.5ms (16.6 ms is better) so that the controller can reset.
State Select (Pin 7) Pin 1 Pin 2 Pin 3 Pin 4 Pin 6 Pin 9
0 LOW            
1 HIGH            
2 LOW     * * A Start
3 HIGH Up Down Left Right B C
4 LOW ** **        
5 HIGH Z Y X Mode    
6 LOW            
7 HIGH            

*: These pins are set LOW together and indicate the presence of a controller.

**: These pins are set LOW together and indicate a 6-button controller is connected.

The Mode Button

There are very few games that use the Mode button, but why? While games can technically read the Mode button like any other, it's not its primary purpose. As mentioned above, most games designed for 3-button controllers can still use a 6-button controller due to the fact that they only read the controller once per game frame, giving the controller time to reset its state back to 0.

However some games, like Ms. Pac-Man, do read the controller multiple times per frame. When this happens the controller state passes 3, and the game misinterprets the values on the input pins. This causes erratic behavior and makes the game unplayable.

The true purpose of the Mode button is to enable compatibility for games like Ms. Pac-Man. If you hold down the Mode button while connecting the controller (ie. connecting power), the chip inside will switch to a compatibility mode and behave exactly like a 3-button controller. The controller will stay in this mode until it is disconnected (ie. disconnecting power).

The 2-Button Controller

The standard 2-button controller is a simple, passive device that is easy to read. It has 6 total buttons: the Up, Down, Left, and Right directional buttons, plus the 1 (Start) and 2 buttons.

Reading the 2-Button Controller

  1. Read the six input pins according to the table (LOW = the button is being pressed).
Pin 1 Pin 2 Pin 3 Pin 4 Pin 6 Pin 9
Up Down Left Right 1 (Start) 2

Note that unlike with the Genesis controllers, there is no indication that a Master System controller is connected unless buttons are being actively pressed.

⚠️ **GitHub.com Fallback** ⚠️