Updated 4/6/2017
Update 7/24/2017
Changed the Start button to Enter instead of E
Most of this is copied from another tutorial.
This mapping skips the SPI pins used by the SPI TFT screens as well as the analog audio out pins so that it may be used with those screens attached and analog audio.
First of all you will need to solder the required pins to the GPIO of your Pi Zero. Here is a map of where to solder the pins. solder the ground to any of the ground pins on the GPIO.
I suggest starting with a fresh image of retropie as this will use a certain set of keyboard keys that I preselected. With a fresh retropie install you will be able to map these key presses on first startup. map the following table of keys with your keyboard so that things will work with my Code. Then you can get in and setup network so you can use SSH and FTP.
Up - up
Down - down
left - left
right - right
start - enter
select - s
A - a
B - b
X - x
Y - y
L - l
R - r
Download the retrogame.c file at the google drive link below and place in a directory on your Pi Zero SD card.
https://drive.google.com/open?id=0B9I5H ... EhKUFJOb2M
I used FTP to get to my pi zero and made the Adafruit-Retrogame directory in the /home/pi directory. This is the directory referenced later in code in this tutorial. So its best to stick to this.
as of retropie 4.2 SSH is now disabled by default. to enable
press F4 on a keyboard then.
Code: Select all
sudo raspi-config
In the middle of this wiki it will show you how to FTP into retropie
https://github.com/retropie/retropie-se ... rring-Roms
In your FTP Client make sure you are in the pi directory then right click and click new then folder and name it Adafruit-Retrogame
Copy the retrogame.c file to the /home/pi/Adafruit-Retrogame directory on the SD Card using your preferred method. I found that FTP was the easiest for me
At this point you will need a terminal connection. I highly suggest using SSH as this will allow you to test run retrogame with the gui running on your device for button mapping testing.
Here is the wiki on how to SSH into retropie. Your pi zero will need to have a network connection for this to work.
https://github.com/RetroPie/RetroPie-Setup/wiki/SSH
type:
Code: Select all
cd /home/pi/Adafruit-Retrogame
Code: Select all
make retrogame
One more step is to create a custom udev rule which will allow retrogame input events to be visible to applications built using the latest SDL2 library. Some applications like the latest version of RetroPie's EmulationStation frontend require SDL2 and can't see input events from retrogame without this rule. It can't hurt to add this rule even if you aren't using EmulationStation or other SDL2 apps.
To add the rule, run the following command to create and edit the file /etc/udev/rules.d/10-retrogame.rules in the nano text editor:
Code: Select all
sudo nano /etc/udev/rules.d/10-retrogame.rules
Code: Select all
SUBSYSTEM=="input", ATTRS{name}=="retrogame", ENV{ID_INPUT_KEYBOARD}="1"
Restart your Raspberry Pi to make sure the new configuration is loaded.
Code: Select all
sudo reboot
Navigate back to the Adafruit-Retrogame directory
Code: Select all
cd /home/pi/Adafruit-Retrogame
Code: Select all
sudo ./retrogame
Code: Select all
sudo nano /etc/rc.local
Code: Select all
/home/pi/Adafruit-Retrogame/retrogame &
If you placed the software in a different location, this line should be changed accordingly. “sudo” isn’t necessary here because the rc.local script is already run as root.
Reboot the system to test the startup function:
Code: Select all
sudo reboot
Each emulator will have its own method for configuring keyboard input. Set them up so the keys match your controller outputs. Up/down/left/right from the arrow keys is a pretty common default among these programs, but the rest will usually require some tweaking.