More MAME

Atari hook upSuccess! Hooked up the Atari joystick to the Raspberry Pi, played a proper round of Galaga.  

Making the adapter: Many classic joysticks used the commonly available DB9 connectors.  The joystick has a female DB9 so we need the male DB9.  Solder leads to all 9 pins of the male D9 connector.  You only really need to connect six (Up, Down, Left, Right, Fire, Ground) but we put wires on every pin to leave it open for alternative configurations. I decided to use the Pi Cobbler breakout on a breadboard to conveniently move pins around.  You can also connect directly to the pins on the Pi, but since I have many experiments planned I did not want to risk damaging the board when we changed configurations. 

Used the Adafruit retro game guide and code to get things running.

Setup:

DB9 Pin 1: Blue – GPIO 10 (labeled MOSI) | Up

DB9 Pin 2: Green – GPIO 17 | Down

DB9 Pin 3: Yellow – GPIO 25 | Left

DB9 Pin 4: Orange – GPIO 9 (labeled MISO) | Right

DB9 Pin 5:  Red | Leave disconnected

DB9 Pin 6: Grey – GPIO 23 | Fire/Button 1

DB9 Pin 7:  Purple | Leave disconnected

DB9 Pin 8: Black | Ground

DB9 Pin 9: White | Leave disconnected (optional: connect to GPIO 7 | Alt/Button 2 – labeled CE1 on the breakout)

Clone the Adafruit code onto your RPi:

$ mkdir git cd git

$ mkdir github cd github

$ mkdir adafruit cd adafruit

$ git clone https://github.com/adafruit/Adafruit-Retrograme

$ cd Adafruit-Retrogame

$ make clean

$ make

$ sudo ./retrogame

To change any of the pin settings, edit the retrogame.c file by typing the following in to the command line:

$ nano retrogame.c  #opens code in the nano editor – scroll to line 77

struct{ int pin; int key; }

io[] { {25, KEY_LEFT}, {9, KEY_RIGHT}, {10, KEY_UP}, {17, KEY_DOWN}, {23, KEY_LEFTCTRL}, {7, KEY_LEFTALT} };

#Write your changes, then exit the editor and in the command line type $ make.  Quickly open a new terminal window to test changes by typing Alt-F2.

#Want more keypress options?  Look in the input.h library by navigating to /usr/include/linux/input.h  at line 108

Now, on to more complicated controllers.  Bring on the buttons!

Galaga

Note – to use the joystick in the future, you need to run /git/github/adafruit/Adafruit-Retrogame $ sudo ./retrogame every time you boot up the pi.

Followup – have successfully hooked up a two-button joystick with the same Dsub9 connector.   Bought more connectors to solder.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s