Jul. 29, 2013
By C.W. Dalton
I like pi, who doesn’t? Pi, the number that gives us circles. Pie, a delicious dessert that comes in many different flavors. Pi, a pocket sized computer with capacity for hours of entertainment. This last kind of pi, Raspberry Pi, is one of things we were lucky to work with this year in Operating Systems (CIS 460). At first we simply used them to learn basic Linux, but then we were set free to configure and set up something of our own design we were interested in.
I thoroughly enjoy video games. Especially those from the 90’s. How could I turn this little pocket sized motherboard into an old gaming system to fill my free time with Mario, Luigi, Toad, and Yoshi’s? I needed an emulator, a program that mimics the hardware and functionality of a device virtually. I found RetroPie, which would allow me not only to play Nintendo and Super Nintendo games, but other systems like Sega as well. Using instructions from the Github repository, I downloaded the RetroPie setup file and ....

Install Dialogue
At about 3:00 in the afternoon, I used the installer and chose to download and compile the code on my Raspberry Pi. Not thinking, at first I stopped the process when I thought it froze half-way in. Realizing that it was going to take forever to compile, I started the process again and left it all night to compile. Checking it every so often throughout the night before I went to sleep, it was amazingly slow, but by morning it had finished. After completing the setup, I opened up the config file and set the keyboard mappings for controlling the game. Next was to find some games. I downloaded some games that I had physical copies of at home to play: Super Mario World and Mario Kart. After copying the game images into the correct folder for the Super Nintendo system, I typed emulationstation on the commandline and started playing Mario. It worked beautifully.

It Works!
After about 2 hours of fun, I thought that my experience could be improved. I needed some sort of controller. Knowing that a Wii controller connects through bluetooth, I researched to see if anyone had made any drivers that would allow me to map the buttons. I found CWiid and Wminput. CWiid defines a library for connecting and communicating with a wiimote. Wminput is a joystick/mouse driver that allows the wiimote to communicate as a gamepad. This was perfect for me. I plugged in my usb bluetooth adapter and installed the base bluetooth drivers for Raspberry-Pi.
This is where I ran into the most trouble. When I installed CWiid and Wminput and tried to connect, it reported a Bluetooth error, saying the adapter was down. I tried to run hcitool scan and it would return device hci0 down. After troubl shooting for a couple hours, I finally found that I needed to update the Bluetooth on the Pi, even though I had just installed it, this allowed Bluetooth to use my adapter. After this WMinput worked just fine.

wminput controller mapping code
With the wiki as a guide, I created a joystick config file to map the buttons to joystick functions. Using wminput -c gamepad the wiimote connected and was recognized as a controller. Running the RetroPie command retroarch-joyconfig allowed me to auto map the controller buttons. After setting all this up the wiimote work great as a controller.

This is Awesome.
Setting up my Raspberry Pi as a game emulator was entertaining and gave me a lot of experience. It helped teach me to be self-sufficient in programming. Unlike any other programming assignment, it was very open ended. We were dropped in the wild to make it on our own. If we ran into trouble, the responsibility to solve the issue was mostly on us. We couldn't go to our teacher, Dr. Casey, and ask for help in the same way, since he didn't necessarily have the answer. I think it was a very rewarding more realistic experience.