adafruit / adafruit-retrogame Goto Github PK
View Code? Open in Web Editor NEWRaspberry Pi GPIO-to-virtual-keyboard utility for classic game emulators
Home Page: https://learn.adafruit.com/retro-gaming-with-raspberry-pi
Raspberry Pi GPIO-to-virtual-keyboard utility for classic game emulators
Home Page: https://learn.adafruit.com/retro-gaming-with-raspberry-pi
Pi noob. Trying to use retropie on raspberry pi 3 and leverage serial ports for two buttons but can't get them to register. Is there something special I am missing. I think I disabled serial console, bt uart etc but no luck. Details here.
https://retropie.org.uk/forum/topic/8408/attempting-to-use-gpio-14-15-18-for-button-input
Any links that would help, articles seem to imply I should be able to do it if I'm not using serial port..
Thanks
I have downloaded "Adafruit-Retrogame" (and later, i downloaded "Adafruit-Retrogame.master"). I did this from within the Raspberry Pi after typing "startx" and the using one of the browsers. Once downloaded, it creates a zip folder on the desktop. Then, by clicking on it i can get the files unzipped. They show up in a folder together.
Then i log out and go to the command prompt. I type "cd Adafruit-Retrogame" and it says that the file is not found. Thats where I'm stuck.
Ive gotten further along than this before, but this time i cant get past this.
I have a custom built eight button Game Boy that runs off a Raspberry Pi 3. The controls for this unit are tied directly into the GPIO header. As a result, I have used Adafruit-Retrogame so that my controls can be configured via the text file and seen in EmulationStation. I have done the measure to complete RetroPie 2.0+ compatibility via "sudo nano /etc/udev/rules.d/10-retrogame.rules". My controls work and I thank you.
I do however have an issue. Because of the way the software is set up I can't get the 7th and 8th buttons working no matter how I arrange the buttons according to their pin layout. My Gameboy has six buttons on the front, a select button, a start button, and a D-pad. It also has two buttons on the back. Thus, my end goal is to configure A, B, X, Y, Left Shoulder, Right Shoulder, Left Trigger, and Right Trigger buttons along with select, start, and the D-pad. But since the text configuration file simply requires an L or R and does not differentiate between LS, RS, LT, and RT I am using the numbers 1 and 2 in lieu of this. But, when I do this only six buttons work in PS1 emulation; 1 and 2 do not.
Below is my configuration file. Again, I have confirmed the buttons actually do send input to the RPi3. Those pin outs work. I can swap the numbers and those pinouts become active. Here is the text for that file:
UP 26 # 'UP' button
DOWN 13 # 'DOWN' button
LEFT 19 # 'LEFT' Button
RIGHT 6 # 'RIGHT' button
A 7 # 'A' Button
B 15 # 'B' button
X 23 # 'X' button
Y 14 # 'Y' button
ENTER 0 # 'ENTER' button
SPACE 5 # 'SELECT' button
L 22 # 'Left' Shoulder button
R 12 # 'Right' Shoulder button
1 21 # 'Left' Trigger button (back)
2 20 # 'Right' Trigger button (back)
This text is the end of the file. As you can see, everything is set up properly. I just can't make the back buttons work because it appears the sum of working buttons in RetroPie is six, unless there's alternative button labels besides 1 and 2 that will drive those buttons.
Thank you for any and all effort. And don't hesitate to get a hold of me.
Regards,
Neil Bradshaw
Hi!
Can't find it neither on the Adafruit's forum nor here so I ask: How can I make retrogame work for two players?
When configuring my buttons connected to the GPIO they are known as "Keyboard" and I can only configure one set of command but I'd like to enjoy multi-players games so I need it to bind two sets of commands.
Many thanks in advance!
For example I want to use:
Right + X + W (run and jump in a Mario game) but the program only seems to emulate 2 keys at the same time.
Any idea @PaintYourDragon ?
Hello this is working as far as inputing keys but when I use a joystick it will need keep the button pressed; it only ouputs one press even when held.
Is there something in the configuration that will let the up,down,left,right not debounce?
Thank you
Looking for some advice on troubleshooting GPIO with Retrogame. Unable to get responses from physical Pin 7 and 13 on RPI B Rev 2 using stock code.
GPIO tool shows the mode as in and state as low, but not switching to high with key press. Tried both with Adafruit interface board and direct connection.
Will try another RPI Rev B board when able, but would appreciate other method to diagnose the problem in the interim (to determine if pins are fried or a software / OS installation problem). If HW problem will rewire interface board/connections as required but want to rule software out first.
Hello there,
I encounter a problem regarding the buttons in Kodi. The buttons aren't working even tho' it's working on the "desktop" and retropie.
I put a Pi Zero W into a PSP. Connected the GPIO to the controls of the PSP. I then installed a Raspbian Image. I apt-get install kodi to get kodi. And also installed Retropie manually using this link.
I use retrogame.cfg file to make the buttons work. And copy the retrogame in /usr/local/bin/retrogame (both files has been given to me so I don't really know thing about them, sorry).
# Sample configuration file for retrogame.
# Really minimal syntax, typically two elements per line w/space delimiter:
# 1) a key name (from keyTable.h; shortened from /usr/include/linux/input.h).
# 2) a GPIO pin number; when grounded, will simulate corresponding keypress.
# Uses Broadcom pin numbers for GPIO.
# If first element is GND, the corresponding pin (or pins, multiple can be
# given) is a LOW-level output; an extra ground pin for connecting buttons.
# A '#' character indicates a comment to end-of-line.
# File can be edited "live," no need to restart retrogame!
# Here's a pin configuration for the PSPi v2 project:
UP 23 # Up
DOWN 27 # Down
LEFT 22 # Left
RIGHT 17 # Right
Q 19 # Square
ENTER 16 # X
Y 20 # Triangle
ESC 26 # Circle
LEFTCTRL 24 # Left Trigger
RIGHTCTRL 21 # Right Trigger
S 12 # Start
D 6 # Select
VOLUMEDOWN 25 # Volume Down
VOLUMEUP 5 # Volume Up
# For configurations with few buttons (e.g. Cupcade), a key can be followed
# by multiple pin numbers. When those pins are all held for a few seconds,
# this will generate the corresponding keypress (e.g. ESC to exit ROM).
# Only ONE such combo is supported within the file though; later entries
# will override earlier.
I checked several post about the subject but I can't make it work, but I could'nt find anything that is appropriate to my project...
When I start the PSP I end up on the shell. From there I just use the Up button to get the last lines. I can enter kodi like that. Once there the buttons aren't working. When I start emulationstation or StartX it's working fine. It looks like the buttons are well "simulated" on those like I would use the keyboard but not in Kodi
Can someone help me to figure out how to get that working in Kodi ?
Thanks all
## EDIT :
I tried to configure the controller already. I didn't say it but before this I tried a Retropie Image and installed Kodi from there. Same problem, buttons works in Retropie not in Kodi. And when I try to make a new input in the controller the timer just go to 0 and I can't put any key, like the buttons are not recognize.
I checked the link with the Keymap already but as I'm running the stuff on a PSP which structure should I take ? Remote ? Gamepad ? Keyboard ?
Custom Joystick and I put retrogame like that ?
<joystick name="retrogame">
<button id="27">Down</button>
</joystick>
A other thing. The joystick from the PSP is connected to the Gamepad so basically the input from the gamepad are the same for the joystick it's exactly the same wiring.
So I tried like that, I created a new file psp.xml that I put here : ~/.kodi/userdata/keymaps
I wrote this inside :
<keymap>
<global>
<joystick name="retrogame">
<button id="27">Down</button>
<button id="23">Up</button>
</joystick>
</global>
</keymap>
It is not working either.
Is there any manipulation to do to "activate" the .xml file maybe so that Kodi recognize it ? Should I use a different structure ?
Hello,
How could this code be adapted to use an arduino uno as an expantion i/o board?
I'd like to create a 2 players machine, using 2 joysticks and 12 buttons. As there are only 17 Gpio pins on Raspberry, I thought in using an arduino as a I²c port expander.
Is it possible? Can you guys help me?
Thanks,
David
Ps: Sorry for the Bad English
I followed the instructions I have hooked up my arcade button to the correct two pins the ground and pin 5 I have not changed the config file but have moved it to the boot folder as it recommended. I just want to try to do a simple space in a text editor just to see if the code works properly. My end goal is to make an arcade cabinet. Please help with any advice or things to do to make this great idea work. Thank you :)
I have a problem:
I configured a PS3 controller (bluetooth) on retropie, when I was to play, I figured out that the GPIO gamepad and the PS3 controller are the same player.
I tried to install joystick-selection (https://github.com/meleu/RetroPie-joystick-selection), setting up the PS3 to be the second player and adding the line "Input_player1_joypad_index= "0"" in the /opt/retropie/configs/all/retroarch-joypads/Name Of Your Controller.cfg file, now I can play a versus battle, but the PS3 controller control the player 1 and player 2 at same time!
Is there a way to solve this?
Are there any additional tweaks needed for a Pi 3? Joystick works fine, buttons are not responding.
I have the following problem:
Two new buttons I installed have the contact closed when not pressed, and open when pressed. Since retrogame expects the GPIOs to be low, it always generates a keypress when the button is not pressed, but not when it is.
Is there any way to "reverse" that input for those two buttons (and only for them, the rest are normal buttons)?
hey
so i'm traying to set this up to run with retro pi my problem is that i have a some electronics on gpio 1 witch if pulled high turns off my screen and if low turns on the screen
what i need is a way to make you're script to do nothing to gpio 1 preferably a setting in the settings file witch allows me to edit this
Hi, so my pi is running the adafruit issue lastest version of rasbian with a ptfit display attached. I am running Retrogame to get button inputs set up for Retropi, and everthing works fine until I actualy start retrogame. Whenever I start retrogame, by going to /usr/local/bin and doing sudo ./retrogame, it just goes to the next line and freezes entirely. I compiled it multiple times, but it continues to do this even though it compiled fine, and the pi even tried to activate it on startup a few times, causing a freeze than too. After it freezes, it locks up completely and excepts no input from either the buttons or a keyboard. The only way to unfreeze it is to hard shutdown and reboot the pi.
Is there any way to add a delay so that the key stroke "activates" after a certain period of time?
Hi I am very happy with the software you have built so far but I want to add a second Player can you do that if so how and if not can you add a way? Thank you :)
root@retropie:/home/pi# cat /sys/class/gpio/gpio21/value
0
-> retrogame simulate endless key input.
When i hold something into this optical switch:
root@retropie:/home/pi# cat /sys/class/gpio/gpio21/value
1
-> No key input
retrogame simulate by the false gpio state
Or is the problem with me?
Had an arcade that used to use the old code that had the indiecity mame install.
raspberry pi 2 using gpio pins with 6 buttons and a joystick wanted to update to retropie
installed retropie from github on november 2016 raspian image w/ pixel desktop
i installed Retrogame and configured for 6 button + joystick, after reboot keyboard/mouse wont work anymore and the networking (hardwired) no longer works.
Figuring it might be something i did wrong I tried with a default latest Retropie image this time and it did that same thing after reboot when i pulled down the retrogame.sh and rebooted.
I did it 2 more times to be sure its not anything else. and same results.
A few folks have noted that on the PiGrrl 2 build the select button is getting mapped to [SPACE] currently, while also using this config in the instructions for the controller carries a default mapping of [SPACE] to toggle fast-forward... does not play nicely. Hitting select in any emulator will toggle fast-forward w/ the default config, no bueno.
This is an easy fix that can be applied in the retroarch.cfg file included in this repo that is being pulled down by the retrogame.sh script in the Raspberry-Pi-Installer-Scripts repo.
I’d really appreciate it if this was released under a permissive license... I don’t see any license listed right now. MIT would be great! Thank you so much for making this tool.
Sent with GitHawk
On my joy bonnet (attached to a Pi Zero W), pressing the "1" key on the PCB generates a "2" keyboard press and vice versa.
Trivial to fix by swapping the key codes in joyBonnet.py, but I was wondering if this is a known issue?
Downloading, installing retrogame...ERROR
Downloading, installing retrogame.cfg...ERROR
Performing other system configuration...OK
I get this when I try to install retrogame on my pigrrl zero. /boot/retrogame.cfg does not exist, and I've had some trouble remaining connected to the pi via SSH. Any tips as to what I should do to solve this?
With a MCP23017?
The latest retrogame is not working with the latest Retropie. I'd suggest that you make the WIP (config files feature) a different branch, and make the 11 august version the master branch (that one works).
Currently make install
moves the executable. Expected behaviour is to copy the executable
Thanks for making the new version where the only thing we have to change is the retrogame.cfg file. That makes it a lot easier to set up and such.
However, I still can't get it to work. I have a RPi3vB running RetroPie, and I followed the instructions on the Adafruit tutorial exactly, as far as I can tell.
Here is my retropie.cfg:
# Sample configuration file for retrogame.
# Really minimal syntax, typically two elements per line w/space delimiter:
# 1) a key name (from keyTable.h; shortened from /usr/include/linux/input.h).
# 2) a GPIO pin number; when grounded, will simulate corresponding keypress.
# Uses Broadcom pin numbers for GPIO.
# If first element is GND, the corresponding pin (or pins, multiple can be
# given) is a LOW-level output; an extra ground pin for connecting buttons.
# A '#' character indicates a comment to end-of-line.
# File can be edited "live," no need to restart retrogame!
# Here's a pin configuration for the PiGRRL 2 project:
LEFT 4 # Joypad left
RIGHT 17 # Joypad right
UP 27 # Joypad up
DOWN 22 # Joypad down
A 18 # 'A' button
B 23 # 'B' button
# For configurations with few buttons (e.g. Cupcade), a key can be followed
# by multiple pin numbers. When those pins are all held for a few seconds,
# this will generate the corresponding keypress (e.g. ESC to exit ROM).
# Only ONE such combo is supported within the file though; later entries
# will override earlier.
My setup is really simple: just the 4 directions on a joystick and two buttons. When I run retrogame:
./retrogame
I don't get any error messages or anything, but nothing happens when any of the GPIO pins are shorted to ground. I even tried directly touching one of the wires connected to the appropriate GPIO pin to the wire connecting to the GRD pin, but still nothing.
Any ideas on what I can do to troubleshoot?
Hi,
I want to use the project PIGRRL with an Archlinux.
For the screen PITFT, I add these lines in config.txt:
device_tree_overlay=pitft28
dtoverlay= pitft28,rotate=270,speed=32000000,fps=60
And I add pitft28-overlay.dt bin /boot/overlays/
For the retrogame (keyboard map GPIO):
I have a raspberry pi b rev1 (256 ram), so I must update map.
I change the pin numbers 2, 3 and 27 to 0, 1 and 21, respectively. Recompile with:
make CFLAGS=-DCUPCADE
sudo make install
modprobe uinput
sudo retrogame
But I have this error:
./retrogame: Pin config failed. Try 'sudo ./retrogame'.
Have you an idea ?
Thank you.
from testing, it seems that retrogame (rather, available GPIOs) is (are) maxxed out when running with PITFT and Cupcade Interface board (also as state in the source file). Previously, attempts to reroute to other PINs has resulted in errors when executing the binary (Pin config error).
Does any one have any success / suggestions on modifications to allow retrogame (and such a hardware setup) to support something like the PiSuppy? (which by default, requires physical Pin 8 and following recommended installation, Pin 7)?
sudo apt-get install libncurses5-dev libncursesw5-dev
sudo apt-get install expat libexpat1-dev
(debian version 7.2)
Hi there,
First of all, I don't know if this issue would fit here, so if not, feel free to close it.
I've installed a port by YoYo Games of the amazing game Maldita Castilla for the Raspberry Pi.
I've followed these instructions and it's working perfectly, but only when using a keyboard, not when pressing the GPIO arcade buttons.
Do you know why that might be?
The other ports that come bundled with RetroPie work flawlessly. And also all the emulators.
Thanks!
Any chances of guides for building on
Does it recognize button press on Rising edge and release on falling edge, or what? I have my buttons pulled down then when the button is pressed it reads high. Is this opposite of how retrogame works?
I can't rewire it because the circuit is set up in such a way as when any button is pressed, a LED lights inside the game cabinet.
Can retrogame be changed so it recognizes the button press at a HIGH signal instead of LOW?
My question is if I was playing could I do diagonal so not just Left, Right, Up, and down, could it be up-left, upright, down-right, down,left? Thanks again for taking the time to look at the questions and issues. :)
I'm using Retrogame along with Retropie to create a portable gaming system for my little brother. Right now I'm using Retrogame to listen for inputs through the GPIO pins on the Raspberry Pi. The program works great, but only if a keyboard is plugged in. I looked around and read lots of blog posts and forums, and I can't find any information concerning a work around. Is there a way for retrogame to work without a keyboard plugged in?
Thank you for your help.
I just finished building a home arcade kit called Porta-Pi that runs RetroPie 1.9.1 and uses Retrogame as the input. It works wonderfully and is a great alternative to buying a dedicated input device. Not to mention I actually learned something working on something I love to do! :)
I recently tried to upgrade RetroPie to version 2.2 and it longer works. After some searching the programmer of RetroPie/EmulationStation posted this on a forum:
"I have the same problem as you. I asked Aloshi (creator of EmulationStation) on the Raspberry Pi Forums and this is what he said:
This probably has to do with the change from SDL 1.2 to SDL 2. SDL2 uses evdev for input handling (in the console in the Pi). I don’t remember what SDL 1.2 uses. Not much I can do about this, sorry."
I don't know anything about programming but I have learned a lot about Unix just doing this project and really enjoyed it. Is there any chance in a future version this could possibly incorporated into retrogame.c. It's a fantastic piece of software and I really appreciate all the work put in to it.
Also I use to use an older version that didn't require downloading ncurses and expat(?) but after rebuilding my SD card I had to download the newer version and also download the additional software. Is there a repository or link you might share to download the older version without the new additions?
Thank you and have a great morning!
How do I cross-compile this ?
Eg. produce an arm binary with a x86/x86_64 Ubuntu.
Thanks :)
Is this compatible with Raspberry Pi 3 Model B? Not getting any response from my buttons and as far as I am aware the GPIO is the same as the 2 models.
Just followed https://www.youtube.com/watch?v=4u1NKok2-BE to get the PiTFT to work on a Rasp 3, but when it got to this step I used the new commit where we do not change the ioStandard table at all but when I boot up the Rasp again the input Gamepad is not detected. I checked the voltage and all seems ok. This last commit (67a447e) seems to be the only difference in how it works.
The retrogame.cfg is also located in directory /home/pi
I use GPIO with this config:
{ 22, KEY_LEFT }, // Joystick (4 pins)
{ 23, KEY_RIGHT },
{ 17, KEY_UP },
{ 27, KEY_DOWN },
{ 24, KEY_LEFTCTRL }, // A/Fire/jump/primary/RED
{ 10, KEY_LEFTALT }, // B/Bomb/secondary/YELLOW
{ 9, KEY_Z }, // X/BLUE
{ 25, KEY_X }, // Y/GREEN
{ 18, KEY_SPACE }, // Select
{ 4, KEY_ENTER }, // Start
{ 11, KEY_A }, // L Shoulder
{ 8, KEY_S }, // R Shoulder
{ 13, KEY_1 }, // PiTFT Button 2
{ 19, KEY_2 }, // PiTFT Button 3
{ 26, KEY_3 }, // PiTFT Button 4
It works great on retropie interface but not in game, retroarch doesn't recognize this GPIO, doesn't know why.
Hi, I would be interested in repeating key 5 (used to add credits) so my MAME emulator can add more than 1 credit. This repeated key must be delayed so MAME can distinguish it from the previous one.
Thanks so much in advance
Best Regards
Pablo
Trying to set this up to work with the Pi 2 and some buttons work... but others like GPIO21 (pin40) pressed to the ground next to it, does nothing?
To debug I've mapped 4, 17, 24 ,25 ,5, 6, 12, 13, 19 16, 26, 20, 21
all to different keyboard letters.
26, 19, 12, 13, 6 and 4 work
20 sends randomly when i press the other buttons :(
the rest don't work at all. I've checked for shorts everywhere and all the buttons themselves work.
Here's what I'm working on: http://i.imgur.com/ocLdTe5.jpg
And these are the insides: http://i.imgur.com/phMY4Ku.jpg
Is there anyone who managed to run retrogame on Batocera? I want to switch from retropie to Batocera without resoldering my GPIOs.
Many thanks in advance!
Making a Pigrrl project somewhere between a Pigrrl 2 and Zero. I'm using a Raspberry Pi 3 and have retropie and retrogame installed. Buttons work great in emulationstation but do nothing in a game. Any ideas on what's going wrong?
Hello,
I am using your script on RetroPie (http://blog.petrockblock.com/retropie/) and it is awesome. I customised all my buttons and everything is fine.
What I would like to ask, is to find a way to emulate something else than a keyboard (Gamepad 2), so I could configure the options for an other player.
I don't know if it is currently possible...
Any idea?
Hi there!
I built a nice little arcade box with an RPi2, 6 Arcade buttons, and an adafruit Small Joystick. Everything is wired up fine, and responds accordingly most of the time. However after some time (at random) I notice that a certain input wont respond. I am using MAME as my arcade platform for now. For example, I'll be playing a game then all of the sudden the Up motion on the joystick won't respond, or the Shoot arcade button will just not react. After a reboot everything will work for awhile again, then the error will happen. I am puzzled to believe this is still a hardware issue, have there been any known issues with MAME using retrogame? I have made sure SDL2 compatibility is okay and everything.
Retrogame isn't noticing button presses (debugging with http://wiringpi.com/the-gpio-utility/ I can see the pins go from high to low when I press them, but it doesn't reliably send the key stroke).
Advice?
-Jon
I have followed the directions, added the udev rule, yet emulationstation will not recognize the buttons. I am able to see that retrogame is functioning, as each press of a button results in an emulated keypress as expected. I have tried every guide and piece of advice I could find in my 6 days search for a solution, tried multiple times to format, and re-image the SD card, I have started from scratch around 50 times. the real "fix" provided by CrazySpence both on the adafruit git, and his github page doesn't work with v2.3 because the SDL folder does not exist in this version. bummer! Why can't it all just work?! wink
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.