I've long thought this would be a fun costume to build and, even though I only had 24 hours to make it happen, I was confident I could get something working even if it wasn't playable. In the end, it went surprisingly smoothly and I was able to get the buttons working minutes before the party. I even had time to cut arm holes (buttons were the priority though)!
Step 1: Software Setup; Constructing the Body
I was confident I could build the body of the costume. It's a box with a picture on the front! So, my first step was to check that I could get a Gameboy emulator running on an old laptop and get the ROM loaded.
I installed Ubuntu on the laptop, downloaded the Gameboy Emulator, gngb, and booted up the ROM. It worked great first time (phew, was worried it'd take hours!). Gameboy emulation seems to be spot on.
Then I found a photo of the front of a Gameboy and used PosteRazor to print it on multiple sheets for gluing up. I usually like to paint and sculpt my costumes but I didn't have time for that this time; printing the front saved several hours of work.
Then it was just a matter of gluing it up and pasting it on the front of a suitable box. Couple of hours into the build and it's already a (basic) costume; now the pressure was off!
Step 2: Mounting the Laptop
The laptop I had couldn't quite fold out flat so I unscrewed the hinges. On this particular Dell, all the hinge screws were on the outside and the cables were long enough to manoeuvre the hinges out and flat. This felt like the riskiest part of the built and I might have lost Wifi but thankfully the screen stayed on all night.
With the laptop laid out flat, I carefully placed it into the costume and then built up gaffer tape and duct tape to hold it firmly in place. Gaffer tape and duct tape are similar but gaffer tape is designed to be removed cleanly. I used the gaff directly on the laptop so I could reclaim it later and then built up duct tape for strength.
Since the laptop was fairly heavy, I also glued a cardboard ledge into the costume to hold the weight. I used E6000 contact adhesive to attach that since it quickly cures to be stronger than the cardboard itself.
Step 3: Making the Buttons Work
At this point, I had the laptop mounted, Tetris loaded and it'd run through its demo loop every minute or two. But I wanted buttons! Sorry for the lack of pictures, I was down to about 2 hours to go at this point...
Time to put my Arduino to work. The path from button to gameboy looks like this:
- Button is pushed, closing the circuit from ground to one of the digital input pins (I used the internal pull-ups so the pins normally read HIGH until the button is pushed).
- Arduino reads inputs every few msec, detects button push.
- Arduino debounces the button push.
- Arduino sends signal over its built-in serial port emulator for each button push. (What you see in the Arduino serial monitor.)
- Python app reads the serial port, maps the raw data to the correct key to be pushed.
- Python app uses "xte" to emulate a keypress, feeding it to the current application. Note: this is Linux-specific, the code would need to be totally different for Windows.
- Gameboy emulator sees the keypress and voila(ish)!
Can't recommend Arduino enough for this sort of thing. I had an LED blinking in 1 min, then serial communication up in 5 mins. Luckily I had some Python code lying around for reading the serial port so the main problem I had to solve was getting the input into the emulator.
For that I used xte, which is an app that can feed input events directly to the window server. I was worried at first because the emulator didn't seem to pick up the presses; adding a delay between the down and up events helped but it was still a bit unresponsive.
I think the problem was that I only had the Arduino emit key down events, which meant that the Python app had to simulate down/up event pairs. Then the emulator must've been doing its own debouncing. Would have been better to map key down and up directly to the same events via xte and let the emulator handle it.
I shared the code on Github.
Step 4: Finishing Touches
- Added the emulator as a startup application so it'd boot directly into it if I had to restart the laptop.
- Charged the battery.
- Added a wireless mini keyboard that I had for controlling my HTPC. That let me quit the emulator and tinker without dismantling anything.
- Cut arm holes!
Thanks for reading!