Wii Paint

After getting my Wii remote hooked up with the WiiFlash Server, I knocked up this quick Flash demo which draws the blobs of infrared light the Wii remote detects (it can track up to 4 blobs at once), just like the Wii console’s sensitivity setting dialog does. I just gave each blob a different colour and clear the graphics on pressing the ‘A’ button.

Here’s the code to get it working – requires WiiFlash Server:

import org.wiiflash.Wiimote;
import org.wiiflash.IR;
import org.wiiflash.events.ButtonEvent;
import org.wiiflash.events.WiimoteEvent;
import flash.events.*;

var myWiimote:Wiimote = new Wiimote();
myWiimote.connect();myWiimote.addEventListener(WiimoteEvent.UPDATE, onUpdated);
myWiimote.addEventListener(ButtonEvent.A_PRESS, onAPressed);

function onUpdated (pEvt:WiimoteEvent):void {
var ir:IR = pEvt.target.ir;
var irWidth:Number = 400;
var irHeight:Number = 400;
var irSize:Number = 4;
if (ir.p1) drawCircle(ir.x1*irWidth, ir.y1*irHeight, ir.size1*irSize, 0xff0000);
if (ir.p2) drawCircle(ir.x2*irWidth, ir.y2*irHeight, ir.size2*irSize, 0x00ff00);
if (ir.p3) drawCircle(ir.x3*irWidth, ir.y3*irHeight, ir.size3*irSize, 0x0000ff);
if (ir.p4) drawCircle(ir.x4*irWidth, ir.y4*irHeight, ir.size4*irSize, 0xffff00);

function onAPressed (pEvt:ButtonEvent):void {
pEvt.target.rumbleTimeout = 50;

function drawCircle (x:Number, y:Number, size:Number, colour:Number=0xffffff):void {
graphics.beginFill(colour, .2);

2 thoughts on “Wii Paint”

  1. Hey Liam,

    Just been checking out your site; really great stuff man. I love this experiment too! Haven’t had a chance to play with interfacing the wii remote, but this’ll get me started, so thank you. And good luck with the interactive stuff (re. your comment on my blog). It’s all new to me too 🙂

  2. Hello,

    Great experiment, thanks for the code. Trying to make it work and use it in theater, I truly think this can be put to great use. Keep the good “things” coming.

    With kind regards,

    Jan Willem

Leave a Reply