Who doesn’t love a good old fashioned arcade game? Seriously, there’s something about those 80’s titles that just draws you in. Imagine our delight, then, when we got MAME going on our Raspberry Pi. But, for the full-fat retro gaming experience, we really, really wanted to hook up a joystick.
Now back in the day, we had ourselves a state of the art Competition Pro 5000 – joystick heaven – which we foolishly sold along with our Amiga stuff. So after ransacking eBay we eventually picked one up in its original box:
The first step was to hook this beauty up to the RPi general purpose input output (GPIO).
We used a breadboard with our homebrew Pi Cobbler at one end and a similar connector at the other wired up to an old PC serial card cable that had the right (male) DB9 connector for the joystick plug (female).
Then it was just a matter of adding some pull up resistors (10K) and some patch cables:
We hate to admit it, but at this point we realised we’d entered a blind alley.
Having already seen gpio-keys we reckoned we’d be using that, but when it came to the crunch we just didn’t have a clue where to start. We probably needed a package of RPi kernel source. Anyway, we told ourselves we probably really wanted gpio-mouse anyway.
After some digging around the Raspberry Pi Forums we stumbled upon a comment about using Python to generate keystrokes. This was the pointer we needed, and we headed in the direction of Python uinput (a module that can create keypresses)…
sudo modprobe uinput
git clone https://github.com/tuomasjjrasanen/python-uinput
sudo python setup.py install –prefix=/usr/local
Sensing victory, we knocked together some code that turns GPIO into keypresses. But sadly it seems that AdvMAME derives its input in a way that completely ignores uinput for keyboard. Doh! Back to the drawing board…
But not to be put off our gaming nirvana, we kept digging around the examples for Python-uinput until we found one for…YES! joystick
With a racing pulse, we attempted the task of creating a GPIO connected variant, and with that saved as rpi-gpio-jstk.py it was a simple case of running:
sudo python rpi-gpio-jstk.py &
We tested it using advj, and it showed input. And when we fired up AdvMAME the joystick worked – HALLELUJA!
We’re now the proud owners of a fully working vintage joystick for our classic games. Truth be told, we’re not entirely happy with the Python based approach (particularly as it uses polling) but we’ve seen nastier hacks. We’d love to get a proper kernel module working, especially if it can use interrupts rather polling. And we should probably also check out internal pullups so we can simplify the wiring for when we make a more permanent (dual?) joystick adaptor.
But these are carping criticisms. We have a joystick. And we’re not afraid to use it. Let the action commence…
Notre site Web utilise des cookies et des technologies similaires pour vous fournir un meilleur service lorsque vous effectuez une recherche et passez une commande, à des fins d'analyse ou pour personnaliser nos publicités. Vous pouvez modifier vos paramètres de cookies en lisant notre politique en matière de cookie. Faute de quoi, nous considérerons que vous acceptez notre utilisation des cookies.
Please select an option to see content specific to your location and shop online.