If you want to play some retro arcade games, you will install the amazing MAME and run your favorite ROM. One of my best-of-all-times is Bomb Jack.
But you have to play it with the keyboard. Bah!
Or an USB game pad. Better, but still — bah!
Nothing compares to real arcade controls. And with a bit of tinkering, you can get a tiny step closer to the real gaming experience.
HID stands for Human Interface Device class. Common devices of this class are keyboards, mice and joysticks. The great thing, that this interface brings in, is, the devices don’t need a specific device driver. If they behave according to the USB HID spec, then they are automatically recognized by all OSs. Every device sends a report, in which it states, which kind of device it is and how it wants to report its data.
The next great part is the fantastic USB driver V-USB that is developed by Objective Development. This driver can be run on most of all Atmel AVR controllers, even on ATtinys. It does not require any other chip, only a couple of standard components. The library is licensed under GPL, a commercial license is available as well.
I ordered my arcade controls at ArcadeShop.de, a german shop for Arcade parts. The joystick is great. Heavy and solid. And makes nice clicks.
The buttons, that I ordered are ok. They are working fine but seem to be a bit too small. They have a diameter of 27 mm. Next time I would take bigger ones.
Nothing special about the rest of the needed parts. A breadboard, an ATmega48 and a couple of resistors, capacitors and diodes. And of course a plastic box as enclosure. Keeps the electrons fresh. BTW, mine is not Tupperware, but super cheap IKEA.
The circuit is almost one of the standard setups, that Obdev recommends. I used 47 Ohm instead of 68 Ohm for R2 and R3 because I had them laying around. The two 1N4148 diodes reduce the supply from 5 V to about 3.6 V. This is a “poor mans” voltage regulator. A better solution would be a low drop 3.3 V voltage regulator. But for prototyping the two diodes will do the job.
First I tried to run it with a 16 MHz crystal. I thought that it should be enough to change the F_CPU setting, but that didn’t work out. The device was not recognized. When I switched to the 12 MHz crystal it worked almost at once.
All controls, the stick and the buttons, are connected to the controller and to ground. Therefor the internal pull-up resistors have to be enabled.
The firmware is based on the examples provided at the V-USB page. Two projects, that I played with are the HIDKeys example and the SNES-Joypad. The first one is used to build a simple keyboard. The second was made to play emulated SNES games with a SNES pad.
The biggest problem was to find a matching USB HID report descriptor. This descriptor is used to tell the PC, what kind of device is attached to the USB port and what kind of data it sends. At the moment I am using the “Game Pad” device class.
This is a work in progress. The plastic box works but is way too wobbly. It was more of a joke. The next version should have a more sturdy enclosure. And the circuit should be more permanent and not that place consuming.
I am planning to have a two player version (Gauntlet!). For that I am still unsure, if I should switch to the USB-HID keyboard class. Or maybe implement two gamepads with one controller. We will see.
Over all, it’s great to play some of the old games again. Even if this is nothing compared to a real cabinet.