BitLegit

Just a couple of kids tryin' to make it on their own.

WiiBuddy API

Copyright (c) 2016, BitLegit

All rights reserved.

WiiBuddy requires Unity 5.0 or higher.

Delegate Event Functions
OnDiscoveryFailed(int error)
OnWiimoteDiscovered(int remote)
OnWiimoteDisconnected(int remote)

Broadcasted Messages
“OnWiimoteFound(int remote)”
OnWiimoteDropped(int remote)”
“OnDiscoveryError(int error)”

Static Functions
void StartSearch()
void StopSearch()
int GetDiscoveryStatus()
void DropWiiRemote(int i)
int GetRemoteCount()
bool IsActive(int remote)
bool IsSearching()
float GetBattery(int remote)
void SetLEDs(int remote, bool LED1, bool LED2, bool LED3, bool LED4)
bool[] GetLEDS(int remote)
void SetRumble(int remote, bool enabled)
bool GetRumble(int remote)
void ToggleRumble(int remote)
bool GetButton(int remote, string s)
bool GetButtonDown(int remote, string s)
bool GetButtonUp(int remote, string s)
float GetIRSensitivity(int remote)
void SetIRSensitivity(int i, float sensitivity)
Vector2 GetIRPosition(int remote)
Vector3 GetIRVector3(int remote)
float GetIRRotation(int remote)
Vector3[] GetRawIRData(int remote)
bool HasMotionPlus(int remote)
void CheckForMotionPlus(int remote)
void DeactivateMotionPlus(int remote)
void ShouldAutomaticallyCheckForMotionPlus(bool should)
void ShouldAutomaticallyCalibrateMotionPlus(bool should)
bool IsMotionPlusCalibrated(int remote)
Vector3 GetMotionPlus(int remote)
Vector3 GetRawMotionPlus(int remote)
bool IsRollFast(int remote)
bool IsYawFast(int remote)
bool IsPitchFast(int remote)
void CalibrateMotionPlus(int remote, Vector3 calib)
void CalibrateMotionPlus(int remote)
void UncalibrateMotionPlus(int remote)
int GetExpType(int remote)
Vector2 GetNunchuckAnalogStick(int remote)
bool GetNunchuckButton(int remote, string s)
bool GetNunchuckButtonDown(int remote, string s)
bool GetNunchuckButtonUp(int remote, string s)
Vector3 GetNunchuckAcceleration(int remote)
bool GetClassicButton(int remote, string s)
bool GetClassicButtonDown(int remote, string s)
bool GetClassicButtonUp(int remote, string s)
Vector2 GetClassicAnalogStick(int remote, string s)
float GetAnalogButton(int remote, string s)
Vector4 GetBalanceBoard(int remote)
Vector4 GetRawBalanceBoard(int remote)
Vector2 GetCenterOfBalance(int remote)
float GetTotalWeight(int remote)
bool GetGuitarButton(int remote, string s)
bool GetGuitarButtonDown(int remote, string s)
bool GetGuitarButtonUp(int remote, string s)
Vector2 GetGuitarAnalogStick(int remote)
int GetGuitarStrum(int remote)
float GetGuitarWhammy(int remote)
bool GetDrumButton(int remote, string s)
bool GetDrumButtonDown(int remote, string s)
bool GetDrumButtonUp(int remote, string s)
Vector2 GetDrumAnalogStick(int remote)
float GetDrumVelocity(int remote, string drum)
bool GetTurntableButton(int remote, string s)
bool GetTurntableButtonDown(int remote, string s)
bool GetTurntableButtonUp(int remote, string s)
Vector2 GetTurntableAnalogStick(int remote)
float GetTurnTableSpin(int remote, string which)
float GetTurnTableSlider(int remote)
float GetTurnTableDial(int remote)

Broadcasted Messages

“OnWiimoteFound(int remote)”
– Takes a single int parameter representing the number of the remote found.

“OnWiimoteDropped(int remote)”
– Takes a single int parameter representing the number of the remote lost.

“OnDiscoveryError(int error)”
– Takes a single int parameter representing the error code.

Static Functions

void StartSearch()
-begins the search for new wiimotes or balance boards. Press the 1 and 2 buttons
simultaneously on a wii remote or press the sync button on the remote to allow it to
be discovered. The search lasts approximately 20 seconds. Newer wiimotes (“with a bluetooth identifier ending in TR”) can only be detected by the Mac version of WiiBuddy and only if the sync button is pressed (not if the 1 and 2 button are pressed).

void StopSearch()
-cancels any ongoing attempts to discover new wiimotes

int GetDiscoveryStatus()
-returns a value representing the current status of the discovery
0 = not currently searching
1 = searching
1## = new remote is found with ## representing its number
a negative value means that the search has ended in failure
-100 means that the search timed out

void DropWiiRemote(int i)
int i : the number of the remote (0-15)
-closes the connection to the wiimote or balance board represented by the number given.

int GetRemoteCount()
-returns the total number of wiimotes and balance boards connected.

bool IsActive(int remote)
int remote : the number of the remote(0-15)
-returns true if there is an open connection to the remote represented by the number given.

bool IsSearching()
-returns true if currently searching for new wiimotes or balance boards.

float GetBattery(int remote)
int remote : the number of the remote(0-15)
-returns a float between 0 and 1 representing how much power
the battery of the remote represented by the number given contains

void SetLEDs(int remote, bool LED1, bool LED2, bool LED3, bool LED4)
int remote : the number of the remote(0-15)
bool LED1 : the desired state of the first LED
bool LED2 : the desired state of the second LED
bool LED3 : the desired state of the third LED
bool LED4 : the desired state of the fourth LED (duh.)
-updates all four LEDs so that they match the four boolean parameters
-Balance boards only have the one LED represented by LED1

