How To Build A USB SNES Controller For The PC, iPad, And PS3 - Part 2: Theory

20 Nov 2012

Before we can start building the controller, we need to figure out how each platform talks to its hardware. Just because the PC, iPad, and PS3 all use USB doesn't mean that they're immediately going to be able to use the same input methods. Without further adieu, let's begin.

The PC - Gamepad Input

The most straightforward means of using the SNES controller on a PC is to make it into a USB Gamepad. Windows, Mac, and Linux all accept standardized gamepad input. This standard is shared with joysticks as well, and as such gamepads are often referred to as "joypads". The variable nomenclature also comes from the joystick world. While their shape, size, and available buttons often differ, below is an example of your typical joystick and gamepad layouts:

Teensydunio Joystick Example

Teensyduino Gamepad Example

This standard is more than capable of accommodating the SNES controller.

SNES Mapping

So that's all there is to getting an SNES controller to masquerade as a gamepad. For those of you observant enough to notice that JOY3 and JOY4 are missing, hold your questions off for now.

The PC - Keyboard Input

Didn't we just do the PC? Well, yes. However, not every PC game accepts standard gamepad input unfortunately. There's a plethora of PC titles which for whatever reason only accept keyboard input. That answer's not going to fly if you're going to put all this effort into making a USB controller though, so let's see what we can do.

SNES Mapping 2

This looks like a reasonable enough key mapping. Everyone's got their own preferences, but this is typically what I use when playing a (legally obtained) game on an emulator. There's one small catch however: USB Keyboards typically can only send roughly 6 keys at the same time. Thankfully, this isn't a huge issue with the SNES controller. You can press a diagonal direction, two face buttons, and both shoulder buttons without any commands being lost. If you tried pressing start, select, or any additional face buttons, those keys would not be sent. However, you'd have to contort your hand in a remarkably uncomfortable manner to pull this off, and I can't recall any games requiring a six button combo at any point in time. Still, for this reason, gamepad input is preferable to keyboard input if both are available.

The PS3 - Gamepad Input Redux

In my searching on the web, I've recently discovered that apparently the PS3 accepts standard USB gamepad input. If you plug a USB gamepad into your PS3, this is how it should behave:

PS3 Mapping

Look familiar? You guessed it: We can reuse our PC gamepad mapping on the PS3. There's one small cravat however. The PS3 "Home" button is only possible to use if you specifically identify the device as a PS3 gamepad. It's a rather technical process, and would most likely muck up any of the multi-platform things we're trying to do on the PC and iPad side. If you own a PS3, you've probably got a PS3 controller laying around if you need the home button, so the our controller's lack of one shouldn't be too much of an issue.

The 360 - Impossible

I figured I'd shoot this question down before someone asks it in the comments. Microsoft very strictly licenses all its 3rd party products. It's nearly impossible to recreate a 360 controller on your own. The only luck people have had making their own 360 controllers is using a method called "padhacking". It involves embedding an entire 360 controller's circuit board in the controller you're trying to build, so sadly it's mostly suited only for arcade style fight-sticks.

The iPad - iCade Keyboard Input

So now we get to the real meat of the issue: Just how on Earth are you supposed to use a USB SNES controller on the iPad? Well, to answer your first question, you plug it into the iPad Camera Kit USB dongle. There's also a Lightening version of it out now. It's worth noting that this adapter doesn't work on the iPhone out of the box. The phone version of iOS doesn't have the right drivers installed by default unfortunately. It appears that there's a Jailbreak utility which enables support for the iPad Camera Connection Kit on the iPhone. I haven't had time to test it myself yet, but I'll update this post if it indeed works as advertised.

Great, so we can plug the controller into an iPad. That doesn't do us a lick of good unless there's software that knows how to recognize it. The iPad is a fully touch device, it was never designed to have someone press buttons in order to trigger actions. This is the point where we would normally be out of luck, but thankfully ThinkGeek and Ion have lent us a significant hand.

Last year the two teamed up to create the iCade. The iCade is a small arcade cabinet style dock for the iPad, complete with joystick and button controls. This dock was designed to work with a specific Atari game, but Ion published an iOS controller standard that any developer can use in their game. Over the last year, a sizable number of games have been made adhering to this spec. To give our controller the maximum amount of compatibility across applications, we'll be sticking with Ion's spec as well.

Certifying a third party device to use Apple's dock connector standard is an expensive, difficult, and time consuming process. Devices given Apple's approval are also generally tied specifically to the manufacturer's app, and aren't allowed to be open to other developers. In order to get around this, Ion simply didn't use Apple's dock connector. The iCade is nothing more than a fancy Bluetooth keyboard. Much like our example for the PC, the iCade simply sends keyboard commands.

This presents a problem however. As I pointed out above, there's a limit to how many keys you can hold down simultaneously on a keyboard, even a bluetooth one. Unlike the SNES controller, the iCade is also much more likely to encounter a situation in which the user has the ability to hold several buttons down at the same time. In order to solve this, the Ion developers got very clever.

iCade Example

Let me explain their solution with an example. You're at the dinner table, and your friend is pouring water for you. He wants to know how much water to give you, and so you come up with two different methods of letting him know when to stop pouring. The first method you try is to just say "keep going" over and over. "Keep going keep going keep going keep going keep going." He starts pouring when you start talking, and he stops pouring when you stop talking. The alternative is for you to just say "start" when he should start pouring, and "stop" when he should stop pouring. That's the two ways a keyboard can work as well.

In our first example, when you press a button, that letter is continually sent to the computer. It knows when you let go because you no longer are sending it. This requires multiple letter signals to be send over an extended period of time as you hold down multiple buttons.

In the second example, the way the iCade does it, the device sends out a single character briefly when you start pressing the button, and then a different character when you stop pressing it. This method requires a bit more code on both the sending and receiving end, but it keeps the communication channel near empty the entire time. In the example shown above, the "y" key is sent to the iPad when you start pressing the button, and the "t" key is sent when you stop. It could be receiving no data at all from the iCade and still know you're holding a button down, since it's only received a "y" and not it's terminating "t".

It should be noted that Ion is bad at writing documentation, all of the letters the iCade sends are lower case, not upper case like the images suggest. Here is the button mapping for the original iCade:

iCade Mapping

Now all that's left is to find a sensible way of converting this into a gamepad layout. It turns out there are several iCade-protocol supporting gamepads already on the market, so let's see what they used. Here's the first of them, the iControlPad:

iControlPad Mapping

Looks sensible enough. Let's see what Gametel did with their controller:

Gametel Mapping

Err, that's different... Oh hey! iCade came out with their own gamepad! The iCade Mobile! Let's see what it maps to:

iCade Mobile Mapping



For what it's worth, I usually go with the iControlPad mapping. It was first, and most of the emulators available for the iPad expect to see them in that configuration. In the next section of this how-to we'll set up our control to support multiple iOS key mappings anyways, so don't worry about it too much. Speaking of the next section, it looks like we're done here. Stay tuned for the actual hardware and code we'll need to implement the above.

comments powered by Disqus