C# Class WiimoteLib.Wiimote

Implementation of Wiimote
Inheritance: IDisposable
Datei anzeigen Open project: simphax/WiimoteLib Class Usage Examples

Public Methods

Method Description
Connect ( ) : void

Connect to the first-found Wiimote

Disconnect ( ) : void

Disconnect from the controller and stop reading data from it

Dispose ( ) : void

Dispose Wiimote

GetStatus ( ) : void

Retrieve the current status of the Wiimote and extensions. Replaces GetBatteryLevel() since it was poorly named.

ReadData ( int address, short size ) : byte[]

Read data or register from Wiimote

SetLEDs ( bool led1, bool led2, bool led3, bool led4 ) : void

Set the LEDs on the Wiimote

SetLEDs ( int leds ) : void

Set the LEDs on the Wiimote

SetReportType ( InputReport type, IRSensitivity irSensitivity, bool continuous ) : void

Set Wiimote reporting mode

SetReportType ( InputReport type, bool continuous ) : void

Set Wiimote reporting mode (if using an IR report type, IR sensitivity is set to WiiLevel3)

SetRumble ( bool on ) : void

Toggle rumble

Wiimote ( ) : System

Default constructor

WriteData ( int address, byte data ) : void

Write a single byte to the Wiimote

WriteData ( int address, byte size, byte buff ) : void

Write a byte array to a specified address

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Dispose wiimote

Private Methods

Method Description
BeginAsyncRead ( ) : void

Start reading asynchronously from the controller

ClearReport ( ) : void

Initialize the report data buffer

DecryptBuffer ( byte buff ) : byte[]

Decrypts data sent from the extension to the Wiimote

DisableIR ( ) : void

Disable the IR sensor

EnableIR ( IRMode mode, IRSensitivity irSensitivity ) : void

Turn on the IR sensor

FindWiimote ( WiimoteFoundDelegate wiimoteFound ) : void
GetBalanceBoardSensorValue ( short sensor, short min, short mid, short max ) : float
GetRumbleBit ( ) : byte

Returns whether rumble is currently enabled.

InitializeExtension ( ) : void

Handles setting up an extension when plugged in

OnReadData ( IAsyncResult ar ) : void

Callback when data is ready to be processed

OpenWiimoteDeviceHandle ( string devicePath ) : void
ParseAccel ( byte buff ) : void

Parse accelerometer data

ParseButtons ( byte buff ) : void

Parses a standard button report into the ButtonState struct

ParseExtension ( byte buff, int offset ) : void

Parse data from an extension controller

ParseIR ( byte buff ) : void

Parse IR data from report

ParseInputReport ( byte buff ) : bool

Parse a report sent by the Wiimote

ParseReadData ( byte buff ) : void

Parse data returned from a read report

ReadWiimoteCalibration ( ) : void

Read calibration information stored on Wiimote

Wiimote ( string devicePath ) : System
WiimoteFound ( string devicePath ) : bool
WriteReport ( ) : void

Write a report to the Wiimote

Method Details

Connect() public method

Connect to the first-found Wiimote
Wiimote not found in HID device list
public Connect ( ) : void
return void

Disconnect() public method

Disconnect from the controller and stop reading data from it
public Disconnect ( ) : void
return void

Dispose() public method

Dispose Wiimote
public Dispose ( ) : void
return void

Dispose() protected method

Dispose wiimote
protected Dispose ( bool disposing ) : void
disposing bool Disposing?
return void

GetStatus() public method

Retrieve the current status of the Wiimote and extensions. Replaces GetBatteryLevel() since it was poorly named.
public GetStatus ( ) : void
return void

ReadData() public method

Read data or register from Wiimote
public ReadData ( int address, short size ) : byte[]
address int Address to read
size short Length to read
return byte[]

SetLEDs() public method

Set the LEDs on the Wiimote
public SetLEDs ( bool led1, bool led2, bool led3, bool led4 ) : void
led1 bool LED 1
led2 bool LED 2
led3 bool LED 3
led4 bool LED 4
return void

SetLEDs() public method

Set the LEDs on the Wiimote
public SetLEDs ( int leds ) : void
leds int The value to be lit up in base2 on the Wiimote
return void

SetReportType() public method

Set Wiimote reporting mode
public SetReportType ( InputReport type, IRSensitivity irSensitivity, bool continuous ) : void
type InputReport Report type
irSensitivity IRSensitivity IR sensitivity
continuous bool Continuous data
return void

SetReportType() public method

Set Wiimote reporting mode (if using an IR report type, IR sensitivity is set to WiiLevel3)
public SetReportType ( InputReport type, bool continuous ) : void
type InputReport Report type
continuous bool Continuous data
return void

SetRumble() public method

Toggle rumble
public SetRumble ( bool on ) : void
on bool On or off
return void

Wiimote() public method

Default constructor
public Wiimote ( ) : System
return System

WriteData() public method

Write a single byte to the Wiimote
public WriteData ( int address, byte data ) : void
address int Address to write
data byte Byte to write
return void

WriteData() public method

Write a byte array to a specified address
public WriteData ( int address, byte size, byte buff ) : void
address int Address to write
size byte Length of buffer
buff byte Data buffer
return void