GPIO buttons config HOWTO?

General GBZ-related chat goes here. Share ideas, tips and tricks, or ask questions that don't fit into the hardware/software help forums.
laluva
Posts: 17
Joined: Thu Aug 25, 2016 12:35 pm
Has thanked: 1 time
Been thanked: 3 times

GPIO buttons config HOWTO?

Post by laluva » Fri Sep 30, 2016 1:33 pm

Hello

Have a ZERO wired directly from the GPIO to a common ground panel.

Can not get it to work.

Hope someone here has any good tips.

Have updated with a fresh install of retropie 4.02.

Have followed this guide on how to do the software configuration.
https://learn.adafruit.com/retro-gaming ... s-software.
There is not much info on the internet on how to do this, and the guide above is the only updated to the new easy way to do it.
Have checked my wiring for contiuinity and have even tried another raspberry pi with an jumper cable between pins for simulating common ground panel.
Have read the tutorial up and down without result.

I am not sure if the key names are correct, and that may be the issue.
And i am not sure if i should use the "GPIO" number or the "PIN" number in the retrogame.cfg file

I also get "no gamepad detected" at retropie welcome setup screen.

retrogame.cfg file is placed in /boot folder and looks like this:


# 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:

GND 39 # 'GND'
LEFT 31 # Joypad left
RIGHT 32 # Joypad right
UP 29 # Joypad up
DOWN 35 # Joypad down
LEFTCTRL 37 # 'A' button
LEFTALT 36 # 'B' button
SPACE 40 # 'Select' button
ENTER 38 # 'Start' 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.

User avatar
Chedda
Posts: 151
Joined: Fri Sep 16, 2016 3:11 pm
Location: USA (for now)
Has thanked: 29 times
Been thanked: 52 times

Re: GPIO buttons config HOWTO?

Post by Chedda » Fri Sep 30, 2016 1:38 pm

It is not the pin number that corresponds to a GPIO number.

The correspond with these numbers.

Image
Builder and tinkerer

laluva
Posts: 17
Joined: Thu Aug 25, 2016 12:35 pm
Has thanked: 1 time
Been thanked: 3 times

Re: GPIO buttons config HOWTO?

Post by laluva » Fri Sep 30, 2016 2:08 pm

Should i use the pin nr or the GPIO number in the retrogame.cfg?

My Ground point is PIN 39 it has no GPIO number, how should it be texted in retrogame.cfg?

My "A" button is wired to PIN 37 same as GPIO26, should i use 37 or 26 in the retrogame.CFG?

Tutorial says this about ground point, but i dont understand it.
"If you want to use a GPIO pin as a spare ground for buttons: use “GND” as the key name, then list one or more pin numbers separated by spaces."

User avatar
Chedda
Posts: 151
Joined: Fri Sep 16, 2016 3:11 pm
Location: USA (for now)
Has thanked: 29 times
Been thanked: 52 times

Re: GPIO buttons config HOWTO?

Post by Chedda » Fri Sep 30, 2016 2:21 pm

I did another reply with the config you need
Last edited by Chedda on Fri Sep 30, 2016 2:34 pm, edited 1 time in total.
Builder and tinkerer

User avatar
Chedda
Posts: 151
Joined: Fri Sep 16, 2016 3:11 pm
Location: USA (for now)
Has thanked: 29 times
Been thanked: 52 times

Re: GPIO buttons config HOWTO?

Post by Chedda » Fri Sep 30, 2016 2:33 pm

Your config should be this.


LEFT 6 # Joypad left
RIGHT 12 # Joypad right
UP 5 # Joypad up
DOWN 19 # Joypad down
LEFTCTRL 26 # 'A' button
LEFTALT 16 # 'B' button
SPACE 21 # 'Select' button
ENTER 20 # 'Start' button
Builder and tinkerer

laluva
Posts: 17
Joined: Thu Aug 25, 2016 12:35 pm
Has thanked: 1 time
Been thanked: 3 times

Re: GPIO buttons config HOWTO?

Post by laluva » Fri Sep 30, 2016 2:47 pm

Thanks.

tried it now still not working.

Could there be some command missing in the tutorial, or some misspelling?

this line
/home/pi/Adafruit-Retrogame/retrogame &

is copied in to this folder
sudo nano /etc/rc.local

User avatar
Chedda
Posts: 151
Joined: Fri Sep 16, 2016 3:11 pm
Location: USA (for now)
Has thanked: 29 times
Been thanked: 52 times

Re: GPIO buttons config HOWTO?

Post by Chedda » Fri Sep 30, 2016 3:01 pm

did you do another make retrogame? You have to create a new one every time you change the cfg
Builder and tinkerer

laluva
Posts: 17
Joined: Thu Aug 25, 2016 12:35 pm
Has thanked: 1 time
Been thanked: 3 times

Re: GPIO buttons config HOWTO?

Post by laluva » Fri Sep 30, 2016 3:22 pm

Tutorial says nothing about make retrogame, how is the command?
and when do i use it?

As i understand from this tutorial there is a new simpler way of doing this as of september 2016.

User avatar
Chedda
Posts: 151
Joined: Fri Sep 16, 2016 3:11 pm
Location: USA (for now)
Has thanked: 29 times
Been thanked: 52 times

Re: GPIO buttons config HOWTO?

Post by Chedda » Fri Sep 30, 2016 3:39 pm

Sure it does. It says it at the bottom of the page. Here is the command.

Make retrograme
Builder and tinkerer

rdazjeff
Posts: 14
Joined: Tue Aug 30, 2016 10:34 am

Re: GPIO buttons config HOWTO?

Post by rdazjeff » Fri Sep 30, 2016 4:25 pm

Hi,
i used this tuto and work perfectly, not trouble at all for ALL GAME
Iv'ed test a lot of game and emulator and all work #1.
http://www.sudomod.com/forum/viewtopic.php?p=525

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest