Wii media in 15 minutes and $5

At the end of 2007, I became interested in a Wii media lab for designing novel interfaces. To explore the feasibility, Veronica Paredes, Andrea Rodriguez and myself experimented with several user interfaces that use a wiimote. I found several tricks, which if you have done much of this before, then you already know. But if you would like to learn how to experiment with a wiimote, and have a wiimote, a bluetooth-enabled computer, 15 minutes and $5, I'll share what I learned.

You must already own:

To enable bluetooth on my computer, I plugged in a D-Link DBT-120 USB Bluetooth adapter (bluetooth 1.1). This is compatible with BlueSoleil.

You'll need to buy:

Connecting Wiimote to Computer

  1. You'll need to download and install software to connect wiimote by Bluetooth: BlueSoleil (trial version)
  2. I installed IVT_BlueSoleil_5.0_for_32bit_OS.zip.
  3. Reboot computer.
  4. Open Blue
  5. For details see Instructions on connecting to Wii.
  6. These directions produced a joystick, with the properties:
    Device Type:  Nintendo RVL-CNT-01
    Device Address:  00:1A:E9:3F:DB:1E
    
  7. Double-click human interface device HID icon (mouse icon). Dialog Connecting to Nintendo ... appears.
  8. Connect while on wii holding down sync button and 1+2 buttons. If 1+2 button do not sync, then you may need to remove battery cover to press sync button.

Reprogramming Wiimote interface

What makes this so easy is the work by Carl Kenner, GlovePIE, which is a programmable interface emulator. With it you wiimote can appear be about like any standard interface.
  1. Download GlovePIE
    Note to self: Apply Carl Kenner's license restrictions to all my software: '''NOTE! You may not use this software on military bases, or for military purposes, or in Israel (until they end the occupation of Palestine). Violation of the license agreement will be prosecuted. See the readme for the license agreement.'''
  2. Unzip GlovePIE030.zip
  3. For a test case, open GlovePIE. Paste this script.
    Mouse.LeftButton = Wiimote.A
    Mouse.RightButton = Wiimote.B
    
  4. Run the script.
  5. Move mouse to desktop.
  6. On wiimote, click B button to see context menu popup. Click A button to cause context menu to disappear.

Infrared LED

Wiimote has a camera on the front which sees near infrared. For fine-grain manipulation, the wiimote must see infrared points. Verify that your LEDs are emitting infrared.
  1. Turn on your wii in a dim or dark room.
  2. Point your digital camera at the front of the sensor bar. You will see five lights on each side, one for each LED. Digital cameras pick up near infrared. Take a picture.
  3. Get your infrared LED and button battery to test.
  4. Attach cathode (long, flat end) of infrared LED to flat side of battery. Squeeze metal to battery.
  5. Point digital camera at front of LED. Take a picture. You should see an indigo light.
  6. Open GlovePIE. Find and run IRmouse.PIE. Point wiimote at sensor bar (while wii is on). Verify cursor movement with wii sensor bar. Then use your own infrared LED to verify cursor movement. (If you invert the direction of the mouse movement in the script then you can move the infrared LED to act as a mouse.)

Now you're ready to begin experimenting with the wii. GlovePIE includes documentation and auto-complete when scripting. It is by far the easiest scripting environment I have used. It is also robust, supporting all wiimote sensors, nunchuk, a crude 3D renderer, math library, MIDI playback, text-to-speech, and export to Open Sound Control (OSC). This is all described in the GlovePIE documentation (under the Help menu).

Common activities

Oftentimes you'll want to verify which wiimote is which and if they are connecting. Here is a trivial test:
// Trivial test of connectivity and identity.
Wiimote.Led1 = true
Wiimote2.Led2 = true
Wiimote3.Led3 = true
Wiimote4.Led4 = true
Visualize a variable. Oftentimes you'll want to see what the data is, in a mode easier to understand than a debug message. I represent a gauge of three values to side-by-side to calibrate sensitivity. Here is a script.

What is it good for?

Besides the technical configuration, there are are design considerations. The wiimote is versatile, yet some activities are more usable than others. Veronica, Andrea, and I made the following notes on use of an interace scripted in GlovePIE.

One fairly comprehensive test of GlovePIE is a "MIDI clock" that Veronica, Andrea and myself designed. It demonstrates acceleration sensing, 3D visualization, MIDI playblack, and can be configured for text-to-speech. Here is the GlovePIE script. With additional scripts, multiple wiimotes can be connected (2, 3, and 4).

GlovePIE is not a programming environment (it does not support user-defined functions), and slowed down with complex operations. For that, I exported the necessary wii data to OSC and then used SimpleOSC capture the data every frame in a Python application.

For example, in the one-week project, I drove a virtual lever in an ODE physics simulation, by a physical lever with a wiimote strapped to it. Here is the GlovePIE script:

/*
Control OSC roll object by roll of wiimote.
*/

var.debug = true

// OSC
Osc1.port = 9001
Osc1.ip = "127.0.0.1"
Osc1.broadcast = true

Wiimote.Led1 = true

// - roll sticks
var.angle = wiimote.Roll//Smooth( wiimote.Roll, 10 )
// - pitch Sticks.
//var.value = Smooth( wiimote.Pitch, 5 )

Osc1.angle = var.angle

if var.debug == true then
  debug = 'angle: ' + var.angle + '   battery: ' + Wiimote.Battery + '/255.00'

  obj.Size = [1,0.05,0.05] m
  obj.roll = var.angle
  obj2.CubeSize = 0.1 m

  camera.z = -2 m
endif

And here is the Python script that got the angle, using SimpleOSC module.

import osc

def osc_init(self):
    osc.init()
    self.osc_socket = osc.createListener('127.0.0.1', 9001) 
    osc.bind(self.set_target_angle_to_osc, "/angle")
    # osc.bind(osc_test.printStuff, "/angle") # DEBUG

def set_target_angle_to_osc(self, *msg):
    self.target_angle = msg[0][2]

def update_osc(self):
    if hasattr(self, 'osc_socket') and self.osc_socket:
        osc.getOSC(self.osc_socket)

Wiimote can control Windows Media Player. An included script does this. But the control is sluggish, because Windows Media Player is sluggish.

Wiimote can remap to just about any application. It can, for example, be used to paint in Photoshop with an IRmouse. However, the software is not optimized for this control remap and the IR mouse is somewhat shaky.

It's fun to use the wiimote like a rattler that creates speech. For example:

// text to speech test.

if wiimote.RelAccX <= -10 m per s per s
  Say("Wii Wii We Wo Wa Wow Whoa")
  //Say("Hello world")
endif

if wiimote.RelAccY <= -10 m per s per s
  Say("Woooooooooooo")
  //Say("Hello world")
endif

if wiimote.RelAccZ <= -10 m per s per s
  Say("Waaaaaaaaaaaaaaaa")
  //Say("Hello world")
endif

The camera only has a viewing angle of about 45 degrees. Furthermore the LED on has an emission angle of about 45 degrees, so wide ranges movement, such as swinging your arm or holding a stylus at various angles are not received. This hampered the use of a chopstick interface, because two wiimotes are used for triangulation, and the volume that contains the chopsticks is constrained, as are the angles at which the chopsticks can be held.

Another simple example is by Alex Schreyer, who maps Wiimote input to Google SketchUp commands.