SNESDev-RPi: A SNES-Adapter for the Raspberry Pi

You already might have heard of the Raspberry Pi. It is a credit-card sized PC from the Raspberry Pi Foundation and is going into mass production and distribution these days. There is a huge demand for “the Pi” and the first orders are limited to one per person. A few weeks ago I got my Pi delivered and started working on what I would describe as “universal console”. In this post I describe my initial thoughts about this project and present an adapter that allows you to use SNES controllers as input devices for the Raspberry Pi.

UPDATE: The ControlBlock is now available and provides an easy and safe way for connecting NES, SNES, and Arcade controllers to the RPi and it also provides a power switch functionality!

Being part of the 80ies generation I belong to the group of people that grew up with a whole bunch of 8- and 16-bit video consoles. Nowadays, you can find emulators for all kinds of these consoles and some time ago I got the idea that it would be nice to have a tiny PC that could just be switched on to play this or that good old game. When I read about the Raspberry I finally decided to start this project.

There are several things that have to be done for this:

  • Decide for a stable working Linux distribution that provides access to the video and sound hardware.
  • Make the emulator(s) work.
  • Build a launch menu that allows for selecting the console and or the video game.
  • Build a hardware controller interface that allows you to connect real video game controllers.
  • Build a case that contains the Raspberry and the connector(s) for the controller(s).

I know that you are now saying “Each of these five points is a project on its own.” and I agree! Let’s have a brief look at each of these points now:

The distribution The decision for a “good” distribution is tricky and I am not sure which of the available ones is best suited. Since the Debian distro will be the official distribution of the Raspberry, I think that this might be the best choice. But, currently, even the Debian distro provides an ALSA module only in alpha stage. This produces horrible audio outputs and leads us to the second point:

The emulators There is already work going on for tht point and ToadKing is doing fantastic work here. He is adapting the RetroArch emulator to the Raspberry currently and provides a public Github repository. There is also a thread about this work in the official forum. This is a central piece of this “universal console” and I really hope that the Raspberry port of RetroArch and of the emulator cores will be further developed.

The launch menu Maybe there already exists a launcher that can be compiled on the Raspberry. If you know such a thing, please tell me! Otherwise, I thought of a rudimentary (Python?) script that could be used for the beginning. Update: In the meantime, the front end “Emulation Station” has started to be developed. A lot of ideas are still being discussed and on the to-do list, but there is already a running version of it. A follow-up article presents the RetroPie setup script that automates the installation of emulators and front end.

The controller interface I think that an authentic retro-gaming device needs authentic input hardware. The Raspberry comes with two USB ports and one possibility would be to use some remakes of, for example, SNES controllers with USB connectors. In order to use original controllers, however, one needs to come up with an interface for these controllers. This is where the second part of this post comes into play: I built an adapter board that allows you to connect two SNES connectors to the GPIO pins of the Raspberry. I got the SNES connectors from two controller extension cables. This wiki article gives some more details about the GPIO pins of the Rasperry. A short C program reads the states of the two controllers and passes all button presses to a virtual keyboard that is implemented with the help of the uinput module. In the following, I explain some more details of this adapter, show some pictures of it, and, at the end, also a video demo.

Let us first talk about the hardware part. The idea of designing a PCB that could be used for connecting SNES controllers to a microcontroller or PC came up when I read about a project, in which an NES controller was connected to an iPad. In previous posts, I wrote about the first prototype, the SNES-adapter PCB, and a case for the adapter. For the connection to the Raspberry I used the following parts:

  • 1x SNES-adapter PCB
  • 2x SNES connectors (obtained from extension cables)
  • 2x Shrouded Pin Header, 2×3 pins
  • 2x Ribbon Crimp Connector, 2×3 pins
  • Ribbon Cable – 6 wire
  • 1x Ribbon Crimp Connector, 2×13 pins
  • Ribbon Cable – 26 wire

The SNES-adapter board really does nothing but to provide a clean wiring for the connectors. You could also connect a SNES connector with the 26-wire ribbon cable directly. Besides the cleaner look, the nice thing of the adapter board is that it provides the possibility to connect two controllers without the need for manually splitting the 5V line. If you are interested in the adapter board, send me a mail, I would be happy to share this! To get the SNES connectors I ordered two SNES extension cables and just used the female connectors of them. The SNES and ribbon crimp connectors are wired as following:

You can also see some resistors in the picture – these are actually for LEDs and a button and are not used here. A more detailed description for the assembly is given here. This is a diagram of the pinout of the adapter board:

The GPIO pinout of the Raspberry and of the corresponding 26-wire ribbon cable are shown here:

The connection between the GPIOs and the adapter board is as following:
  • GND to P6
  • VCC to P2
  • DATA 2 to P15
  • LATCH to P16
  • CLOCK to P18
  • DATA 1 to P22
This is how it should look after the assembly:

Here is another picture with the adapter attached to the Raspberry:

Having finished the hardware part I started with the software implementation. I decided for a C program to have the possibility to keep the CPU load as low as possible. Basically, the program has to do two things: First, it has to read the state of each button. A very good source for information about the NES/SNES controllers is also the documentation of the Uzebox. Second, it has to pass button events to a virtual keyboard. The uinput kernel module can handle the input subsystem from within the user space. I stumbled across a very informative article about the uinput kernel module. It is a two-parts article with part 1 here and part 2 here. The uinput module has to be manually loaded with this command:

To access the GPIO pins from within a C program you need to download and install the Broadcom BCM 2835 library. These commands download and install this library:

I called the program SNESDev and created a Github repository for it. You can find it at https://github.com/petrockblog/SNESDev-RPi. Here is a demo of everything working together for a quick game of a famous kart game:

This leads us to the end of this post. So far, I did not speak about a case yet. Having some experience with other laser-cut cases I already started to design a case for the Raspberry that also contains ports for two SNES connectors. When this is finished I will write about it in another post. UPDATE: You can now find a shell script in my Github repository that automatically installs all needed packages for RetroArch and various emulator cores, as well as SNESDev.

Certainly, I left out some information that you would be interested in. So, if you have any questions, comments, or questions, just send me a mail or write some comments below – I would be happy about any contributions!

Some obligatory legal stuff: The Raspberry Pi is a trademark of the Raspberry Pi foundation.

Check Also

New Revision of the PowerBlock: Increased Flexibility

