Remarks
WiiClassicController | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
WiiClassicController classicController;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2cBus = Device.CreateI2cBus(WiiClassicController.DefaultSpeed);
classicController = new WiiClassicController(i2cBus: i2cBus,
useHighResolutionMode: true);
//onetime update - could be used in a game loop
classicController.Update();
//check the state of a button
Resolver.Log.Info("X Button is " + (classicController.XButton.State == true ? "pressed" : "not pressed"));
//.NET events
classicController.AButton.Clicked += (s, e) => Resolver.Log.Info("A button clicked");
classicController.BButton.Clicked += (s, e) => Resolver.Log.Info("B button clicked");
classicController.XButton.Clicked += (s, e) => Resolver.Log.Info("X button clicked");
classicController.YButton.Clicked += (s, e) => Resolver.Log.Info("Y button clicked");
classicController.LButton.Clicked += (s, e) => Resolver.Log.Info("L button clicked");
classicController.RButton.Clicked += (s, e) => Resolver.Log.Info("R button clicked");
classicController.ZLButton.Clicked += (s, e) => Resolver.Log.Info("ZL button clicked");
classicController.ZRButton.Clicked += (s, e) => Resolver.Log.Info("ZR button clicked");
classicController.PlusButton.Clicked += (s, e) => Resolver.Log.Info("+ button clicked");
classicController.MinusButton.Clicked += (s, e) => Resolver.Log.Info("- button clicked");
classicController.HomeButton.Clicked += (s, e) => Resolver.Log.Info("Home button clicked");
classicController.DPad.Updated += (s, e) => Resolver.Log.Info($"DPad {e.New}");
classicController.LeftTrigger.Updated += (s, e) => Resolver.Log.Info($"Left Trigger {e.New}");
classicController.RightTrigger.Updated += (s, e) => Resolver.Log.Info($"Left Trigger {e.New}");
classicController.LeftAnalogStick.Updated += (s, e) => Resolver.Log.Info($"Left Analog Stick {e.New.Horizontal}, {e.New.Vertical}");
classicController.RightAnalogStick.Updated += (s, e) => Resolver.Log.Info($"Right Analog Stick {e.New.Horizontal}, {e.New.Vertical}");
return Task.CompletedTask;
}
public override Task Run()
{
classicController.StartUpdating(TimeSpan.FromMilliseconds(200));
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
To wire a WiiClassicController to your Meadow board, connect the following:
WiiClassicController | Meadow Pin |
---|---|
GND | GND |
SCL | D08 (SCL) |
SDA | D07 (SDA) |
VCC | 3V3 |
Syntax
public class WiiClassicController : WiiClassicControllerBase
Constructors
WiiClassicController(II2cBus, Boolean)
Creates a Wii Classic Controller object
Declaration
public WiiClassicController(II2cBus i2cBus, bool useHighResolutionMode = false)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | the I2C bus connected to controller |
System.Boolean | useHighResolutionMode | Enable high resolution mode analog sticks and triggers (8 bits of precision) |
Properties
AButton
A Button
Declaration
public IButton AButton { get; }
Property Value
Type | Description |
---|---|
IButton |
BButton
B Button
Declaration
public IButton BButton { get; }
Property Value
Type | Description |
---|---|
IButton |
DPad
D-pad
Declaration
public IDigitalJoystick DPad { get; }
Property Value
Type | Description |
---|---|
IDigitalJoystick |
HomeButton
Home Button
Declaration
public IButton HomeButton { get; }
Property Value
Type | Description |
---|---|
IButton |
LButton
L Button
Declaration
public IButton LButton { get; }
Property Value
Type | Description |
---|---|
IButton |
LeftAnalogStick
Left analog jostick (6 or 8 bits of precision)
Declaration
public IAnalogJoystick LeftAnalogStick { get; }
Property Value
Type | Description |
---|---|
IAnalogJoystick |
LeftTrigger
Left analog trigger (5 or 8 bits of precision)
Declaration
public IAnalogTrigger LeftTrigger { get; }
Property Value
Type | Description |
---|---|
IAnalogTrigger |
MinusButton
- Button
Declaration
public IButton MinusButton { get; }
Property Value
Type | Description |
---|---|
IButton |
PlusButton
- Button
Declaration
public IButton PlusButton { get; }
Property Value
Type | Description |
---|---|
IButton |
RButton
R Button
Declaration
public IButton RButton { get; }
Property Value
Type | Description |
---|---|
IButton |
RightAnalogStick
Right analog jostick (5 or 8 bits of precision)
Declaration
public IAnalogJoystick RightAnalogStick { get; }
Property Value
Type | Description |
---|---|
IAnalogJoystick |
RightTrigger
Right analog trigger (5 or 8 bits of precision)
Declaration
public IAnalogTrigger RightTrigger { get; }
Property Value
Type | Description |
---|---|
IAnalogTrigger |
XButton
X Button
Declaration
public IButton XButton { get; }
Property Value
Type | Description |
---|---|
IButton |
YButton
Y Button
Declaration
public IButton YButton { get; }
Property Value
Type | Description |
---|---|
IButton |
ZLButton
ZL Button (at bottom of trigger)
Declaration
public IButton ZLButton { get; }
Property Value
Type | Description |
---|---|
IButton |
ZRButton
ZR Button (at bottom of trigger)
Declaration
public IButton ZRButton { get; }
Property Value
Type | Description |
---|---|
IButton |
Methods
Update()
Get the latest sensor data from the device
Declaration
public override void Update()