| META TOPICPARENT |
name="ExWiiLabCOM" |
WiiLab Example Code - WiiLab: Wiimote Feedback
Rumble
The Wiimote's Rumble is controlled from the SetRumble method of WiiLAB. The method takes one parameter, a boolean value, that determines if the Rumble should be turned on or off.
/// <summary>
/// Calls WiimoteLib's SetRumble(bool on)
/// </summary>
/// <param name="on">if true :: turns on rumble</param>
public void SetRumble(bool on)
{
wm.SetRumble(on);
}
LEDs
The SetLEDs method of WiiLAB has two overloads. The first takes four boolean parameters and the second is by a single integer parameter. The boolean parameters correspond to each LED on the Wiimote from left to right if you are looking directly at the Wiimote. If the value is true the LED will turn on and it will turn off if the value is false. The integer version of SetLEDs is a little more complicated. The LEDs are controlled by the last four (least significant) bits of the integer. If the bit is a 1 the LED will turn on and if the bit is a 0 the LED will turn off. The least significant bit controls the leftmost LED, then next bit controls the LED to the right of the leftmost one and so on. If you are not familiar with the bitwise representation of integers we recommend you use the boolean version.
/// <summary>
/// Calls WiimoteLib's SetLEDs(bool led1, bool led2, bool led3, bool led4)
/// I could not get overloaded functions to work in Matlab so i changed the name slightly
/// </summary>
/// <param name="led1">if true :: turns on LED 1</param>
/// <param name="led2">if true :: turns on LED 2</param>
/// <param name="led3">if true :: turns on LED 3</param>
/// <param name="led4">if true :: turns on LED 4</param>
public void SetLEDsBool(bool led1, bool led2, bool led3, bool led4)
{
wm.SetLEDs(led1, led2, led3, led4);
}
/// <summary>
/// Calls WiimoteLib's SetLEDs(int leds)
/// For specific wiimote int mappings of the LED refer to WiiBrew wiki
/// It is reccomended to use SetLEDsBool
/// </summary>
/// <param name="leds">int instructing wiimote to set indicated LEDs based on the binary representation</param>
public void SetLEDsInt(int leds)
{
wm.SetLEDs(leds);
}
-- JordanBrindza - 22 Jul 2008 |