bool[] GetLEDS(int remote)
int remote : the number of the remote(0-15)
-returns an array with a length of four. Each boolean
represents the LEDs of the wiimote represented by the number given.
-The booleans represent the LEDs from left to right.
-Balance boards only have the one LED represented by the first boolean

void SetRumble(int remote, bool enabled)
int remote : the number of the remote(0-15)
bool enabled : whether or not the wiimote should rumble
-Balance boards don’t rumble

bool GetRumble(int remote)
int remote : the number of the remote(0-15)
-returns whether or not the wiimote is already rumbling

void ToggleRumble(int remote)
int remote : the number of the remote(0-15)
-causes the wiimote to either start or stop rumbling,
depending on its current state.

bool GetButton(int remote, string s)
int remote : the number of the remote(0-15)
string s : the type of button you wish to check.
-returns true if the button is depressed.
-acceptable button types:
“A” “B” “ONE” “1” “TWO” “2” “PLUS” “+” “MINUS” “-” “HOME” “H” “UP” “DOWN” “LEFT” “RIGHT”
“C” “Z”
“CLASSICA” “CLASSICB” “CLASSICMINUS” “CLASSICPLUS” “CLASSICHOME” “CLASSICX”
“CLASSICY” “CLASSICUP” “CLASSICDOWN” “CLASSIC LEFT” “CLASSICRIGHT” “CLASSICL”
“CLASSICR” “CLASSICZL” “CLASSICZR”
“GUITARGREEN” “GUITARRED” “GUITARYELLOW” “GUITARBLUE” “GUITARORANGE”
“GUITARPLUS” “GUITARMINUS”
“DRUMGREEN” “DRUMRED” “DRUMYELLOW” “DRUMBLUE” “DRUMORANGE” “DRUMPLUS”
“DRUMMINUS””DRUMPEDAL”
“TURNTABLEGREENLEFT” “TURNTABLEREDLEFT” “TURNTABLEBLUELEFT”
“TURNTABLEGREENRIGHT” “TURNTABLEREDRIGHT” “TURNTABLEBLUERIGHT”
“TURNTABLEEUPHORIA” “TURNTABLEPLUS” “TURNTABLEMINUS”

bool GetButtonDown(int remote, string s)
int remote : the number of the remote(0-15)
-returns true if the button is depressed in the current frame,
but was not in the previous frame.
-acceptable button types:
“A” “B” “ONE” “1” “TWO” “2” “PLUS” “+” “MINUS” “-” “HOME” “H” “UP” “DOWN” “LEFT” “RIGHT”
“C” “Z”
“CLASSICA” “CLASSICB” “CLASSICMINUS” “CLASSICPLUS” “CLASSICHOME” “CLASSICX”
“CLASSICY” “CLASSICUP” “CLASSICDOWN” “CLASSIC LEFT” “CLASSICRIGHT” “CLASSICL”
“CLASSICR” “CLASSICZL” “CLASSICZR”
“GUITARGREEN” “GUITARRED” “GUITARYELLOW” “GUITARBLUE” “GUITARORANGE”
“GUITARPLUS” “GUITARMINUS”
“DRUMGREEN” “DRUMRED” “DRUMYELLOW” “DRUMBLUE” “DRUMORANGE” “DRUMPLUS”
“DRUMMINUS””DRUMPEDAL”
“TURNTABLEGREENLEFT” “TURNTABLEREDLEFT” “TURNTABLEBLUELEFT”
“TURNTABLEGREENRIGHT” “TURNTABLEREDRIGHT” “TURNTABLEBLUERIGHT”
“TURNTABLEEUPHORIA” “TURNTABLEPLUS” “TURNTABLEMINUS”

bool GetButtonUp(int remote, string s)
int remote : the number of the remote(0-15)
-returns true if the button is not depressed in the
current frame but was in the previous frame.
-acceptable button types:
“A” “B” “ONE” “1” “TWO” “2” “PLUS” “+” “MINUS” “-” “HOME” “H” “UP” “DOWN” “LEFT” “RIGHT”
“C” “Z”
“CLASSICA” “CLASSICB” “CLASSICMINUS” “CLASSICPLUS” “CLASSICHOME” “CLASSICX”
“CLASSICY” “CLASSICUP” “CLASSICDOWN” “CLASSIC LEFT” “CLASSICRIGHT” “CLASSICL”
“CLASSICR” “CLASSICZL” “CLASSICZR”
“GUITARGREEN” “GUITARRED” “GUITARYELLOW” “GUITARBLUE” “GUITARORANGE”
“GUITARPLUS” “GUITARMINUS”
“DRUMGREEN” “DRUMRED” “DRUMYELLOW” “DRUMBLUE” “DRUMORANGE” “DRUMPLUS”
“DRUMMINUS””DRUMPEDAL”
“TURNTABLEGREENLEFT” “TURNTABLEREDLEFT” “TURNTABLEBLUELEFT”
“TURNTABLEGREENRIGHT” “TURNTABLEREDRIGHT” “TURNTABLEBLUERIGHT”
“TURNTABLEEUPHORIA” “TURNTABLEPLUS” “TURNTABLEMINUS”

Vector3 GetWiimoteAcceleration(int remote)
int remote : the number of the remote(0-15)
-returns a vector3 representing the three axes of the wiimote’s acceleration.
-the x-axis runs from the left side to the right side.
-the y-axis runs from the expansion port to the IR camera
-the z-axis runs from the button faces to the battery panel

float GetIRSensitivity(int remote)
int remote : the number of the remote(0-15)
-returns a value from 1 to 100 representing the IR sensitivity used in GetIRPosition. Sensitivity is 50 by default.

void SetIRSensitivity(int i, float sensitivity)
int remote : the number of the remote(0-15)
-sets the sensitivity value to be used y GetIRPosition.
-sensitivity value is clamped from 1 to 100.
-sensitivity is 50 by default.

