This plug-in* provides support for the Nintendo Wii" remote control, nicknamed the Wiimote. The Wiimote outputs acceleration, IR, joystick and button data over a wireless Bluetooth connection.
Before using the plug-in*, you must establish a connection to the Wiimote using your Bluetooth driver software. Since the Wiimote communicates over wireless Bluetooth, you will need a USB Bluetooth dongle so your computer can send/receive data to/from the Wiimote. In order for your Bluetooth driver to detect the Wiimote, you must place the Wiimote in "Discovery" mode by holding down the 1 and 2 buttons simultaneously. When these button are held down, the LED lights on the Wiimote will blink. You must keep the buttons down until your Bluetooth driver finds and connects to the Wiimote. This process must be repeated for each Wiimote you plan on using with Vizard. Some USB Bluetooth dongles and drivers may not be compatible with the Wiimote. The following site has a list of devices and drivers that are compatible with the Wiimote:
http://wiibrew.org/wiki/List_of_Working_Bluetooth_Devices
The Wiimote plug-in* is implemented as a Vizard extension sensor. The Wiimote extension contains the following methods/constants:
Method |
Description |
<wii>.addWiimote(device=-1) |
Connect to a Wiimote. If device is -1, the next available Wiimote will be returned, otherwsie the Wiimote at the specified device index will be returned. |
<wii>.BUTTON_LEFT <wii>.BUTTON_RIGHT <wii>.BUTTON_DOWN <wii>.BUTTON_UP <wii>.BUTTON_A <wii>.BUTTON_B <wii>.BUTTON_PLUS <wii>.BUTTON_MINUS <wii>.BUTTON_HOME <wii>.BUTTON_1 <wii>.BUTTON_2 |
Button ID and mask values for the Wiimote. |
<wii>.NUNCHUK_C <wii>.NUNCHUK_Z |
Button ID and mask values for the Wiimote Nunchuk extension. |
<wii>.CLASSIC_LEFT <wii>.CLASSIC_RIGHT <wii>.CLASSIC_DOWN <wii>.CLASSIC_UP <wii>.CLASSIC_R <wii>.CLASSIC_PLUS <wii>.CLASSIC_HOME <wii>.CLASSIC_MINUS <wii>.CLASSIC_L <wii>.CLASSIC_ZR <wii>.CLASSIC_X <wii>.CLASSIC_A <wii>.CLASSIC_Y <wii>.CLASSIC_B <wii>.CLASSIC_ZL |
Button ID and mask values for the Wiimote Classic Controller extension. |
<wii>.EXT_NONE <wii>.EXT_NUNCHUK <wii>.EXT_CLASSIC |
Extension types supported by the Wiimote. |
<wii>.EXT_CONNECT_EVENT <wii>.EXT_DISCONNECT_EVENT |
Events IDs triggered when an extension is connected/disconnected from a Wiimote. The event passes a single event structure e with the following attributes:
e.object The Wiimote sensor object.
e.extension The extension type that was connected/disconnected. |
<wii>.CLASSIC_JOYL <wii>.CLASSIC_JOYR |
Source flags that can be used when creating a link with the Wiimote Classic Controller. The flags control whether the position comes from the left or right joystick. |
<wii>.LED_1 <wii>.LED_2 <wii>.LED_3 <wii>.LED_4 |
Bit masks for each LED light on the Wiimote. Can be ORed together. |
The Wiimote extension sensor contains the following methods/attributes, in addition to the standard extension sensor methods:
Method |
Description |
<wiimote>.getLED() |
Returns the bit state of the Wiimote LED lights. If the light is on, the corresponding bit will be set. |
<wiimote>.setLED(state,mode=viz.MASK_SET) |
Set the state of the Wiimote LED lights. mode can be one of the following: viz.MASK_SET viz.MASK_ADD viz.MASK_REMOVE viz.MASK_TOGGLE |
<wiimote>.getRumble() |
Returns the state of the Wiimote rumble pad. |
<wiimote>.setRumble(state,duration=-1) |
Set the state of the Wiimote rumble pad. If state is True, then duration specifies how long to rumble for. If duration is -1, the Wiimote will rumble indefinitely. |
<wiimote>.getAccel() |
Returns the acceleration vector of the Wiimote. The vector is relative to the Wiimotes local coordinate system. |
<wiimote>.getBattery() |
Returns the battery power percentage of the Wiimote. The value is between 0 and 1, where 1 means the battery is at full power. |
<wiimote>.getExtension() |
Returns the type of extension that is currently connected to the Wiimote. The possible values for the extension type are listed above.
|
<wiimote>.getNumIR() |
Returns the number of IR points last detected by the Wiimote. |
<wiimote>.getAngleIR() |
Returns the roll angle of the Wiimote computed from the IR points |
<wiimote>.getPositionIR(num=-1) |
Returns the position of the specified IR point. If num is -1, the computed screen pointing position of all the IR points is returned. |
<wiimote>.getFoundIR() |
Returns a list of all the currently found IR point positions. |
<wiimote>.state |
Read attribute that returns the current button state of the Wiimote |
<wiimote>.led |
Read/write attribute for the Wiimote LED lights. |
<wiimote>.rumble |
Read/write attribute for the Wiimote rumble pad. |
<wiimote>.accel |
Read attribute for the Wiimote acceleration vector. |
<wiimote>.battery |
Read attribute for the Wiimote battery level. |
<wiimote>.extension |
Read attribute for the current extension type of the Wiimote. |
<wiimote>.numIR |
Read attribute for the number of IR points last detected by the Wiimote |
<wiimote>.angleIR |
Read attribute for the roll angle of the Wiimote computed from the IR points. |
<wiimote>.posIR |
Read attribute for the average position of the IR points. |
<wiimote>.foundIR |
Read attribute for found IR point position list. |
<wiimote>.nunchuk |
Handle to Wiimote Nunchuk sensor. Nunchuk methods are documented below. |
<wiimote>.classic |
Handle to Wiimote Classic Controller sensor. Classic Controller methods are documented below. |
The Wiimote can estimate its pitch/roll angle from the acceleration data. The orientation data from the Wiimote sensor will contain this estimation.
The Wiimote Nunchuk sensor contains the following methods/attributes:
Method |
Description |
<nunchuk>.getConnected() |
Returns whether the Nunchuk is currently connected to the Wiimote. |
<nunchuk>.getAccel() |
Returns the acceleration vector of the Nuncuk. The vector is relative to the Nuncuks local coordinate system. |
<nunchuk>.getDeadZone() |
Returns the [x,y] dead zone of the Nunchuk joystick. |
<nunchuk>.setDeadZone(zone) |
Sets the [x,y] dead zone of the Nunchuk joystick. |
<nunchuk>.position |
Read attribute for the joystick position. |
<nunchuk>.state |
Read attribute for the Nunchuk button state. |
<nunchuk>.connected |
Read attribute for the Nunchuk connection state. |
<nunchuk>.accel |
Read attribute for the Nunchuk acceleration data. |
<nunchuk>.deadZone |
Read/write attribute for the Nunchuk joystick dead zone. |
The Nunchuk orientation data will contain the pitch/roll estimation from its acceleration data. The Nunchuk position data will represent the joystick position.
The Wiimote Classic Controller sensor contains the following methods/attributes:
Method |
Description |
<classic>.getPositionLeft() |
Returns the position of the controllers left joystick. |
<classic>.getPositionRight() |
Returns the position of the controllers right joystick. |
<classic>.getConnected() |
Returns whether the controller is currently connected to the Wiimote. |
<classic>.getDeadZoneLeft() |
Returns the [x,y] dead zone of the controllers left joystick. |
<classic>.setDeadZoneLeft(zone) |
Sets the [x,y] dead zone of the controllers left joystick. |
<classic>.getDeadZoneRight() |
Returns the [x,y] dead zone of the controllers right joystick. |
<classic>.setDeadZoneRight(zone) |
Sets the [x,y] dead zone of the controllers right joystick. |
<classic>.setDeadZone(zone) |
Sets the [x,y] dead zone of the controllers left/right joystick. |
<classic>.getTriggerLeft() |
Returns the analog value of the controllers left trigger. |
<classic>.getTriggerRight() |
Returns the analog value of the controllers right trigger. |
<classic>.state |
Read attribute for the controller button state. |
<classic>.positionL |
Read attribute for the controllers left joystick. |
<classic>.positionR |
Read attribute for the controllers right joystick. |
<classic>.connected |
Read attribute for the controller connection state. |
<classic>.deadZoneL |
Read/write attribute for the controller left joystick dead zone. |
<classic>.deadZoneR |
Read/write attribute for the controller right joystick dead zone. |
<classic>.deadZone |
Read/write attribute for the controller left/right joystick dead zone. |
<classic>.triggerL |
Read attribute for the controller left trigger. |
<classic>.triggerR |
Read attribute for the controller right trigger. |
The Classic Controller position data will represent the joystick position.
The joystick data for the Nunchuk and Classic Controller is normalized between -1 and 1. The dead zone values of the joysticks controls the range of the reported joystick positions. All raw position values between 0 and the dead zone value will be reported as 0. The default value for the dead zones are [0,0], which means the full range of motion will be reported.
The Wiimote button state contains the state of all the Wiimote buttons, including the button state of any extensions. The button state of the extension objects only contains the state of the extension buttons. When a Wiimote generates a viz.SENSOR_DOWN_EVENT or viz.SENSOR_UP_EVENT, the object passed to the event will be the Wiimote sensor, even if the button belongs to an extension.
The following code shows how to connect to the first available Wiimote:
This code snippet shows how to turn on LED 1 and 4 of the Wiimote:
The next piece of code will setup the Wiimote to rumble while the B button is down:
The following code will use the computed IR position and angle to display a pointer on the screen:
This code will rumble the Wiimote for 0.5 seconds whenever a Nunchuk is connected:
*Wiimote plugin and Wiimote plugin description are copyrighted by WorldViz GBR, Germany.