Build Your Own Arcade Controls Forum

Main => Raspberry Pi & Dev Board => Topic started by: EightBySix on April 01, 2015, 05:55:19 am

Title: Controllers direct to GPIO - no keyboard encoder.
Post by: EightBySix on April 01, 2015, 05:55:19 am
Wanted to start a thread around this. It's attractive to me because it's one less component (the keyboard encoder). I also have a simple setup of two players, 2 buttons. If you have lots, then you'll run out of pins.

I got it working for player 1 (still to do player 2, coin sensor and a few admin buttons) using retropie - a program to monitor the pins, and initiate key presses - with these instructions (https://learn.adafruit.com/retro-gaming-with-raspberry-pi/buttons) from adafruit.

Note that some of the links are updated for the RPi2. It seems to work fine with Emulation Station.

The tricky bit for me was the physical connection from the controls to the GPIO header. The available pins aren't all together, so I connected the control wires individually after crimping these on the end.
(http://forum.arcadecontrols.com/index.php?action=dlattach;topic=136713.0;attach=326941;image)

The way I did it is flexible (I knew I wouldn't get them right 1st time) but I think a better approach would be to get or make a GPIO breakout cable with some screw terminals like this.
(http://forum.arcadecontrols.com/index.php?action=dlattach;topic=136713.0;attach=326943;image)
Might actually be better to make one, so I can put meaningful labels on it from the controls.


Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: DaOld Man on April 05, 2015, 08:47:30 am
Interesting. How many inputs are available? Enough for two player?
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: BobA on April 05, 2015, 10:51:54 am
Pi with the 26 pin header has 15 i/o ports.  Can be programmed as either input or output.
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: DaOld Man on April 06, 2015, 01:11:12 pm
Pi with the 26 pin header has 15 i/o ports.  Can be programmed as either input or output.

Not enough for most two player games.
I guess games that have both players using same controls would be ok (IE: Pacman, Donkey Kong, etc). But two player fighter games not so much.
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: nitrogen_widget on April 06, 2015, 01:53:52 pm
Doesn't the new RPI 2 have a 40 pin header?
That should equally a few more inputs.
Maybe enough for neo Geo?
Now I gotta research this.
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: keilmillerjr on April 06, 2015, 05:22:32 pm
Doesn't the new RPI 2 have a 40 pin header?
That should equally a few more inputs.
Maybe enough for neo Geo?
Now I gotta research this.

Marketing can be deceiving because not all 40 GPIO pins are I/O pins. I forgot the actual number.
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: nitrogen_widget on April 07, 2015, 11:08:00 am
Doesn't the new RPI 2 have a 40 pin header?
That should equally a few more inputs.
Maybe enough for neo Geo?
Now I gotta research this.

Marketing can be deceiving because not all 40 GPIO pins are I/O pins. I forgot the actual number.

It should be half.
if they followed the same scheme as the original.
so 20.
which should be enough for two joysticks with 6 buttons each.

admin/coin/start buttons would have to be handled by USB which isn't too bad an option.
I'm just not sure exactly which fighter games would work on a RPI or an RPI2.

i've read recently that some people have Final Burn Alpha Libretro Playing street fighter 3 smoothly on the RPI2 but I haven't tested this myself.
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: EightBySix on April 07, 2015, 04:07:58 pm
There are 15 pins available, plus 4 extra if you are happy to solder a header on = 19.

So for my setup:
 4 directions, and 2 buttons = 6

 x 2 players = 12

Plus p1 and p2 start and coin leaves room for 4 admin type buttons
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: nitrogen_widget on April 07, 2015, 06:22:45 pm
There are 15 pins available, plus 4 extra if you are happy to solder a header on = 19.

So for my setup:
 4 directions, and 2 buttons = 6

 x 2 players = 12

Plus p1 and p2 start and coin leaves room for 4 admin type buttons

ok.
So the classics.
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: elPaulio on April 12, 2015, 06:16:05 am
I did exactly this....

So I ended up making my own connections, but with the pins on the Pi end pre bought.
I had a 20cm cable length with one of those little pin connectors on each side.

I chopped the end off, and reused it. The other end, I crimped myself with spade connectors of various sizes and then simply spliced/soldered them together and put a bit of insulating tape around it
Note, soldering is important, because they would just not hold themselves with tape alone

worked well for me :)

If I were to do it again, id definitely go for either crimping both ends myself, or a breakout board like you suggest. It would just be cleaner, and easier to trace the cabling once its all in there
I have joystick, 6 player buttons and 3 more for start/credit/select/exit, so the wiring got a bit tiresome at times!
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: scaryevilguy on April 13, 2015, 05:13:55 am
(https://raw.githubusercontent.com/DigitalLumberjack/mk_arcade_joystick_rpi/master/wiki/images/mk_joystick_arcade_GPIOsb+.png)

This is the pinout I used in a RPi 2 using DigitalLumberjacks driver. It allows 2 joysticks, and 8 buttons per player. Works fine with Retropie
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: nitrogen_widget on April 13, 2015, 02:51:12 pm
Then I guess I was right.
didn't think it made sense to have a 40 pin GPIO but not increase the actual number of usable GPIO's incrementally.
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: StefanBurger on April 21, 2015, 03:28:22 pm
Adafruit has also an gpio to usb-keyboard driver:
https://github.com/adafruit/Adafruit-Retrogame (https://github.com/adafruit/Adafruit-Retrogame)
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: mvolke1 on May 07, 2015, 03:19:05 pm
I use an iPac with my Pi bar top and it's worked great. Very simple.
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: StefanBurger on May 07, 2015, 06:12:32 pm
I also use Ultimarc iPac4 with raspberry-pi 2 and it works great (just plug and play, will be recognized as a keyboard, no special drivers necessary).

Another approach would be a simple custom pcb with shiftregisters:
http://www.instructables.com/id/Using-a-shift-register-with-Raspberry-Pi/?lang=de (http://www.instructables.com/id/Using-a-shift-register-with-Raspberry-Pi/?lang=de)

Regards
Stefan
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: StefanBurger on May 07, 2015, 06:15:53 pm
Some YouTube Tutorial about using shiftregisters to expand number of input ios:
https://youtu.be/nXl4fb_LbcI
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: Slippyblade on May 07, 2015, 06:52:47 pm
I use a KADE mysef programmed as a keyboard encoder.  Not had any problems.
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: pbj on May 07, 2015, 11:08:31 pm
Pi 2 has recognized everything I've thrown at it thus far.
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: DaOld Man on May 09, 2015, 10:07:49 pm
(https://raw.githubusercontent.com/DigitalLumberjack/mk_arcade_joystick_rpi/master/wiki/images/mk_joystick_arcade_GPIOsb+.png)

This is the pinout I used in a RPi 2 using DigitalLumberjacks driver. It allows 2 joysticks, and 8 buttons per player. Works fine with Retropie

Anyone have a pinout pic like this one, but for the RPi B? 26 pins
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: nitrogen_widget on May 09, 2015, 10:23:34 pm
I'll be using this guide for my rpi1
https://learn.adafruit.com/retro-gaming-with-raspberry-pi/buttons
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: DaOld Man on May 10, 2015, 12:05:36 am
I'll be using this guide for my rpi1
https://learn.adafruit.com/retro-gaming-with-raspberry-pi/buttons

Thanks!
So from what I understand, we could use GPIO 24 & 8 for ESC and Player 1 Start?

I have a small (2.8") touchscreen that I plan to plug into this connector too. How would using these pins as inputs affect the screen?
Title: Re: Controllers direct to GPIO - no keyboard encoder.
Post by: StefanBurger on May 10, 2015, 01:09:24 am
...
I have a small (2.8") touchscreen that I plan to plug into this connector too. How would using these pins as inputs affect the screen?

well, assumed thats the same 2.8 touch tft like the following
http://www.adafruit.com/products/1601 (http://www.adafruit.com/products/1601)
...then:

Quote from: adafruit
...Uses the hardware SPI pins (SCK, MOSI, MISO, CE0, CE1) as well as GPIO #25 and #24. All other GPIO are unused. Since we had a tiny bit of space, there's 4 spots for optional slim tactile switches wired to four GPIOs, that you can use if you want to make a basic user interface. For example, you can use one as a power on/off button. See below for the link to get the optional tact switches, they're not included...