Vector2 GetIRPosition(int remote)
int remote : the number of the remote(0-15)
-returns the x and y coordinate of the IR pointer
-this function is overly elaborate and attempts to continue functioning,
even if the IR camera loses sight of half the sensor bar. I encourage
anyone capable to create a more effective function using the raw IR data.

Vector3 GetIRVector3(int remote)
int remote : the number of the remote(0-15)
– returns the same x and y values as GetIRPosition along with a Z
value determined by how close the wiimote is to the sensor bar.

float GetIRRotation(int remote)
int remote : the number of the remote(0-15)
– uses the accelerometer information to determine the angle between
the button face of the wiimote and gravitational upwards, along the axis
of the wiimote running from the IR Camera to the expansion port.
The angle is measured in radians. Clockwise roll is positive. Counter
clockwise roll is negative.

Vector3[] GetRawIRData(int remote)
int remote : the number of the remote(0-15)
-returns an array of four Vector3s. The x and y of each Vector3
represent the position of an IR point, relative to the IR Camera.
The x and y values are scaled to range from 0 to 1.
the z of each Vector3 represents how close that IR point is.

bool HasMotionPlus(int remote)
int remote : the number of the remote(0-15)
– Returns true if external motion plus device is attached or if wiimote has motion pus built in.

void CheckForMotionPlus(int remote)
int remote : the number of the remote(0-15)
– If the remote has an unactivated or deactivated Motion Plus attached to it, this will activate it.
– Once activated, the Motion Plus will still need to be calibrated.

void DeactivateMotionPlus(int remote)
int remote : the number of the remote(0-15)
– If the remote has an activated Motion Plus, this will uncalibrate and deactivate it.
– Doing so may allow for more IR information (so long as no other extension is attached)

void ShouldAutomaticallyCheckForMotionPlus(bool should)
– If true, WiiBuddy will check for attached (but unactivated) motion plus every 4 seconds.
– Is true by default, but will only work if the Wii prefab is present in the scene

void ShouldAutomaticallyCalibrateMotionPlus(bool should)
– If true, WiiBuddy will automatically calibrate any remotes with uncalibrated Motion Plus
– Calibration happens when an uncalibrated remote is placed face down and motionless for a few seconds.
– Is true by default, but will only work if the Wii prefab is present in the scene.

bool IsMotionPlusCalibrated(int remote)
int remote : the number of the remote(0-15)
– Returns true if the wiimote’s motion plus is available and has been calibrated.
– Motion plus is calibrated by placing the wiimote face down and motionless.

Vector3 GetMotionPlus(int remote)
int remote : the number of the remote(0-15)
– Returns a Vector3 representing the roll, yaw, and pitch of the wiimote
– Returns Vector3.zero if uncalibrated.

Vector3 GetRawMotionPlus(int remote)
int remote : the number of the remote(0-15)
– Returns a Vector3 containing the raw roll, yaw, and pitch of the wiimote.
– This is Meant to be used for calibrating the Motion Plus without Wii.cs doing it automatically
– Before calibration, these will represent the raw data of the motion plus.
– After calibration, these will still be calibrated(I think), but will not exclude near-zero values or use Time.deltaTime

bool IsRollFast(int remote)
int remote : the number of the remote(0-15)
– Returns true if the motion plus is rolling quickly.
– Does not need to be calibrated.

bool IsYawFast(int remote)
int remote : the number of the remote(0-15)
– Returns true if the motion plus is yawing quickly.
– Does not need to be calibrated.

bool IsPitchFast(int remote)
int remote : the number of the remote(0-15)
– Returns true if the motion plus is pitching quickly
– Does not need to be calibrated.

void CalibrateMotionPlus(int remote, Vector3 calib)
int remote : the number of the remote(0-15)
Vector3 calib : the roll, yaw, and pitch which will become the motion plus center values.
– Calibrates the remote’s motion plus so that the entered values represent no rotation.

void CalibrateMotionPlus(int remote)
int remote : the number of the remote(0-15)
– Calibrates the remote’s motion plus so that the current raw values represent no rotation.

void UncalibrateMotionPlus(int remote)
int remote : the number of the remote(0-15)
– Throws away this motion plus’s calibration information.
– This motion plus must be placed face down to recalibrate.

int GetExpType(int remote)
int remote : the number of the remote(0-15)
-returns an int representing the expansion type plugged
into this wiimote.
0 : no expansion
1 : nunchuck
2 : classic controller
3 : balance board
4 : guitar
5 : drumset
6 : Turntable

Vector2 GetAnalogStick(int remote)
int remote : the number of the remote(0-15)
-if the wiimote has an expansion with an analog stick,
a Vector2 is returned representing the x and y values
of that analog stick. If the expansion is the classic controller,
the left analog stick is used.

Vector2 GetAnalogStick(int remote, string s)
int remote : the number of the remote(0-15)
string s : the type of analog stick you wish to check
-acceptable analog stick types
“NUNCHUCK” “CLASSICLEFT” “CLASSICRIGHT” “GUITAR” “DRUMS” “TURNTABLE”
-if the specified analog stick is available, the returned Vector2 represents its x and y value

Vector2 GetNunchuckAnalogStick(int remote)
int remote : the number of the remote(0-15)
-if a nunchuck is attached to this wiimote, a Vector2 is returned
representing its analog stick’s x and y values.
-values are returned on a scale between approximately -1 and 1.

bool GetNunchuckButton(int remote, string s)
int remote : the number of the remote(0-15)
-returns false if nunchuck is not attached to this wiimote.
string s : the type of button you wish to check
-returns true if the button is depressed in the
current frame
acceptable button types:
“C” “Z”