The PowerBlock is a small support shield for the Raspberry Pi that provides a power …

  • Pingback: Interfacing SNES controllers with your Raspberry Pi - Hack a Day()

  • Fritiof (Sweden)

    Nice work! However, I may have noticed an issue with your code. Since you use the same clock for both controllers BUT the code isn’t aware of that you can lost some events, specially if you are using NES mouses that send their relative position since last poll. The controllers will count any poll signal, so even if you’re only looking on B the A controller will reset as well.

    Keep up the good work!

    • Thanks a lot!

      Yes, I agree. This could be implemented in a more cleaner and, at the same time, more efficient way! I will take care for this within the next days.

      • Ryan Davis

        Screw the technical stuff…he needs to learn how to Power Slide!

        Hold the button on the top of the controller, the right button if turning left and the left button if turning right, to execute a controlled slide. It takes some practice, but it’s the most important move to master in Mario Kart!

      • You are right – the power slide needs to be trained 😉

      • Hi everyone, just to let you know I have created a automated script for the installation process, also a python console application (works, but need further dev) to help you find and run your roms. Check it out at
        http://www.frost-software.com/blog/2012/7/20/super-nintendo-for-the-raspberry-pi.htmlhttp://www.frost-software.com/blog/2012/7/20/super-nintendo-for-the-raspberry-pi.html

      • Thank you!

        I am also using a similar self-written script for automatically setting up everything automatically for a freshly installed distro. If I feel that it is mature enough I will put it into my Git repository.

        UPDATE: You can find the Github repository with the “auto-installer” script at https://github.com/retropie/RetroPie-Setup. See also my (short) post about this script.

        The app launcher in Python is a great idea! Seems as if we both are following the same approach: I also did already some tests with Python, XML, and PyGame for a front end. Especially PyGame could be used for a simple graphical front end, I think.

      • Smikey

        I’m also working on a launcher-script for the emus… As a bash-script with the dialog-utility. I thinks I’ll be ready within the next few days 🙂

  • So, you are powering the SNES controllers with 5v? If so are the GPIO pins sending the controllers a logic high of 3.3v to Latch and clock, or are you just relying on them to pull the pins low? I’m also guessing that the resistors on that board are for interfacing the data pins to GPIO ins or are those for the LEDs you speak of?

    • Yes – the controllers are powered with 5V. The GPIO pins are sending 3.3V to Latch and Clock. I tested the same circuit in a previous project with an ATMega328 and found that this is working well (at least so far). I added a link above that points to a chapter of the Uzebox documentation about the NES/SNES controllers.
      The resistors are for the optional LEDs and the button and have no function here.
      So far, there is no over-voltage protection here. What would be your advice here?

  • jwk

    This is pretty great – I’d been thinking about using a Raspberry Pi as a game console to replace my getting-flaky SNES. Nice touch using the original controllers instead of an adapter!

    • Thanks a lot! I also think that using original controllers is an important thing here.

  • hi! Today I commited a major code rewrite of my linux program/emulator launcher “typhon”.
    I don’t have a raspberrypi yet, but I’m sure it will work on it. (requires sfml2 master, tinyxml, opengl and/or some optional stuff for p3t ps3 themes or videos).
    To be updated (when 2.0 is ready) homepage with older vids, screenshots and themes:
    http://www.frostworx.de/?p=1
    google code project page with latest code:
    http://code.google.com/p/typhon-launcher/

    • Hi! Thanks for the links – I will test your updated code within the next days and report about it … or maybe someone else is faster than me 😉

      • great to hear you want to try it 🙂
        although the (re-)write of the current state took a lot of time, the commit itself didn’t.
        unfortunately I just found out that you need to build typhon with debug enabled (or better say not optimized cflags), else you only see the commandline help. sry for inconvenience. apart from that it should work just fine i hope…

  • I’ve used WahCade (http://www.anti-particle.com/wahcade.shtml) for mame in linux. It’s a copy of the popular MameWah, and seems to work well with everything. It does have a struct with the different inputs types used in mame, and it’s missing some of the newer values, but it’s all in python or perl, and easily editable.

  • phaedrus5001

    Concerning using a traditional SNES controller, you may want to check this out: http://www.ladyada.net/make/usbgamepad/index.html

  • Pingback: Super Nintendo now comes in Raspberry Pi flavour()

  • Pingback: Developer hacks Raspberry Pi to play Super Nintendo games | SPECTA NEWS()

  • Pingback: Developer hacks Raspberry Pi to play Super Nintendo games | AVORAH - Geek Lifestyle Reviews And Views - TECH, GADGETS, STYLE.()

  • Pingback: Developer hacks Raspberry Pi to play Super Nintendo games | Ceklit()

  • Pingback: Raspberry Pi mod turns the $35 PC into a retro gaming console - Liliputing()

  • Pingback: Current Event News - CurrentEvent.co()

  • Red1

    I realize this wouldn’t be nearly as geeky or cool, but you could always just use a Retrode connected to the RasPi for controllers. I don’t think you necessarily have to be using a game cart in it for the controller part to function as well.

    • Yes, this might also work, thanks for your suggestion! But I like the all-in-one solution more – it needs some hardware work though.

  • Hello, my brother and I are currently making snes ports with the gpio ports, nes power on / off and reset buttons as well as a GUI launcher for any emulator in Qt which is done and working. I am hoping a decent x driver comes out within the months but if not a qtEmbedded version of my GUI will come and so we dont have to run X. Watch the rasp pi blog we will be making a post about it soon. I think they like that stuff.

  • Pingback: Το Raspberry Pi παίζει Super Nintendo [video] – gadgeta.me()

  • Pingback: SNES-Adapter for the Raspberry Pi – #piday #raspberrypi @Raspberry_Pi « adafruit industries blog()

  • Pingback: Developer hacks Raspberry Pi to play Super Nintendo games()

  • pikachu

    Cool! Would it work for a Sega Genesis gamepad?
    BTW, Buffalo already has USB versions of NES and SNES gamepads (search for buffalo classic gamepad in amazon.co.jp).

    • The software would have to be adapted to the protocol of the Sega Genesis controller. I do not plan to do this, but you could add this functionality to SNESDev 🙂

  • Pingback: [MOD] Joypad del SNES su Raspeberry PI - Netbook News()

  • Pingback: [MOD] Joypad del SNES su Raspberry PI - Netbook News()

  • Pingback: Developer hacks Raspberry Pi to play Super Nintendo games | The Personal Computer Games Site()

  • Smikey

    Great work!
    But I have one question. You wrote you use RetroArch. Do you use the Pocketsnes-libretro Port or the snes9x-Port? MarioKart works well on my Rpi, but Kirby’s Dreamland 3 runs slowly as hell 😉
    So I’m working on the exactly same thing, an ultimate retro-console-thing 🙂

    • Kirby’s Dreamland 3 goes into pseudo-hi res mode at specific levels (Level 1-2 for instance) – that on-top of an additional 10Mhz co-processor to emulate (Kirby’s Dreamland 3 using the SA-1 co-processor). This is processor-intensive.

    • There is already an answer as the reason for the slowness here. just as addition to that: I am using the Pocketsnes-libretro port right now.

  • ole

    Amazing work! Looking forward to seeing this project take form! =)

  • Pingback: Raspberry Pi Modded To Play Super Nintendo Games()

  • Pingback: Raspberry Pi Modded To Play Super Nintendo Games | Fix-Singh - Computer Repair Leicester()

  • Pingback: Disfruta de los mejores juegos de SNES en tu Raspberry Pi | conecti.ca()

  • Pingback: Raspberry Pi Modded To Play Super Nintendo Games | Christ School International()

  • Pingback: Raspberry Pi Modded To Play Super Nintendo Games | Free Best Trends()

  • Pingback: Developer hacks Raspberry Pi to play Super Nintendo games | WorldFlashNews.com()

  • Daniel

    Hi. Congratulations for the nice work. You could also try testing MESS. MESS is a sister-MAME project which attempts to emulate several old computers, consoles and videogames that ever existed. It shares a lot of code with MAME, which it is gets its basis from, it is command line driven, good for integrating into frontends and works in Linux. http://www.mess.org/

  • Reblogged this on zacharias and commented:
    Major geekness everyone simply MUST love!

  • Very cool, is the emulator running on KMS/framebuffer directly, or is it using X or Wayland?

    Really nice work, congrats.

    • Actually, I am not that deep within the RetroArch architecture. Without looking at the source code I would have a guess, but I do not want to say something wrong here. I assume that ToadKing could tell you a lot more about this.

  • Pingback: Developer hacks Raspberry Pi to play Super Nintendo games | The Computer Games Site()

  • Pingback: La Raspberry Pi comme console de jeu à 35$ ?  blogeee.net()

  • Pingback: A Slice of Raspberry Pi Hardware | Technology Blog()

  • Matt

    Is this something you plan on building and selling once it’s complete? I’m a classic games collector and player, and I agree there’s nothing quite like playing with a real controller on a television in a living room. Problem is, I have so many consoles and games that having them all hooked up at once is a huge mess of cables and a real fire hazard.

    I’ve bought a handheld device called a Dingoo which can output to a TV, but the emulation isn’t always perfect, and you can’t use real controllers. Having a single console, not having to dig through my bins of games, and only swapping out controllers is something I would be willing to pay real money for, and I doubt I’m alone.

    Do you have a website or something where I can follow your progress and make a purchase in the future?

    • Thanks a lot for this encouragement! There is still a lot to do before something like “a product” would be reached here. However, I plan to continue the work on this and any progress will be posted in this blog. So, I recommend to subscribe to the RSS feed 😉

  • Pingback: Daily Retrospektive – 10/07/2012()

  • Pingback: Raspberry Pi : un adaptateur pour manettes SNES ?!()

  • Pingback: ROMSCENTRO - Convirtiendo la Raspberry Pi en una SNES()

  • Pingback: $35 Dollar Raspberry Pi Computer Hacked To Play SNES Games()

  • Jennifer

    I’m trying to buy a new game for my hubby… what game would you suggest? He likes action games.

  • Miles

    This is amazing, I am looking at modifying it for a Raspberry Pi installed in a Gameboy, I need the GPIO pins tied to individual buttons, there are only 8 buttons. I thought of using a NES controller IC I have here, but I would prefer to just wire the buttons to the GPIO pins.

    I assume that if I edit the code I can get it to accept 1 pin as one input instead of reading a serial chip.

    Looking forward to any plans to emulate a standard USB gamepad for compatibility with a wide range of programs.

    • Hi Miles,

      thank you! I like the idea with the Gameboy – do you plan to use the Gameboy as a case only or do you even plan to attach an LCD display to the RPi? Take care for the voltages – it just happened that the SNES controllers can be polled with the voltages provided by the RPi.

      I will continue the work on the SNESDev-RPi code in the next days and include a gamepad functionality.

      Hope to hear more from your Gameboy project!

  • Would this work for NES controllers too? If not what modifications would need to be done? I am currently planning on making a case for my Raspberry Pi from an NES, so I would like to be able to use NES controllers with it using the original connectors.

    Shawn

    • Hi Shawn,

      this would also work for NES controllers. From what I read so far, the code from my Github repository should work out of the box. The BES and SNES controllers have (nearly) the same polling protocol.

  • Folkert

    Wow, that’s a nice project! You might consider using an old SNES as a casing, since it already has the two controller ports and it looks awesome.
    I was wondering if the emulator you use is run on top of an X-server? Or are you using a hardware accelerated framebuffer?

    • Cool idea with the SNES case!

      The emulator is running directly from the console without X. I am not sure if any kind of hardware acceleration is used right now – ToadKing could probably tell you more about this.

  • Pingback: Connecting SNES sockets to the Raspberry Pi: An assembly guide | petRockBlog()

  • For some reason my Controller 1 buttons are throwing out numbers from 1-8 except for the D-pad which is correct

    • Are you using the SNESDev code from my Github repository (https://github.com/petrockblog/SNESDev-RPi)?

      • Yes I’am. For example I press start on the pad it throws out number 8 which is the 8th command on the button list form the code. Everything works fine for second controller data.

      • Did you manage to solve the problem? One solution for this would be to adapt the key map from RetroArch. When I wrote the SNESDev I had the buttons from the first controller mapped to the number keys 1 to 8, but the current version in Github has the same mapping as RetroArch expects it to be for the first controller …

  • Pingback: RetroPie-Setup: An initialization script for RetroArch on the Raspberry Pi | petRockBlog()

  • This might sound like a daft question but i’m assuming I just run SNESDev as a background process? I’m fully confident RetroArch is fine and is getting the correct config file.

    • Yes, you are right with the background process!

      I updated the README.md in the repository and added information about installation and running SNESDev.

  • Awesome work! Thanks for the script! I’m going to try it out later. I have a question though, I’m putting my Pi into an NES and using Raspbmc for my media duties, as well as rom management for emulators. Will retroarch work with XBMC? Also, I’m looking at the work you did for the controllers, what would I need to do to replicate that using the NES controller ports?

    • I am afraid I have no experience with the combination of XBMC and RetroArch.
      For the hardware part of the NES connectors you might want to have a look at http://uzebox.org/files/NES-controller-Hydra-Ch6All-v1.0.pdf. There you will see that the SNES and NES connectors vary only in their shape and not in their pin out. Also the polling protocol is very similar. I have not tried it yet, but SNESDev might already poll NES controllers without many modifications.

%d bloggers like this:
Skip to toolbar