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 6599 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
Parents
  • balearicdynamics
    0 balearicdynamics over 10 years ago

    Hi, let me explain the idea before tracking down the circuit and a decent documentation.

     

    First of all take in account that there is an already working software with a set of single-characters commands with the relative parser to connect the ChipKit PI by one side and the Raspberry PI to the other. It works fine and is modular and I can customise it in very few time. So all the input can already send to the PI just the corresponding "command" character. Not only but the parser in this case is monodirectional so the Raspberry PI component side can be simplified.

     

    As the console uses almost vintage joysticks and buttons, I suppose that they has also the need to be managed properly to reach the switching quality needed by the micro controller hardware at the date. To simplify the software on the micro we can send already "cleaned" switch signals with a debouncing bank (also the cost is really very few $) with a circuit like the example image below, done for 5 switches (can be expanded as well)

    image

    Then we should consider that we are working with 30 input switches and the switch detection time is strategic in most of the arcade games. So all the 30 inputs can be read sufficiently fast by a shift-in register (four daisy chained registers can manage up to 32 inputs) so the ChipKit PI as a matter of fact should continuously monitor the four-bytes input status, check if some bit has changed and with some fast AND operations will send the corresponding character to the Raspberry PI. As the communication / parsing protocol on the Raspberry PI receives a CR as the end command it is also possible to send multiple characters if needed to manage simultaneous button press if needed. This is a parameter that can be set at software level.

    As the Raspberry PI software is developed in C++ it is not difficult to integrate it in Python, as a command line parameter or in any other way (including a background process as it actually works).

     

    Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • balearicdynamics
    0 balearicdynamics over 10 years ago

    Hi, let me explain the idea before tracking down the circuit and a decent documentation.

     

    First of all take in account that there is an already working software with a set of single-characters commands with the relative parser to connect the ChipKit PI by one side and the Raspberry PI to the other. It works fine and is modular and I can customise it in very few time. So all the input can already send to the PI just the corresponding "command" character. Not only but the parser in this case is monodirectional so the Raspberry PI component side can be simplified.

     

    As the console uses almost vintage joysticks and buttons, I suppose that they has also the need to be managed properly to reach the switching quality needed by the micro controller hardware at the date. To simplify the software on the micro we can send already "cleaned" switch signals with a debouncing bank (also the cost is really very few $) with a circuit like the example image below, done for 5 switches (can be expanded as well)

    image

    Then we should consider that we are working with 30 input switches and the switch detection time is strategic in most of the arcade games. So all the 30 inputs can be read sufficiently fast by a shift-in register (four daisy chained registers can manage up to 32 inputs) so the ChipKit PI as a matter of fact should continuously monitor the four-bytes input status, check if some bit has changed and with some fast AND operations will send the corresponding character to the Raspberry PI. As the communication / parsing protocol on the Raspberry PI receives a CR as the end command it is also possible to send multiple characters if needed to manage simultaneous button press if needed. This is a parameter that can be set at software level.

    As the Raspberry PI software is developed in C++ it is not difficult to integrate it in Python, as a command line parameter or in any other way (including a background process as it actually works).

     

    Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
  • 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
  • spannerspencer
    0 spannerspencer over 10 years ago in reply to Problemchild

    Ah yes, I've used an I-Pac before -- that was with a PC, and it was pretty good. Very simple, and it worked as advertised. I can only assume that it'd work just as well with an RPi. No reason to assume otherwise, anyway.

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

    Very cool : ) That looks very good, and seems to have a ton of features for games.

    Maybe (say) a FRDM board could be used to replicate some version of this, would be an nice project to build a key interface to USB for gaming uses. Maybe something like the K22F, which looks like it has enough I/O for it.

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

    Anything with enough I/O and can implement a USB Keyboard HID device would be good I think Shabaz

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

    If you are interested in connecting original controllers to the Pi like arcade controllers or other original controllers like SNES or Genesis/Megadrive controllers, you might be interested in the ControlBlock. It was designed specifically for that use case: https://blog.petrockblock.com/controlblock/ It even provides a power switch functionality.

    • Cancel
    • Vote Up 0 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