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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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 667 subscribers
  • Views 5886 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 9 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
  • balearicdynamics
    0 balearicdynamics over 9 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
  • gadget.iom
    0 gadget.iom over 9 years ago

    I haven't played these games much in the past, but I'm having trouble finding the 12 buttons on the attached images in the linked post. It looks like the console has two joysticks (4 switches each) and eight buttons (4 each). Are you planning to add more?

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

    Ah yes, sorry -- I wasn't too clear there. Yeah, it's going to have a new control board, with more buttons on it image  And some of the buttons might be on the cab itself, too.

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

    Ahh ok.

    Another approach could be to emulate USB keyboard presses for each button using a commercially available keyboard emulator, or better still an Arduino/Teensy programmed up with the keyboard libraries.

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

    Maybe an alternative. But the bare buttons connected to an input are not sufficient in my opinion should be debounced. Then, there are 30 inputs, and I vote again Arduino. Better the PIC 80 MHz More reliable.

     

    Enrico

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

    Yeah, either a hardware debounce could be built. It might also be possible to employ some software debounce.

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

    Software debounce is almost impossible for two reasons. The first is that you have 30 inputs so you should use a shift-in register and the second is that also when possible, this introduce a huge complexity in the code (AFAIK) that is easier to use something like the schematics I posted in above.

     

    Enrico

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

    Given that the Raspberry Pi 2 has 26 inputs (if I remember correctly), how do you think it'd manage if we just took the buttons direct to the GPIO? If we could run some kind of "GPIO-to-keyboard-presses" script, each button comes into the emulator as a key press. Is that likely to suffer from button bounce? If it is, would something as simple as a pF cap across the micro-switch terminals take care of that?

     

    Also, I had another thought in case we need additional buttons. If it worked as above, with buttons going direct to GPIO, could a keyboard script recognise two simultaneous GPIO pins as a different key stroke?

     

    For example, let's say that PLAYER ONE LEFT goes to GPIO pin 14, and PLAYER ONE RIGHT goes to GPIO pin 15. These two will never be physically used together, because of the joystick position. So if GPIO pins 14 and 15 are simultaneously grounded, could that be recognised as a whole different keyboard press, thereby effectively increasing our range of inputs without additional hardware?

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

    Spanner Spencer wrote:

     

    For example, let's say that PLAYER ONE LEFT goes to GPIO pin 14, and PLAYER ONE RIGHT goes to GPIO pin 15. These two will never be physically used together, because of the joystick position. So if GPIO pins 14 and 15 are simultaneously grounded, could that be recognised as a whole different keyboard press, thereby effectively increasing our range of inputs without additional hardware?

    That might work, until the player tries pressing the up or down buttons on the joystick while pressing the "simultaneous" button. Most arcade buttons have a single SPCO microswitch, so simultaneously grounding on one button press may be complex to achieve.

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

    Ah, yeah -- I think I see what you mean. PLAYER ONE LEFT might not register while the "simultaneous" button is being pressed, because that GPIO pin is already grounded? So you won't be able to move left or right while using that joint, "simultaneous" button.

     

    Good catch, man image

    • 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