Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: pi 2 or 3, Gpio for controls, questions  (Read 4066 times)

0 Members and 1 Guest are viewing this topic.

ivwshane

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1036
  • Last login:December 24, 2022, 09:35:21 pm
    • My first mame cab! (WIP)
pi 2 or 3, Gpio for controls, questions
« on: September 12, 2016, 01:06:27 am »
I'll be making a two player bartop and I'll be using either a raspberry pi 2 or 3. I'll be using recalbox which I believe supports gpio. I think the total number of inputs the 2 or 3 supports is 26 which should be enough. Am I correct? Are there any disadvantages to using gpio inputs other than compatibility (input lag? Ghosting? Reliability)?

lilshawn

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7377
  • Last login:Yesterday at 07:40:39 pm
  • I break stuff...then fix it...sometimes
Re: pi 2 or 3, Gpio for controls, questions
« Reply #1 on: September 12, 2016, 01:29:34 pm »
AFAIK the GPIO inputs are all completely separate and the polling rate of the GPIO pins is dependant on the OS/programming language used to access them. (anywhere from 40hz to 20khz) i remember reading someone tested the GPIO switching rate with various programming languages and different methods of access, but I don't recall who or where. but even at 40hz, 0.025 of a second is probably unnoticeable.

depending on how many buttons you plan on using per player and the use of admin buttons, 26 may or may not be enough. (26 is enough for a joy and 6 buttons and start buttons for 2 players and a few admin) if you go franken panel you might need more or have to shift buttons with a button to double up some admin buttons.

TL;DR - Ghosting won't be an issue...I don't think lag will be much of an issue.

ivwshane

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1036
  • Last login:December 24, 2022, 09:35:21 pm
    • My first mame cab! (WIP)
Re: pi 2 or 3, Gpio for controls, questions
« Reply #2 on: September 13, 2016, 04:36:20 am »
Thanks.

I'm thinking of going with a six button layout with a start and a coin button and two admin buttons, esc and pause.

Dave Bullet

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10
  • Last login:January 06, 2020, 05:41:45 pm
  • I like to fiddle.
Re: pi 2 or 3, Gpio for controls, questions
« Reply #3 on: December 31, 2016, 04:19:46 am »
Retrogame is a GPIO to virtual keyboard emulator.  I'm hacking it to support more than one "pin combination" per key mapping.  Of course you are still constrained to physical buttons / switches, but combinations can trigger other key presses. 

eg. think of using say the player 1 start button as a "shift" key combined with joystick up or down to increase/decrease volume, or player 1 start + player 2 start to end the game (MAME ESC key).

When my PI arrives, I'll let you know if it works if you are interested.

ivwshane

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1036
  • Last login:December 24, 2022, 09:35:21 pm
    • My first mame cab! (WIP)
Re: pi 2 or 3, Gpio for controls, questions
« Reply #4 on: January 01, 2017, 03:23:58 am »
I use recalbox and it allows for a "shift" key. Technically its called the hotkey. I wasn't aware of any limitations with regards to the hotkey and the gpio?

vinegar

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 25
  • Last login:August 12, 2017, 09:07:18 pm
  • ID/hardware hacker
Re: pi 2 or 3, Gpio for controls, questions
« Reply #5 on: January 01, 2017, 11:59:22 am »
i know i'm replying to question from september, but i found the problem with using the pi's GPIO wasn't so much latency, it was extremely inconsistent latency (unsurprising since the BCM chip has limited interrupt paths and GPIO is going to be competing with the system).  i didn't formally time any of it, but i could feel it on a pi 3 in fast-twitch games.  using a separate hardware key encoder (i used an arduino with the FastGPIO lib) had a more consistent/predictable feel for me even with USB HID overhead.

edit: worth noting i'm kinda nuts, so you might not notice the inconsistent latency i do  ;D  even if i'm totally insane, it was worth it to use a USB solution with the encoder close to the CP just to save myself from having to run an unwieldy wire bundle, and have the ability to deal with any potential alterations at the CP.
« Last Edit: January 01, 2017, 12:55:44 pm by vinegar »

Dave Bullet

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10
  • Last login:January 06, 2020, 05:41:45 pm
  • I like to fiddle.
Re: pi 2 or 3, Gpio for controls, questions
« Reply #6 on: January 01, 2017, 03:25:26 pm »
I use recalbox and it allows for a "shift" key. Technically its called the hotkey. I wasn't aware of any limitations with regards to the hotkey and the gpio?

Solutions like recallbox, the petRock control board, ipac2/4 control boards etc... get around this issue (as you noted).

I stumbled upon retrogame (software only) - similar to recallbox??? as I didn't want to spend more on hardware.  The petRock and ipac2 look like good units, but would cost me more than the Pi itself.  I have a mental barrier when it comes to spending more on one accessory than the computer itself  :lol

For other newbies (like me) reading this... The limitations are you have only 26 available GPIO pins to program from (Pi 3).  So if you have more buttons or controls than pins, then you need a hotkey (in PC speak - shift key) to enable one button to hotkey or shift other buttons.  The combination of pins can then be used to signal other key presses.  Of course you need to choose a shift key / hotkey not normally used in play (such as the start or coin buttons combined with joystick or player buttons).

Dave Bullet

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10
  • Last login:January 06, 2020, 05:41:45 pm
  • I like to fiddle.
Re: pi 2 or 3, Gpio for controls, questions
« Reply #7 on: January 01, 2017, 03:32:37 pm »
i know i'm replying to question from september, but i found the problem with using the pi's GPIO wasn't so much latency, it was extremely inconsistent latency (unsurprising since the BCM chip has limited interrupt paths and GPIO is going to be competing with the system).  i didn't formally time any of it, but i could feel it on a pi 3 in fast-twitch games.  using a separate hardware key encoder (i used an arduino with the FastGPIO lib) had a more consistent/predictable feel for me even with USB HID overhead.

edit: worth noting i'm kinda nuts, so you might not notice the inconsistent latency i do  ;D  even if i'm totally insane, it was worth it to use a USB solution with the encoder close to the CP just to save myself from having to run an unwieldy wire bundle, and have the ability to deal with any potential alterations at the CP.

Ahh this is worrying for me!  did you capture any timings?  Good point about a USB solution largely eliminating the wiring mess.

vinegar

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 25
  • Last login:August 12, 2017, 09:07:18 pm
  • ID/hardware hacker
Re: pi 2 or 3, Gpio for controls, questions
« Reply #8 on: January 01, 2017, 05:19:39 pm »
if the decision was holding up a build, i'd say screw it and get used to it, you'll adapt.  since i had long ago braved the slow boat and bought a bunch of pro-micro arduino clones and screw terminal breakouts, and it also solved a clean wiring issue for me, i went ahead with writing an encoder.  i wasn't using that usb port on the pi for anything else, anyway.