Close

Ongoing BeagleSNES Development

A project log for Beagle Entertainment System

Turning the BeagleBone Black into a retro gaming appliance

Andrew HendersonAndrew Henderson 02/17/2015 at 16:030 Comments

Native Gamepad Support:

One of the items that has been on my to-do list for a while now is native support for the original SNES gamepads. Routing events through the USB subsystem is convenient, but the original SNES gamepads are often cheaper than their USB equivalents and input latency goes down to practically nothing if you're talking directly to the original hardware. This is why a BeagleSNES cape board has been in my plans for a while. While I have been quite busy as of late, I did spend a little time with the scope and coded up some tests for SNES gamepad interfacing via GPIOs:

My plans are to push this logic into the PRU and have it repeatedly poll the gamepads as the SNES hardware originally did. The bitmask for the depressed buttons can be pushed to a shared memory location where I can mmap() it from userspace and read it as I would read any control register. This frees me from trying to get the timing on the protocol correct in userspace. You don't get the concurrency guarantee this way, but I can treat the memory location as volatile and re-read it until I get a set of duplicate readings. Not elegant, but it works will practically no overhead.

Currently, the USB gamepad support in BeagleSNES is pretty heavy-weight. This is because I check for not only the presence of USB gamepads, but I also check to see that they are plugged into particular USB ports. This allows me to have player 2 plugged in while player 1 is still unplugged, for example. But, this also requires a stat() or two to make sure that the /dev/input/js? is linked to the proper location on the USB bus. I found that the GPIO support for player 1 that I added in v0.6 was pretty snappy (less latency) when compared to the USB gamepad input, so it is my hope that pushing native gamepad support via GPIOs into the PRU will be even more responsive.

Discussions