Saturday, 9 February 2019

USB Arcade Controllers

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

Last  year I built a Picade kit from Pimoroni, it's been great and has had a lot of use by me and my nephews.
The only thing I had an issue with was the buttons and they way they were mapped, the joystick is the cursor keys, which is fine. The keys on the side and enter and escape, which is also fine, but the buttons on the top and the two on the front are mapped as shift, control, alt, z, x, o, i and space, which didn't really make sense and confused a few emulators which used those keys for other things.
I missed the clicky sound of microswitched buttons, so decided to fit some to replace the original low profile switches. They are the same diameter as normal arcade switches, so it was a simple job to swap them over.
I ordered some standard microswitched arcade switches (from arcadeworlduk) and wired those up.
I had ordered a selection of colours, so I colour coded the wiring, with two wires for each switch rather than a common ground.
I also took the opportunity to solder in and heatshrink the wires on the power button as the crimp tags felt a little loose.
I arranged the new buttons to try to match the colours of other four and six button arrangements - the blue and purple are more distinct that they have come out in the photos.
It was all a bit of a tight fit, getting in those six buttons, and four black buttons around the base of the case, but it all fell into place in the end.
Since the button usage was now more consistent, I used the stickers supplied with the Picade kit to label up some of the buttons. Did I get it right, are there better arrangements?
With all of those wired up, it was time to plug them in. I think by adjusting the setup script on the Pi I should have been able to map these to different keys still using the Picade X Hat controller, but decided to go a different way. I have found in the past the best option with Retropie was to use a game controller with lots of buttons and dedicated start and select buttons.
This is the replacement board I designed, it is a USB game controller with inputs for a 4 way joystick and up to 8 buttons.
Each of the inputs has it's own ground connection along the bottom of the board, all are switched to ground, no multiplexing or keyboard matrix is used here.
The original joystick was microswitched, so I left that as is. It was on a connector with 5 pins on, so I fitted a matching 5 pin socket. The buttons are connected to eight 2 pin headers, each with it's own ground. It could have been wired with a single ground wire, but it's neater and easier to swap things around using a 2 pin cable for each button.
That mounted nicely on the side of the case. The power switch and power LED are left wired to the Picade controller as before. With that connected and RetroPie reconfigured, it seemed to work a lot better with two buttons on the controller dedicated to start and select (the two on the front) and the 6 action buttons as X Y A B, left shoulder and right shoulder..
The two buttons on the sides of the case were setup originally as Enter and Escape. This seemed sensible, so I left those plugged into the Picade X HAT controller.
I had thought I might need to add more buttons, so I also designed an extension board, which has 64 inputs to act as 64 keys on a USB keyboard. As before, these are all individual inputs switch to a common ground.
That would allow individual arcade buttons to press any key you want, such as keys for coin up, player selection, F1 or F12 for menus, any of the letter or number keys etc. You could wire up a joystick to WASD, or to 5678 for Spectrum fans or anything else you can think of.
These are plug in and go, just wire a switch between any of the ground pins and "A" and when you press the switch it will be like you pressed "A" on a normal USB keyboard. I can see this would also be useful for creating those massive controllers people have for flight simulators etc. or adding buttons for menus, changing games, coin up etc.
These boards are available from my Tindie Store, with or without the keyboard extension.
In the usual DIY kit form with the built, programmed and tested controller board, mounting pillars and a USB lead.