Skip to main content

Meadow.Foundation.Sensors.Hid.SnesClassicController

SnesClassicController
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Sensors.Hid.WiiExtensionControllers

Code Example

SnesClassicController snesController;

public override Task Initialize()
{
Resolver.Log.Info("Initialize...");

var i2cBus = Device.CreateI2cBus(SnesClassicController.DefaultI2cSpeed);

snesController = new SnesClassicController(i2cBus: i2cBus);

//onetime update - could be used in a game loop
snesController.Update();

//check the state of a button
Resolver.Log.Info("X Button is " + (snesController.XButton.State == true ? "pressed" : "not pressed"));

//.NET events
snesController.AButton.Clicked += (s, e) => Resolver.Log.Info("A button clicked");
snesController.BButton.Clicked += (s, e) => Resolver.Log.Info("B button clicked");
snesController.XButton.Clicked += (s, e) => Resolver.Log.Info("X button clicked");
snesController.YButton.Clicked += (s, e) => Resolver.Log.Info("Y button clicked");

snesController.LButton.Clicked += (s, e) => Resolver.Log.Info("L button clicked");
snesController.RButton.Clicked += (s, e) => Resolver.Log.Info("R button clicked");

snesController.StartButton.Clicked += (s, e) => Resolver.Log.Info("+ button clicked");
snesController.SelectButton.Clicked += (s, e) => Resolver.Log.Info("- button clicked");

snesController.DPad.Updated += (s, e) => Resolver.Log.Info($"DPad {e.New}");

return Task.CompletedTask;
}

public override Task Run()
{
snesController.StartUpdating(TimeSpan.FromMilliseconds(200));
return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a SnesClassicController to your Meadow board, connect the following:

SnesClassicControllerMeadow Pin
GNDGND
SCLD08 (SCL)
SDAD07 (SDA)
VCC3V3

Class SnesClassicController

Represents a Nintendo SNES Classic Mini controller

Assembly: WiiExtensionControllers.dll
View Source
Declaration
public class SnesClassicController : WiiClassicControllerBase, II2cPeripheral

Inheritance: System.Object -> Meadow.Foundation.Sensors.Hid.WiiExtensionControllerBase

Implements:
Meadow.Hardware.II2cPeripheral

Properties

DPad

D-pad

View Source
Declaration
public IDigitalJoystick DPad { get; }

XButton

X Button

View Source
Declaration
public IButton XButton { get; }

YButton

Y Button

View Source
Declaration
public IButton YButton { get; }

AButton

A Button

View Source
Declaration
public IButton AButton { get; }

BButton

B Button

View Source
Declaration
public IButton BButton { get; }

LButton

L Button

View Source
Declaration
public IButton LButton { get; }

RButton

R Button

View Source
Declaration
public IButton RButton { get; }

StartButton

  • Button
View Source
Declaration
public IButton StartButton { get; }

SelectButton

  • Button
View Source
Declaration
public IButton SelectButton { get; }

Methods

Update()

Get the latest sensor data from the device

View Source
Declaration
public override void Update()

Implements

  • Meadow.Hardware.II2cPeripheral