A simple class for reading button presses from a Super Nintendo (SNES) controller. Requires access to the controller's latch, clock, and data pins.

ABOUT

A simple class for reading a Super Nintendo (SNES) controller's buttons.

HARDWARE

The library was developed using the Nordic mKIT and cheap controllers.

NOTE: This controller has a wide VCC tolerance and continues to operate even when the mKIT is running off of a coin cell battery.

            +-----------+           
            |           |           
            |    +-+    |           
            |    +-+--------+VCC    
            |           |           
            |    +-+    |           
            |    +-+--------+CLOCK  
            |           |           
            |    +-+    |           
            |    +-+--------+LATCH  
            |           |           
            |    +-+    |           
            |    +-+--------+DATA   
            |           |           
            +-----------+           
            |           |           
            |    +-+    |           
            |    +-+--------+N/C    
            |           |           
            |    +-+    |           
            |    +-+--------+N/C    
            |           |           
            |    +-+    |           
            X    +-+----+---+GND    
             X         X            
              ---------             
                                    
          Controller pinout         
(looking into the female connector) 

USAGE

After wiring up a controller:

Include the library

#include "SNESController.h"

Create a new object and specify the pins

SNESController snes(P0_20, P0_21, P0_22);

Read and decode the button presses

uint16_t state = snes.read();
if (snes.pressed(state, SNESController::SNES_BUTTON_RIGHT_ARROW)) {
    ...
}

Poll the controller periodically

Ticker ticker;
ticker.attach(periodicCallback, 0.05);