bool GetNunchuckButtonDown(int remote, string s)
int remote : the number of the remote(0-15)
string s : the type of button you wish to check
-returns true if the button is depressed in the
current frame but was not in the previous frame.
acceptable button types:
“C” “Z”

bool GetNunchuckButtonUp(int remote, string s)
int remote : the number of the remote(0-15)
string s : the type of button you wish to check
-returns true if the button is not depressed in the
current frame but was in the previous frame.
acceptable button types:
“C” “Z”

Vector3 GetNunchuckAcceleration(int remote)
int remote : the number of the remote(0-15)
-returns a vector3 representing the three axes of the nun chuck’s acceleration.
-the x-axis runs from the left side to the right side.
-the y-axis faces out through the button faces
-the z-axis runs through the top of the analog stick to the bottom

bool GetClassicButton(int remote, string s)
int remote : the number of the remote(0-15)
string s : the type of button you wish to check
-returns true if the button is depressed in the
current frame.
acceptable button types:
“A” “B” “MINUS” “PLUS” “HOME” “X” “Y” “UP” “DOWN” “LEFT” “RIGHT” “L” “R” “ZL” “ZR”

bool GetClassicButtonDown(int remote, string s)
int remote : the number of the remote(0-15)
string s : the type of button you wish to check
-returns true if the button is depressed in the
current frame but was not in the previous frame.
acceptable button types:
“A” “B” “MINUS” “PLUS” “HOME” “X” “Y” “UP” “DOWN” “LEFT” “RIGHT” “L” “R” “ZL” “ZR”
bool GetClassicButtonUp(int remote, string s)
int remote : the number of the remote(0-15)
string s : the type of button you wish to check
-returns true if the button is not depressed in the
current frame but was in the previous frame.
acceptable button types:
“A” “B” “MINUS” “PLUS” “HOME” “X” “Y” “UP” “DOWN” “LEFT” “RIGHT” “L” “R” “ZL” “ZR”

Vector2 GetClassicAnalogStick(int remote, string s)
int remote : the number of the remote(0-15)
string s : the type of analog stick you wish to check
returns a Vector2 representing the x and y values of
the specified analog stick. Values range from -1 to 1
with 0 representing the neutral position.
acceptable types of analog stick:
“LEFT” “RIGHT”

float GetAnalogButton(int remote, string s)
int remote : the number of the remote(0-15)
string s :  the type of analog button you wish you check.
acceptable button types:
“CLASSICL” “CLASSICR”

Vector4 GetBalanceBoard(int remote)
int remote : the number of the remote(0-15)
returns the weight in kilograms on each of the four
sensors in the balance board.
The x-value is the top right sensor.
The y-value is the top left sensor.
The z-value is the bottom right sensor.
The w-value is the bottom left sensor.

Vector4 GetRawBalanceBoard(int remote)
int remote : the number of the remote(0-15)
returns the raw values generated by the four sensors
in the balance board.
The x-value is the top right sensor.
The y-value is the top left sensor.
The z-value is the bottom right sensor.
The w-value is the bottom left sensor.

Vector2 GetCenterOfBalance(int remote)
int remote : the number of the remote(0-15)
returns a Vector 2 representing the distribution of weight on
the balance board. The x-value represents the difference in
weight between the right and left sides. The y-value represents
the difference in weight between the front and back sides.
If there is no weight or the weight is evenly distributed,
Vector2.zero is returned.

float GetTotalWeight(int remote)
int remote : the number of the remote(0-15)
returns the total weight on the balance board in kilograms.

bool GetGuitarButton(int remote, string s)
int remote : the number of the remote(0-15)
-returns true if the button is depressed in the
current frame.
-acceptable button types:
“GREEN” “RED” “YELLOW” “BLUE” “ORANGE” “PLUS” “MINUS”:

bool GetGuitarButtonDown(int remote, string s)
int remote : the number of the remote(0-15)
-returns true if the button is depressed in the
current frame but was not in the previous frame.
-acceptable button types:
“GREEN” “RED” “YELLOW” “BLUE” “ORANGE” “PLUS” “MINUS”:

bool GetGuitarButtonUp(int remote, string s)
int remote : the number of the remote(0-15)
-returns true if the button is not depressed in the
current frame but was in the previous frame.
-acceptable button types:
“GREEN” “RED” “YELLOW” “BLUE” “ORANGE” “PLUS” “MINUS”:

Vector2 GetGuitarAnalogStick(int remote)
int remote : the number of the remote(0-15)
-if a Drumset is attached to this wiimote, a Vector2 is returned
representing its analog stick’s x and y values.
-values are returned on a scale between approximately -1 and 1.

int GetGuitarStrum(int remote)
int remote : the number of the remote(0-15)
returns a zero if the strummer is in the neutral position.
returns a 1 if the strummer is turned downwards.
returns a -1 if the strummer is turned upwards.

float GetGuitarWhammy(int remote)
int remote : the number of the remote(0-15)
returns a value between 0 and 1 representing the force depressing the whammy bar, similarly to an analog button.

bool GetDrumButton(int remote, string s)
int remote : the number of the remote(0-15)
-returns true if the button is being struck in the
current frame.
-acceptable button types:
“GREEN” “RED” “YELLOW” “BLUE” “ORANGE” “PLUS” “MINUS” “PEDAL”

bool GetDrumButtonDown(int remote, string s)
int remote : the number of the remote(0-15)
-returns true if the button is being struck in the
current frame but was not in the previous frame.
-acceptable button types:
“GREEN” “RED” “YELLOW” “BLUE” “ORANGE” “PLUS” “MINUS” “PEDAL”

bool GetDrumButtonUp(int remote, string s)
int remote : the number of the remote(0-15)
-returns true if the button is not being struck in the
current frame but was in the previous frame.
-acceptable button types:
“GREEN” “RED” “YELLOW” “BLUE” “ORANGE” “PLUS” “MINUS” “PEDAL”

