element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum How to Interface Arcade Controls with the Raspberry Pi
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 24 replies
  • Answers 2 answers
  • Subscribers 675 subscribers
  • Views 6610 views
  • Users 0 members are here
  • arcade_machine14
  • buttons
  • gpio
  • joystick
  • retrogaming
  • retro
  • raspberry_pi
  • raspberry-pi
  • raspberrypi
  • arcades
Related

How to Interface Arcade Controls with the Raspberry Pi

spannerspencer
spannerspencer over 10 years ago

Hi guys! As you know, we're putting together a Raspberry Pi-powered arcade machine, so we can live firmly in the past (where all the good stuff happened) and revel in the joys of retro video games!

 

Among the various challenges we're faced with in adapting our new cabinet is interfacing the controls with a Raspberry Pi, so I thought I'd ask for a few suggestions from the people in the know (that's you).

 

Joysticks & Buttons

In principle this is a very simple task, because the arcade controls are just micro-switches. They could go straight onto the GPIO pins, with a bit of cunning software running on the Pi to turn the inputs in HID keyboard presses. The emulator recognises these straight out of the box, making it a very neat and efficient way to interface the controls.

 

However, the problems arise from there not being enough GPIO inputs for the number of controls we need. So what can we do to either increase the number of inputs, or maybe even go in a totally different direction, such as converting it all to use a USB input of kind? Would love to hear some creative suggestions from you guys on the subject.

 

List of Inputs

Here's a breakdown of the number of inputs we need to get the arcade machine up and running. Each input can just be considered a simple switch -- nothing clever needed with analogue controls or the likes. This is purely on/off digital simplicity. Just a lot of them.

 

Input NumberFunction
1Player One - Left
2Player One - Right
3Player One - Up
4Player One - Down
5Player One - Button 1
6Player One - Button 2
7Player One - Button 3
8Player One - Button 4
9Player One - Button 5
10Player One - Button 6
11Player One - Start
12Player Two - Left
13Player Two - Right
14Player Two - Up
15Player Two - Down
16Player Two - Button 1
17Player Two - Button 2
18Player Two - Button 3
19Player Two - Button 4
20Player Two - Button 5
21Player Two - Button 6
22Player Two - Start
23Coin/Credit (a single input from the coin mechanism, rather than one for each player)
24Exit Game (a button to bring players out of the game, and back to the emulator)
25Select Game (for choosing a game to play from the emulator's list)
26Pause
27Spare (just in case)
28Spare
29Spare
30Spare

 

Your thoughts on a post card, please!

  • Sign in to reply
  • Cancel
  • shabaz
    0 shabaz over 10 years ago in reply to spannerspencer

    Hi!

     

    But late to the thread, but I noticed adafruit has some driver type code to convert GPIO presses to keyboard events for easy interfacing to existing software, here:

    https://learn.adafruit.com/retro-gaming-with-raspberry-pi/buttons

    (apparently the source code is there, so it could be modified to work with the more advanced 30-ish key proposed keyboard here.

    I think a good (and easy) way would be to use a few 74HC240 ICs (it is an octal tri-state buffer easily available in DIP packages), and stick 8 inputs per chip.

    So, 4 of these ICs would allow for 32 inputs. Each could be built on a separate stripboard (i.e. each one intended for 8 inputs), and then sandwich the boards to connect

    all the outputs together (since it is tri-state).

    The alternative 74HC241 is non-inverting but isn't available in DIP in UK stock, the '240 version has better availability.

     

    The ICs would be scanned using either 4 outputs from the Raspberry Pi, or could be done with an external oscillator and counter, but probably easier to use the Pi.

    This means 8+4 GPIO connections are needed overall, which hopefully the RPI has! (I have not counted).

     

    This means that any combination of simultaneous button presses is fine!

    The adafruit code would need to read which of the 4 ICs is selected of course, so a small code modification is needed there.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 10 years ago

    going back to the switch inputs, there is no need to try to input all those switches directly into the PI, one GPIO at a time, use a few MCP23S17 (SPI) or MCP2317 (I2C) to read all inputs in one go, using the GPIO will require a seperate read for every pin, the 23S17 is 16 bits for one chip, can be in or out and is cascadeable so easy to have 32 pins read in a single SPI command, debouncing may not even be necessary really or just a simple RC network, these old games used either heavy duty micro switches or the equivilent of heavy duty relay contacts that the button or lever pushed aginst. Software debounce would be easy to do if your read, then imedialtly read again and compare the results, it need not be any more complicated than that

     

    The chips also have the option to use an interupt on any pin change if you want... easy (Relativly)

     

    Episode 187: Ben Heck’s Teensy Pinball Portable Part 1 Episode 17.5 mins in is bens pinball input board using a different chip but basically the same idea and he also did not use debounce as it was not needed

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 10 years ago in reply to Robert Peter Oakes

    It seems that a bunch of NZ students did it up north some time ago using an Arduino.

    http://www.futureintech.org.nz/enews/Industry/story.cfm?ID=14

     

    No details on how but it seems a perfect job for a micro ...

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gadget.iom
    0 gadget.iom over 10 years ago

    This is quite an inspiring project. Think I'm gonna spend a while looking for discarded arcade machines now.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • spannerspencer
    0 spannerspencer over 10 years ago in reply to gadget.iom

    It was surprisingly tricky getting one (at a reasonable price, anyway). I guess they're becoming more popular and less available all the time! Well worth it though -- I have one in my living room, and it gets used way more than any of our consoles image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Problemchild
    0 Problemchild over 10 years ago in reply to balearicdynamics

    Why don't you just use one of those programmable button to Keyboard HID device boards that everyone else uses !

    Stick it in the USB and you are away with out having to write custom support for the device to talk to the likes of Mame etc.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • spannerspencer
    0 spannerspencer over 10 years ago in reply to Problemchild

    There's a lot to be said for making it easy for ourselves with one of those image

     

    But I thought it'd be good to explore as many options as possible; particularly if any of those options reduced the number of add-on or extras the project would need.

     

    I've used the type of adapter you're talking about though, and they are smooth and simple.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Problemchild
    0 Problemchild over 10 years ago in reply to spannerspencer

    Indeed it would be nice to use the GPIO directly but I think you may have problems if the cable length is significant maybe an IO expander like the MCPxxxx devices already mentioned would be good then have an I2C +interrupt say to  service the key press. you would also need to create some bodge ware to turn that GPIO button press to the corresponding keyboard events so that the non GPIO aware emulators can interface to it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 10 years ago in reply to spannerspencer

    All the methods have some compromises, so really depends on requirements.

    The USB k/b method is excellent, but suffers from N-key issue for an off-the-shelf part, unless you write your own code to support this, using any microcontroller with USB capability.

    But is very excellent, since no need to write a driver for the RPI. And the number of keys simultaneously detected may not matter too much if they are games designed for a computer rather than a console.

    The I2C method is great too, but requires a driver to simulate keypresses - maybe this already exists, I don't know. I did find source code in a google search, but for an old TI expander.

    The GPIO method also needs a driver, but one does exist (the Adafruit one), although it would need modifications to support the 30 or so keys.

    Maybe all-round, the USB k/b method is quickest and may be good enough.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Problemchild
    0 Problemchild over 10 years ago in reply to shabaz

    The Ipac thing is what I was thinking of and since it has dedicated pins you don't have those "N" key roll over problems

    http://www.ultimarc.com/ipac1.html

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube