Configuring Older Retrogame

This is for the old version of retrogame that required recompilation. You probably don't need this page but its here for historical purposes!

Classic retrogame: Edit Source Code

Assigning keys and buttons in the old retrogame is quite a bit more involved…this is why we recommend just downloading and installing the newer version. But if this is what you have around, here’s the procedure…

Edit the retrogame.c file in the unZIPped Adafruit-Retrogame directory…

Download: file
cd Adafruit-Retrogame
nano retrogame.c

About a hundred lines down, you’ll see a table that looks like this:

Download: file
ioStandard[] = {
        // This pin/key table is used when the PiTFT isn't found
        // (using HDMI or composite instead), as with our original
        // retro gaming guide.
        // Input   Output (from /usr/include/linux/input.h)
        {  25,     KEY_LEFT     },   // Joystick (4 pins)
        {   9,     KEY_RIGHT    },
        {  10,     KEY_UP       },
        {  17,     KEY_DOWN     },
        {  23,     KEY_LEFTCTRL },   // A/Fire/jump/primary
        {   7,     KEY_LEFTALT  },   // B/Bomb/secondary
        // For credit/start/etc., use USB keyboard or add more buttons.
        {  -1,     -1           } }; // END OF LIST, DO NOT CHANGE

Careful now…make sure you’re editing the ioStandard[] table, not the similar-looking ioTFT[] table. The latter applied specifically to the Cupcade project and nothing else.

Within each set of braces is a GPIO pin number and a corresponding key name (from /usr/include/linux/input.h). Because we’re editing C source code, it’s vitally important to maintain the syntax exactly. Open brace, number, comma, key name, close brace, comma. The last item must be {-1, -1}.

If you need an extra ground pin (and have extra GPIO pins available that you’re not using for controls), set the key code to GND instead.

Write your changes to the file and exit the editor, then type:

Download: file
make retrogame

This should build the retrogame executable. If you instead get an error message, there’s a problem in the edited table — most likely a missing curly brace, comma or semicolon.

Depending what’s in /etc/rc.local, you might need to move retrogame to a different location (such as /usr/local/bin). Reboot to use the new settings. Test it out…if anything needs changing, you’ll have to repeat the whole edit-compile-move-reboot sequence.

This guide was first published on Jun 03, 2013. It was last updated on Jun 03, 2013. This page (Configuring Older Retrogame) was last updated on Apr 18, 2019.