Vector2 GetDrumAnalogStick(int remote)
int remote : the number of the remote(0-15)
-if a Drumset is attached to this wiimote, a Vector2 is returned
representing its analog stick’s x and y values.
-values are returned on a scale between approximately -1 and 1.

float GetDrumVelocity(int remote, string drum)
int remote : the number of the remote(0-15)
string drum : the type of drum you wish to check
-acceptable drum types:
“GREEN” “RED” “YELLOW” “BLUE” “ORANGE” “PLUS” “MINUS” “PEDAL”

bool GetTurntableButton(int remote, string s)
int remote : the number of the remote(0-15)
-returns true if the button is depressed in the
current frame.
-acceptable button types:
“GREENLEFT” “REDLEFT” “BLUELEFT”
“GREENRIGHT” “REDRIGHT” “BLUERIGHT”
“EUPHORIA” “PLUS” “MINUS”

bool GetTurntableButtonDown(int remote, string s)
int remote : the number of the remote(0-15)
-returns true if the button is depressed in the
current frame but was not in the previous frame.
-acceptable button types:
“GREENLEFT” “REDLEFT” “BLUELEFT”
“GREENRIGHT” “REDRIGHT” “BLUERIGHT”
“EUPHORIA” “PLUS” “MINUS”

bool GetTurntableButtonUp(int remote, string s)
int remote : the number of the remote(0-15)
-returns true if the button is not depressed in the
current frame but was in the previous frame.
-acceptable button types:
“GREENLEFT” “REDLEFT” “BLUELEFT”
“GREENRIGHT” “REDRIGHT” “BLUERIGHT”
“EUPHORIA” “PLUS” “MINUS”

Vector2 GetTurntableAnalogStick(int remote)
int remote : the number of the remote(0-15)
-if a Turntable is attached to this wiimote, a Vector2 is returned
representing its analog stick’s x and y values.
-values are returned on a scale between approximately -1 and 1.

float GetTurnTableSpin(int remote, string which)
int remote : the number of the remote(0-15)
string which : the type of platter you wish to check
-acceptable platter types:
“LEFT” “RIGHT”
-returns a float representing the direction and speed of a platter’s rotation. Clockwise rotation is represented by positive values, which counter clockwise rotation is represented by negative values. The rotation speed is represented in degrees per second (approximately). If a platter is spinning faster than it can register, it will use smaller values. It seems like the RIGHT platter is able to handle speeds twice as fast as those on the LEFT.

float GetTurnTableSlider(int remote)
int remote : the number of the remote(0-15)
-returns a float representing the current position of the Turntable’s slider. The left and right ends correspond to -1 and 1, with the middle position corresponding to zero.

float GetTurnTableDial(int remote)
int remote : the number of the remote(0-15)
-returns a float representing the current position of the Turntable’s dial.
The value ranges from zero to one.

Advertisements

