SNES - marcosassis/gamepaduino GitHub Wiki
[super nintendo] SNES controller interface
for arduino compatible boards
use
download gamepad
library for arduino, unzip, rename folder to gamepad and move to libraries folder on arduino folder. then open examples SNES_*. now, read this page, have fun, and please feedback me.
soon i'll provide here more information about pinout and plugging, as the same for the protocol. but for now you can just google and read the same sources i found, it's de boa.
then, here's basically "all you have to do"
(but you should read this entire page)
use as a joystick/gamepad USB HID device class
this means that the pro micro
will be recognized by OS (any) as a device of class HID (Human Interface Device Class), of the USB (and HID) specifications
and happily arduino provide us with PluggableUSB interface, that is included in the default arduino environment.
this is used by this nice ArduinoJoystickLibrary. someday i'll interface directly from PluggableUSB, but now this library already provides an adaptor class for ArduinoJoystickLibrary. so as the license is the same, and one can easily download this from arduino built in library manager (this is almost all you have to do), this file is already included in gamepad_joystick_adapter.h
if you don't want to use the usb joystick capabilities of your board (or it doesn't have them, a pity), you still can use this nice SNES controller interface (soon it'll be tested on an arduino pro mini
, example and reports here) for inputting commands to your board (you always can control whatever you want with your original oldschool gamepad). see here for considerations. as gamepad_joystick_adapter
module is optional, if you won't use it, just don't include it.
setup on emulator(general)
just set buttons by pressing it
compatible boards
for SNES_gamepad
class/interface, theoretically, any arduino compatible board should do. we use only arduino encapsulated simple commands and the protocol is not costly (see this for remarks about SNES multiplayer implementation).
↑ this is for this SNES_gamepad
general use class / interface / protocol implementation. you always can read()
then get any gamepad
inputs states (or only changes), and then decide what to do in loop (refer to this link for details). (todo: create [more] and link specific examples about this non OO way to use this library. but it's already easy, just refer to this link.) take a look at *_loop_printer
examples for how to print your (any) controller on loop and begin to familiarize yourself with gamepad
library.
for my ArduinoJoystickLibrary interface see supported boards of this library
available pins
any digital pin will work for this SNES gamepad interface
multiplayer
examples -> gamepad -> SNES_usb_multiplayer
please refer to highly-optimized-snes_multiplayer-class for details on my protocol implementation
multiplayer
functionality depends on LinkedList library. please read
instructions and install this library.
multiplayer
is turn on by default. if you don't want to install LinkedList library and don't compile at all this functionality (let's say you have only 1 controller (for now)), you can opt-out multiplayer by define _GAMEPAD_SINGLEPLAYER
macro before include gamepad
files. more details
all you have to do
to play SNES games with a pro micro
board (or another ATmega32U4
based board, as arduino leonardo
) on your computer
is
- download&install
gamepad
library for arduino USB HID
: if you're willing to use it as a plug and play USB HID joystick/gamepad- download&install ArduinoJoystickLibrary (details)
- open example SNES_usb_*player, plug pins and edit sketch accordingly
multiplayer
: if you have more than 1 controller of any kind (and/or plan to make your own)- download&install LinkedList (details)
- this is turn on by default and LinkedList is included internally, do more nothing, just use
multiplayer
class - if you don't want this module, it's easy to turn it off
- google for information about controller pinout and protocol (soon here)
- available at the moment:
- pins: any DIO
- IDs: 1,2,3,4 †
- choose your favorite way of testing
- if your board serial communication LEDs are blinking as you press buttons, it's probably working
† (this turns on USB/HID IDs as hidReportId=gamepadobj.id+2
. so if you're plugging different boards on same computer with same IDs, they'll conflict.)
tests made
os meus controles de SNES são piratãoparalelos
todo: report tests made with 4 SNES controllers (analogous to tests with N64 controllers, please refer to this link)
todo: decide whether tests with 2 SNES controllers (on 1 pro micro) + 2 N64 controllers (on 1 another pro micro) will be reported here or elsewhere
also refer to history (below)
history
change log and commentaries
highly optimized SNES_multiplayer class
now we're really talking SNES console language, as we read multiple controllers using the same line and signals for clock and latch, and reading each bit of all controllers at the same time (and only then clocking controller line)
SNES controller protocol is not costly for arduino. but with naive implementation of multiplayer (read one after other in a for), on the SNES it caused controllers to be latched N times for each reading cycle (N = number of controllers), since all controllers share the same latch and clock line
[edit: that time with 4 controllers (and my initial midi interface draft), we noticed some delay. i don't have the 4 controllers anymore, now i have only 2 and no delay noticeable]
[edit: and worst, in this naive multiplayer cycle, each controller was reported with its state on a different latch/moment. now all controllers will be latched and clocked/read together (faster), making this a great example of importance of structured interface
multiplayer
(and coherent specializations/derivatives) on this important semantic and functionality point. the intent is to make real playing most similar possible to original consoles, working in conjunct with great open sources (emulators, arduino code and examples, tutorials, rev.eng. reports, etc).]first gametest with 2 controllers on ZSNES was perfect. the reading rate of this example must be way faster than original console. [todo: find sources]
2(https://github.com/marcosassis/gamepaduino/commit/f2bbe5b437b3df76705ce150e26be7890e32e00f)
manete de SNES ok
tests realized with killer instinct on ZSNES (and also Project64, both killers instincts hehe), working great, the same way than with N64 controller: simplest(naïve) implementation
example added, soon on wiki too (N64 is already available!)
1(https://github.com/marcosassis/gamepaduino/commit/b6fd9e484cafaaf3299a4d3ae59b31a9a8d6e0fc)