45 responses to “WiiBuddy API

  1. kevin November 23, 2012 at 2:59 am

    Woah! This is awesome!! Can you do head tracking with this in unity?

  2. gregtamargo November 25, 2012 at 9:47 pm

    Yes. Since you have access to the raw IRData, you could set up a Wii remote as an IR camera and use it to track up to 4 IR lights. The raw IR data is presented as an array of four vector3. Each one contains the x and y value as well as the size of the IR light. I should probably update this API to explain things like that a bit better.

    Oh. Also, the x and y values currently range from zero to one. If for whatever reason, you want to change that, you can do so by editing the function in the Wii.cs file.

    Best of luck to ya.

  3. Luke February 5, 2013 at 7:08 pm

    Hey there,

    just bought your Unity plugin and the setup process was rather painless. Thanks for this awesome project btw 🙂

    Anyways, was having a question about the z value I’m getting from raw IRData. If I’m reading the documentation correctly, this value is supposed to show me the distance between the IR and the sensor bar, right? However, this value appears to be quite jumpy. It can jump between 1.0 and 2.0 by only moving the controller maybe about an inch or so. I also noticed, that it only shows integer like values (1.0, 2.0, 3.0, etc…) and nothing in between. Compared to the x and y values, which are super sensitive (between 0.0 and 1.0), this is quite odd.
    Am I doing something wrong here?

    Thanks in advance.

    • gregtamargo February 5, 2013 at 7:33 pm

      Hello and thankyou!

      Actually, after putting WiiBuddy up, I did some more research into how the IR data works and as it turns out, what I thought was “closeness” of the IR light actually turned out to be the size of the “blob” of light as perceived by the IR camera. Also, this value is only updated when the remote has no extensions attached. So unfortunately, the z value of the raw IR data isn’t as useful as I had originally hoped it to be.

      However! upon doing a bit more digging, I found that there is a fourth bit of IR data that is IR light intensity. I missed it before because no other wii remote connection projects have actually used this data. So it’s definitely on my plate of improvements to make.

      I’m actually about to submit an update to Unity to improve the motion plus functionality. The only reason I’ve been putting this off is because I’ve also been trying to improve functionality with remotes in other countries and was hoping I could make that update at the same time (this doesn’t seem to be the case).

      Anyways, once I make this update, improving the IR functionality for the next update is one of the next things on my plate (along with putting up a free version with no extension support…maybe no IR either… not sure).

      I’m sorry if this inconveniences you and your plans. I’ll do what I can and keep you posted.

      -Greg

  4. Luke February 6, 2013 at 1:58 am

    Hey,

    thanks for your quick reply. Very much appreciated 🙂

    Yeah, that would be awesome, if you could throw that in on the next update.
    I’m working on some head tracking btw.

    Anyways, I played around a bit more with your demo scene and maybe I can compensate for the missing z value for now. Not quite sure though. The red and yellow IR lights seem to transform quite smoothly when moving the sensor bar. Using their distance from the left and right side of the screen and assuming, that if they both get closer to the sides, the sensor bar must also be closer to the wiimote and the other way round, might allow me to get a proper z value. What do you think? Am I on the right track here?

  5. gregtamargo February 6, 2013 at 2:13 am

    I think I understand what you’re saying is that you can estimate the distance of the IR lights by judging their apparent distance from each other. This is something I’ve thought about before.

    When you have 2 IR points it works so long as the “sensor bar” is always facing directly towards the IR camera. If the structure holding the IR lights were to skew in space, then the IR points would appear closer to each other without actually moving further away from the IR camera.

    Since you’re doing head tracking, perhaps you could use a structure that contains 3 or even 4 IR lights. The wiimotes are able to track up to 4 lights at a time.

    if you have 3 lights forming an L-shape or 4 lights forming a square, the camera should be able to tell the difference between the IR structure rotation in space and simply moving away. Exactly what this script would look like I’m not exactly sure, but you should be able to rationalize in your head that if the structure appears narrower without growing shorter, than clearly it must be rotating on a vertical axis and not moving further away.

    I hope this helps. Good luck!

  6. Luke February 6, 2013 at 2:37 am

    Hello again,

    thanks for getting back to me. Well, when doing my research, I came across this amazing dude, called Johnny Lee. In case you haven’t heard of him, maybe do a quick search on YouTube. Anyways, he did some cool stuff by mounting 2 LED lights on a pair of safety glasses. So, it’d be kinda cool, if I could get some results by using 2 LED lights only. I do understand, that if one of those lights goes off camera, I might be in trouble 🙂

    However, my concept assumes a fixed standing position of the user wearing those glasses. So, the head movement on the z axis would be minimal. Not sure, if that will get me off easy though 🙂

    Thanks again for your help. I’ll report back, if I make some progress…

  7. Luke February 6, 2013 at 2:39 am

    Here is the YouTube link I was talking about. Hope, it’s ok to add it here: http://www.youtube.com/watch?v=Jd3-eiid-Uw

  8. Steve December 21, 2013 at 8:25 am

    Guys, your StartSearch() function crashes Unity every time I call it. Your demo scene therefore crashes whenever I click ‘Find’. Any thoughts?

  9. gregtamargo December 23, 2013 at 2:02 am

    Wow… That’s a new one. Are you using a Mac or a Windows machine? If you’re using a Mac and just pushing the StartSearch() function causes Unity to crash or even throw an error, that’s a new one for me… (scary…). Feel free to gimme some more details or email me at bitLegit@gmail.com

  10. Steve December 26, 2013 at 12:38 pm

    Thanks for the reply, I’ve only just seen it. It turns out I had forgotten to switch Bluetooth on! No crashes with Bluetooth on, but with Bluetooth turned off the crash bug is reliably reproducible.

    I’m still struggling a little bit (which I’m sure is down to me being a hack programmer) so will email you with a couple of queries, if the offer still stands.

  11. hpridham February 3, 2014 at 6:37 pm

    I’m having a really hard time connecting two wiimotes. I keep getting “spread the word: error-536870195”. Any help would be grateful.

  12. hpridham February 3, 2014 at 6:48 pm

    My second wiimote simply won’t connect. I just keep getting this error, “spread the word: error-536870195”. What does it mean?

  13. hpridham February 3, 2014 at 6:54 pm

    N/M, I got it to connect by first using the OS X Mavericks bluetooth window to connect manually.

  14. tmorelli June 16, 2014 at 2:02 pm

    Love this plugin! However, I can only seem to connect to wii devices within the IDE. If I build a stand alone application none of my controllers are found. Any thoughts on this one?

    • gregtamargo June 16, 2014 at 6:28 pm

      Hm. That’s strange. The mac OS bluetooth inner workings can be strange though. My initial thought is that you should make sure that you’ve first removed your wii remotes from your mac’s list of familiar bluetooth devices in the bluetooth section of System Preferences. This always seemed to ensure a reliable connection for me. If by some chance that doesn’t work (and I would be surprised if that doesn’t work), try and optimize your application to make sure the computer is as unencumbered as possible while you’re trying to make the connection. Good luck!

      • tmorelli June 17, 2014 at 11:48 am

        Thanks for your quick reply! The issue was a mistake on my part – I connected the devices in the IDE, then built an application. Then I ran the application, but the controllers were still connected to the IDE even though I wasnt running the game. Simply disconnecting from the bluetooth menu and starting the app made everything work. Great bundle by the way. Exactly what I needed!

  15. John November 15, 2014 at 2:48 am

    Can you add a function to the API that would provide the MAC address of the bluetooth connection? This will help us identify one remote from another.

    • gregtamargo November 15, 2014 at 11:47 am

      Iiiinteresting. As far as requests go, that’s a first. We don’t have any immediate plans for adding more features, but I’ll certainly keep this in mind. We may take a shot at making some improvements once Unity 5 comes out. No promises though. Good luck with your project.

  16. rihito January 12, 2015 at 2:33 am

    I tried to make a connection with wii remote using WiiBuddy. However, Unity crashed after the switch of the wii object in the Unity project and the switch of wii remote.
    Could you help me?

    mac OS version is Yosemite.
    Unity version is 4.6.1f1

    • gregtamargo January 14, 2015 at 8:48 pm

      Hmm. You’re the first person to report this problem. Hopefully it was just a one time fluke. During development, the bluetooth could sometimes be fickle, though I don’t think it ever made Unity crash. I’m not entirely clear on the events you’re describing does “the switch of” mean “I switch off”? In the README document that comes with the plugin, I included everything I know about improving the ease of making a connection. Please read through all of that for advice. Also, what specific kind of Wii remote are you using. Is it official-Nintendo-made? Is it a WiiU remote?

      Good luck with your project. I hope this works itself out.

      -Greg

  17. Peter Caddock January 19, 2015 at 12:30 pm

    Hey guys,

    great job so far, now I have a question for you, is it possible to develop in Unity Pro on OS X and then deploy to iPhone Pro (using our Apple developers account)?

    i.e. Does this functionality transfer across to iOS?

    I’d love to be able to use Wii motes etc on iOS games…. yum!

    IPete2.

    • gregtamargo January 19, 2015 at 12:44 pm

      Hey, Pete. Honestly, this is a questions we’ve also asked but never took the time to answer ourselves. From what we understand about Mac bluetooth, it shhhhhooould work???? but still I’m skeptical. I’m pretty sure the iOS and MacOSX bluetooth libraries the same, but even now I wouldn’t consider myself an expert.

      If you try it and find out for certain, please let us know about your results!

      -Greg

  18. Peter Caddock January 19, 2015 at 12:48 pm

    Hi Greg,

    Thanks for the speedy reply. I guess I’ll have to buy Wii Buddy to test it – which I was trying to avoid until I knew it would work. If it did I’d be very (very, very, very excited and happy), but I’ve had no luck so far. Getting an iMac to sync is fine, and I have used UniWii before to develop stuff for a Unity Wii game, (developing on a Mac) but although I can see it works on jailbroken devices, I don’t want to go there. I need a pucker solution… hence the question.

    Do you guys have Apple accounts and Unity iPhone Pro?

    IPete2.

    • gregtamargo January 19, 2015 at 12:58 pm

      I haven’t had Unity Pro at my disposal for a while and it’s been even longer since we worked on WiiBuddy. If other Wii libraries require a jailbroken iphone, I wouldn’t be surprised if WiiBuddy does as well, but really I have no idea and I’m in no position to do the research to find out myself. Sorry and good luck.

      -Greg

  19. Peter Caddock January 19, 2015 at 1:04 pm

    Hey Greg,

    Again thanks for the speedy reply – no problem – it would be hard to find out without Pro!

    Well, in that case I may just have to purchase Wii Buddy to find out… 🙂 If I do I’ll let you know either way because if the iOS side works then it would be excellent for my needs just now.

    I’ll probably try it tomorrow.

    Thanks again,

    IPete2.

  20. Peter Caddock (IPete2) October 3, 2015 at 6:52 am

    Hi Greg

    With the advent of VR on mobile devices, how are you fixed for developing an iOS version or Wii Buddy – imagine using two Wii motes in the same way the Oculus and HTC are developing their hand controllers?

    Wii motes are perfect substitutes for this and I would be happy to test for you…

    I have at the idea game in development for such a use… 🙂

    peter at smartscreenuk.com

    All the best
    IPete2.

    • gregtamargo October 5, 2015 at 12:24 am

      Hey, Pete. This was something we thought of fairly early on in production. I’m not sure what the situation is now, but I know that back then Unity Pro for iPhones was not something we could have easily gotten access to. However, if iOS uses the same bluetooth protocols as Mac OSX, there’s really no reason for it not to work already. We never got around to actually trying it and are unable to do so right now. Hopefully though, there will be a major update to WiiBuddy in the near future. From there, we will be assessing where to go next.

      If you do have a copy of WiiBuddy and are able to give it a shot on iOS, please try it out and let me know how it goes!

      Respectfully,

      Greg

  21. Peter Caddock October 5, 2015 at 10:50 am

    Hi Greg,

    I bought Wii Buddy and Im trying to use it on my iMac.

    I have a number of Wii remotes all of which connect to the iMac, but they don’t select a channel, so all blue lights keep flashing – they do not show 1, 2, 3, or 4.

    Then when I run Wii Buddy demo and press find nothing happens. I do get a console message as follow:

    spread the word error -536870195

    Any thoughts?

    P.

    • gregtamargo October 5, 2015 at 11:58 am

      It sounds like you’re connecting the wiimotes to your mac directly through the OS’s bluetooth preferences and THEN trying to connect to wiibuddy. This is how it would work on a Windows machine, but currently Wiibuddy on Mac handles all the connecting completely internally. With your wiimote completely unconnected, start up Unity and open WiiBuddy. Then, press the Find button (either in the prefab’s custom inspector or in the demo scene). Then press the red sync button on the wiimote. So long as the wiimote and WiiBuddy are searching for each other at the same time, they should connect. I think I go into more detail in the attached documentation. If you go through that and have any more questions or problems, please let me know. I’m working on an update and if there are any problems, I’d love to know.

      -Greg

      • Peter Caddock October 5, 2015 at 12:53 pm

        Oh man that’s exactly what I was doing and so now I’m doing it the right way, and of course it works on OS X straight away.

        I’m about to leave for the day, but I may take this home and test on iOS there. If this works I’ll be jumping very high and shouting Eureka.

        Thanks for the help Greg.

        P.

  22. Peter Caddock (IPete2) October 6, 2015 at 10:19 am

    Hi Greg,

    I switched to iOS build settings and the script came up with a lot of errors, a lot of things to do with typing I think, iOS requires pragma strict. Im sure it can be fixed, but Im not into JS. Not sure if you guys can fix this in the new update? I am straining at the leash to test this on iOS asap. Its vital to my project to know asap.

    P.

    • gregtamargo October 6, 2015 at 4:58 pm

      Sorry about that. The WiiBuddy demo scene was probably the last thing I ever made in JavaScript (and poorly at that). I’m planning on making a new demo scene anyways in C# and with the new UI and what have you. If you’d like I can try and do that sooner rather than later and send something to your smartscreenuk email. Alternatively, if you’re able, you could make your own scene with just some basic functionality to establish a connection and then check for button presses. If you’d like to wait for me, I may be able to email you something tomorrow.

      I’d really like it if this worked. Hopefully the scripting on the Unity side is the only thing holding you back.

  23. Peter Caddock (IPete2) October 7, 2015 at 3:36 am

    Hi Greg,

    No need to apologise, it works fine on desktops! 🙂

    I’ll wait for you if that’s ok? my smartscreenuk email is great thanks. If this works, I think it will be the breakthrough Ive been waiting for in terms of controls for VR at my indie level. What a bboost it will give me on my little project!

    Here’s hoping.

    Best regards,

    P.

  24. cloudscover January 14, 2016 at 9:06 pm

    I’m having trouble getting more than two remotes to connect at once in the demo scene. Whenever I hit Find Remote a third time the third remote just blinks forever and the Debug Log says “spread the message: error-100”. Thoughts?

    • gregtamargo January 15, 2016 at 12:06 am

      Hmm. That is interesting. -100 is just the timeout errorcode. So that means it’s not even seeing the third wiimote. This could mean something is wrong in my code and I missed it. I could have sworn I at least tested up to three though. I’ll check to make sure I have that many remotes and double check this weekend. Before I do though, could you do me a favor? Make sure that you can connect any two of your remotes. If it turns out that one of your remotes just can’t connect, then the problem is not the number of remotes. I’ll investigate this further and get back to you. Thanks for the feedback!

      Respectfully,

      -Greg

      • cloudscover January 15, 2016 at 4:35 pm

        I switched to OS X since the package was developed there and it seems like an easier workflow. Connected three no problem. However, on both systems I really seem to be having quite a large issue ever getting a remote to come back after it’s been lost, whether by telling the API to drop the remote or battery death or something else. I have to go in an scorched earth remove the bluetooth device. Isn’t really very showtime ready of a workflow.

        Gonna see if it’s less broken in an actual build now.

      • gregtamargo January 16, 2016 at 2:39 am

        Hello, again. I managed to track down and re-test with three wiimotes on my Windows machine and found that all three were able to connect and function. If your problem persists, feel free to reach out to me and I’ll do what I can to get to the bottom of it.

        I’d definitely agree and say that I prefer the OSX workflow. Regaining remotes after disconnecting is typically less reliable. I tried to include all of my notes on how to improve connection rates in documentation. The frustrating thing is that there have definitely been periods of time with certain versions of OSX where the connection rates were actually incredibly reliable, but then Apple would issue some updates or something would change with Unity maybe and all of a sudden connection rates would change. Also, working through Unity seems to make connections more difficult. It’s hard to tell.

        At some point in the future, I would like to revisit these issues and see if I can solve them once and for all. Until then, I hope you’re able to achieve the results you’re looking for. Please keep me posted if you have any more questions.

  25. gauravrane September 23, 2016 at 4:58 am

    Hi Greg,
    I purchased the plugin from Unity and i am using it to make a cricket game where the controller is a bat. The problem is that after the first swing the calibration gets messed up and the on screen prefab does not return to the original calibrated position. Hence all consecutive swings are messed up. Could you help out with a solution to this problem.

    • gtamargo September 27, 2016 at 3:45 pm

      Hey, Guarav. I believe you’re talking about using the Wii Motion Plus technology for detecting the controller’s rotation. It’s true that rapid movement and even prolonged regular movement causes its calibration to fade. This is an inherent part of the technology. If you play older games like Wii Sports Resort, you can see that the games were designed to frequently trick the player into recalibrating by pointing at the TV and pressing a button. I’m not sure if WiiBuddy is able capture the complete accuracy of the device, but we likely came very close. Unless something is wrong with your hardware, I’m fairly certain you’ll just have to design your game around the technology’s limitations. Regardless, next time I update WiiBuddy, I’ll be sure to look into this and double check my work. Thank you for your interest. People like you and projects like yours are the reason I keep coming back to WiiBuddy.

  26. cpasyanos August 7, 2017 at 12:03 pm

    (Sorry if I am posting this twice. I hit reply and it didn’t seem to go through) I bought your plugin in order to use a Wii Balance board for a Unity game I’m making, and in editor, it is working great! The BB connects with a click of the “Find” button in the Wii prefab and then I’m off. The problem is when I created an .exe of the test scene I was working on, the balance board no longer connects. I tried to find a few ways to connect the BB through scripting when I first started but couldn’t get it to work, and now I’m not sure how to proceed. I am on Windows 10 and scripting in C#. Thanks for any help!

    • gtamargo August 17, 2017 at 10:43 pm

      Hey. Sorry for the delayed response. I just noticed this. For future reference, feel free to email me at bitlegit@gmail.com. My first question though is if you’re building your exe as 32-bit, 64-bit, or Universal. There used to be a bug with 64-bit builds, but I believe I fixed that a while ago. Please email me if you need to continue this and need more help.

  27. thunderbuns February 2, 2018 at 6:19 pm

    Hey Greg,

    I just recently bought the WiiBuddy and I am really excited about what I can build with it. However I have unfortunately run into a rather big speed bump. When I play the demo scene and click the ‘Find Remote’ button I get a message in the console that says ‘spread the message: error-100’. Do you think that you could help me?

    Sincerely, Thunderbuns

    • gtamargo February 7, 2018 at 3:42 am

      Hey, Thunderbuns. Sorry you’re having trouble. Before I try to help have to made sure to read all of the notes in the ReadMe about how to get a good connection?

      • thunderbuns February 7, 2018 at 3:52 am

        Thanks Greg for getting back to me. As for the ReadMe you are exactly correct, I failed to follow the instructions properly and that is why I couldn’t connect properly, but I got it all worked out.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: