Powered by SmartDoc

WiiFitソスoソスソスソスソスソスXソス{ソス[ソスhソスソスpソスソスソスソスソスuソスIソス[ソスソスソスfソスfソスv(ソスソスソスソスソスHソスネ托ソス)

2009ソスN5ソスソス8ソスソスソスナ終ソスXソスV
ソスソスソスソスナ彦
http://akihiko.shirai.as/projects/WiiRemote/

ソスレ趣ソス

WiiFitソスoソスソスソスソスソスXソス{ソス[ソスhソスソスpソスソスソスソスソスuソスIソス[ソスソスソスfソスfソスv(ソスソスソスソスソスHソスネ托ソス)

ソスuソスIソス[ソスソスソスfソスfソスv

ソスdソスソスソスソスソスソスソス}ソスソスソスソスソスソスソスソスソスソスソスヒ宏ソスソスソスソスソスソスヤ滂ソスソスソスLソスソス

ソスソスソスソスソスHソスネ托ソスwソスRソスソスソスソスソスfソスBソスAソスfソスUソスCソスソスソスソスソスソスソスソス

IMAGINEソス@ソスvソスソスソスOソスソスソス~ソスソスソスOソスソスソスSソスソス4ソスlソスソスソスソスソスソスソスソスuソスIソス[ソスソスソスfソスfソスvソスニゑソスソスソスソスソスihttp://gryng.blog87.fc2.com/blog-entry-15.html

BBOSC

http://456.im/wp/download/bbosc/

ソスSソスJソスソスソスノゑソスソスソスソスソスフ重ソスソス0-10000ソスノスソスPソス[ソスソスソスソスソスト托ソスソスMソスソスソストゑソスソスソスワゑソスソスB

ソスEソスソスAソスEソスソスソスAソスソスソスソスAソスソスソスソスソスフ4ソスJソスソスソスフ値ソスソスソスソスソスソスソスワゑソスソスソスソスAソスソスソスフままでは使ソスソスソスノゑソスソスソスソスフゑソスXソスソスYソスフ2ソスlソスノ変奇ソスソスソスソスワゑソスソスBソスiソスソスソスフスソスソスソスCソスhソスj

ソスyソスIソス[ソスソスソスフ描ソスソスz

ソスlソスフ輪郭ソスノゑソスソスソスソスト鯉ソスソスソスソスoソスソスソスdソスSソスフ擾ソスソスソスソスソスソスソスParticleソスフ色ソスソスソスソスソス゚て、ソスlソスフ趣ソスソスソスノ費ソスホゑソスソスソスソスフ難ソスツゑソスgソスン搾ソスソスせソストオソス[ソスソスソスフ描ソスソスニゑソスソストゑソスソスワゑソスソスB

ソスyソスIソス[ソスソスソスフ診ソスfソスzソスlソスフ重ソスSソスヘ擾ソスノ難ソスソスソスソストゑソスソスソスフで、ソスソスソスフ人ソスフ重ソスSソスフ標ソスソスソスソスソスソスソス゚まゑソスソスB

ソスソスソスbソスフ費ソスソス闔橸ソスヤゑソスンゑソスソスト、ソスdソスSソスフ位置ソス足ゑソスソスト包ソスソスマゑソスソスoソスソスソスワゑソスソスソスソスB

ソスソスソスマの位置ソスソスソスOソスノゑソスソス驍ゥソスソスソスノゑソスソス驍ゥソスAソスEソスノゑソスソス驍ゥソスソスソスノゑソスソス驍ゥソスニゑソスソスソスソスソスソスソスソスソスソスナゑソスソスソスソスワゑソスソスノ色ソスソスソスソスソス゚、XソスソスYソスフ奇ソスソスソスソスネどで費ソスソスソスソスノ色ソスソスマゑソスソストまゑソスソスBソスソスソスニ再鯉ソスソスソスソスフゑソスソスソスIソス[ソスソスソスfソスfソスフ趣ソスソスソス

ソスoソスソスソスソスソスXWiiソス{ソス[ソスhソスソスソス逑セソスソスソスソスソスソスヘゑソスソスニ繊ソスラなので、ソスソスソスマゑソスソスoソスソスソスソスソスヤゑソスンゑソスソス驍アソスニで再鯉ソスソスソスソスソスソスソスソス゚まゑソスソスソスソスB

ソスソスソスソスソスフオソス[ソスソスソスソスソスソスソストゑソスソスソスニゑソスソスノ、ソスフ重ソスソスソスヌゑソスソス轤ゥソスノゑソスソスソスソスツづゑソスソスソスニ色ソスソスソスソスソスじソスソスマ会ソスソスソスソスワゑソスソスBソスソスソスソスソスソスソスソスソスナまゑソスソスBソスヘゑソスソスソスソス゚ゑソスニオソス[ソスソスソスソスソス蛯ォソスソスソスネゑソスソストゑソスンゑソスソスソスソスナ楽ソスソスソスソスソスI

ソスソスソスソスソスヨゑソスネ具ソスソスソスソスソスソスソスソスソスソストゑソスソスAソスuソスIソス[ソスソスソスvソスニゑソスソスソスソスBソスソスソスネ鯉ソスソスtソスソスソス差ソスソスソスzソスソスソスソスソストゑソスソスソスワゑソスソスB

ソスyソスソスJソスソスソスソスソスニゑソスソスソスzソスソスヤ具ソスJソスソスソスソスソスニゑソスソスがソスAソスJソスソスソスソスソスナ人ソスフ輪郭ソスソスソスニる部ソスソスソスソスソスソスソスソスソスフで、ソス{ソスフ趣ソス|ソスニは外ソスソストゑソスソスワゑソスソスワゑソスソスiソスホ)Wiiソス{ソス[ソスhソスソスソスソスナの具ソスJソスヘ色ソスソスソスソスソス゚るたソス゚のアソスソスソスSソスソスソスYソスソスソスナゑソスソスBソスソスソスマゑソスソスソスソス謔、ソスノゑソスソス驍アソスニで簡単ソスノクソスソスソスAソスナゑソスソスソスソスソスソスソスソスソスフでゑソスソスソスソスcソスB

ソスyソスソスソスpソスソスソスソスソスソスソスCソスuソスソスソスソスソスzoscP5 BBOSCソスニの連ソスgJMyronソスJソスソスソスソスソスフ暦ソスソスpソスニ擾ソスソスソスソスwソスiソスソスソスソスソス@ソスナ人ソスニ背ソスiソス分ゑソスソスソスblobDetectionソスlソスフ輪郭ソスソスソスニるたソス゚に使ソスp

ソスyyoutubeソスzhttp://www.youtube.com/watch?v=3pL3ObUwoA8

BBOSC.png
IMG_4750.JPG
IMG_4757.JPG
list.png
P1040055.JPG
P1070530.JPG
P1070559.JPG
ss101310167.png
ss1013124318.png
ss103820.png
ss104743.png
ss13496.png
ss16422.png
ss9_3.png
connect
import oscP5.*;


/* ソスIソスuソスWソスFソスNソスgソスフ読み搾ソスソスソス
------------------------------*/
OscP5 oscP5;  //OscP5ソスIソスuソスWソスFソスNソスgソスソスソスQソスニゑソスソスソスマ撰ソスソスフ宣言


/* ソスソスソスソスソスニ使ソスソスソストゑソスソスソスソスマ撰ソスソスソスン抵ソス
------------------------------*/
//WiiFit
/*ソスdソスSソスフ位置ソス判別ゑソスソス驍スソス゚の趣ソスソスソス(ソスtソスソスソス[ソスソス)ソスソスソスソスソス驍スソス゚ゑソスintソス^ソスフ変撰ソスtソスソス骭セ*/
int t = 100;
/*ソスdソスSソスフ位置ソスソスソス謫セソスソスソス驍スソス゚ゑソス閾値ソスソスソスソスソス驍スソス゚ゑソスintソス^ソスフ変撰ソスthresholdソスソス骭セ*/
int threshold = 4000;
/*閾値ソス超ゑソスソスソスソスロのカソスEソスソスソスgソスソスソスソスソス驍スソス゚ゑソスintソス^ソスフ配ソスソスcソスソス骭セ*/
int [] c;
int [] balanceData;
float wbx, wby = 0.0;
int ac = 100;
int aspeed = 10;


/*--------------------------------------------------*
  setup (ソスナ擾ソスソスノ1ソスだゑソスソスソスソスsソスソスソスソスソス)
 *--------------------------------------------------*/
void setup(){
  //ソスソスソスネ擾ソスソスハゑソスフ奇ソス{ソスン抵ソス
  background(0);           //ソスwソスiソスヘ搾ソス
  frameRate(30);
  size(320, 240);
  smooth();
  
  //WiiFit
  oscP5 = new OscP5(this, 9000);ソス@//OSCソスfソス[ソス^ソスソスソスけ趣ソスソス|ソス[ソスgソスヤ搾ソスソスソスン定すソスソス
  c = new int[4];
  balanceData = new int[4];ソス@//WiiFitソスソスソスソスフデソス[ソス^ソスソスソスSソスモ擾ソスソスソスソスiソス[ソスソスソスソス
 }


 /*--------------------------------------------------*
  draw
 *--------------------------------------------------*/
void draw(){
ソスiソスソスソスソスソスj
}


 /*--------------------------------------------------*
  WiiFit
 *--------------------------------------------------*/
/* oscソスソスソスbソスZソス[ソスWソスソスソスソスMソスソスソスソス*/
void oscEvent(OscMessage theOscMessage){
//Wii balance boardソスフ値ソスソスソスソスソス驍スソス゚ゑソスintソス^ソスフ配ソスソスbalanceDataソスソス骭セ
//ソスzソスソスフ番搾ソスソスニ上下ソスソスソスEソスフセソスソスソスTソス[ソスフ対会ソスソスヨ係ソスヘ、
//0:ソスEソスソスA1:ソスEソスソスソスA2:ソスソスソスソスA3:ソスソスソスソス
  if(theOscMessage.checkAddrPattern("/data")==true){
    if(theOscMessage.checkTypetag("iiii")) {
      for(int i =0;i <4;i++){
        /*OscソスフソスソスbソスZソス[ソスWソスソスbalanceDataソスノ格ソス[ソスソスソスソス*/
        balanceData[i] = theOscMessage.get(i).intValue();
      }
    }
  }
}
aura_check
/*--------------------------------------------------*
  draw
 *--------------------------------------------------*/
void draw(){
  
  commonAction();
  
  switch(step){
    
    case 0:
      checkAura();
      break;
      
    case 1:
      drawAura();
      break;
      
    case 2:
      standby();
      break;
  }

}

ソスiソスソスソスソスソスj

/*--------------------------------------------------*
  check aura
 *--------------------------------------------------*/
void checkAura(){
  
  //ソスメゑソスソスけ会ソスハ表ソスソス
  image(checkImg, 0, 0);
  
  //200ソスtソスソスソス[ソスソスソスフ間包ソスソスマ値ソスソスソスoソスソスソスソスソス゚に体重ソス足ゑソス
  if( checkCnt < 200 ){
    checkCnt ++;
    
    perSum[0] += balanceData[0];
    perSum[1] += balanceData[1];
    perSum[2] += balanceData[2];
    perSum[3] += balanceData[3];
    
  }
  
  if( checkCnt == 200 ){
    
    perXY();
    colorSet();
    step = 1;
    checkCnt = 0;
   
    //ソスpソス[ソスeソスBソスNソスソス
    for(int i=0;i<pNum;i++){
      p[i].reset(i);
    }
    
  }
  
  //ソスメゑソスソスけフソスソスソスbソスO
if( balanceData[0]<150 && balanceData[1]<150 && balanceData[2]<150 && \
    balanceData[3]<150 ){
    checkCnt = 0;
    step = 2;
  }
  
}

ソスiソスソスソスソスソスj

void colorSet(){
  println(perSum);
  
  if( perSum[0]+perSum[2] > perSum[1]+perSum[3] ){
    
percc[0] = 225 + (30 * (perSum[0]+perSum[2])/2 / \
    (perSum[0]+perSum[1]+perSum[2]+perSum[3]));
    
    if( perSum[0]+perSum[1] > perSum[2]+perSum[3] ){
      
      percc[1] = 150 * perSum[3] / (perSum[0]+perSum[1]+perSum[2]);
      percc[2] = 255 * perSum[1] / (perSum[0]+perSum[3]+perSum[2]);
      
    } else {
      
      percc[1] = 255 * perSum[3] / (perSum[0]+perSum[1]+perSum[2]);
      percc[2] = 150 * perSum[1] / (perSum[0]+perSum[3]+perSum[2]);
      
    }
    
  } else if( perSum[3] > perSum[1] ){
    
percc[1] = 225 + (30 * perSum[3] / \
    (perSum[0]+perSum[1]+perSum[2]+perSum[3]));
    
    if( (perSum[0]+perSum[2])/2 > perSum[1] ){
      
percc[0] = 255 * (perSum[0]+perSum[2])/2 / \
    ((perSum[0]+perSum[2])/2+perSum[1]+perSum[3]);
      percc[2] = 150 * perSum[1] / (perSum[0]+perSum[3]+perSum[2]);
      
    } else {
      
percc[0] = 150 * (perSum[0]+perSum[2])/2 / \
    ((perSum[0]+perSum[2])/2+perSum[1]+perSum[3]);
      percc[2] = 255 * perSum[1] / (perSum[0]+perSum[3]+perSum[2]);
      
    }
    
  } else {
    
percc[2] = 225 + (30 * perSum[1] / \
    (perSum[0]+perSum[1]+perSum[2]+perSum[3]));
    
    if( (perSum[0]+perSum[2])/2 > perSum[3] ){
      
percc[0] = 255 * (perSum[0]+perSum[2])/2 / \
    ((perSum[0]+perSum[2])/2+perSum[1]+perSum[3]);
      percc[1] = 150 * perSum[3] / (perSum[0]+perSum[1]+perSum[2]);
      
    } else {
      
percc[0] = 150 * (perSum[0]+perSum[2])/2 / \
    ((perSum[0]+perSum[2])/2+perSum[1]+perSum[3]);
      percc[1] = 255 * perSum[3] / (perSum[0]+perSum[1]+perSum[2]);
      
    }
  }
  
  cc[0] = percc[0];
  cc[1] = percc[1];
  cc[2] = percc[2];
  
  println("color:");
  println(cc);

}

ソスソスSecondLifeソスソスWiiRemoteソスナ托ソスソスすソスソス

VRソスEソスソスソス^ソスoソス[ソスXソスニゑソスソスソスソスホ「SecondLifeソスvソスナゑソスソスソスソスAGlovePIEソスソスソスgソスソスソスホ、WiiRemoteソスナ托ソスソスすソス驍アソスニゑソスソスツ能ソスノなゑソスワゑソスソスBソスIソスソスソスWソスiソスソスソスヘ「Google Earthソスvソスソスソスxソス[ソスXソスノ、ソスソスsソスソスwソスソスソスソスソスフ渡邉英ソスソスソス謳カソスソスソス成ソスソスソストゑソスソスソスワゑソスソスソスソスフで紹介しソスワゑソスソスB

//Calibrate your Wiimote!
//Place the Wiimote face up on a flat surface. Change these values until \
    the
//debug line next to the run button shows zero for each axis.
var.xtrim = -7
var.ytrim = -20
var.ztrim = -4

//Set your Wiimote LEDs to your liking. Binary value, 1-15
Wiimote.Leds = 1

//Key Map
Mouse.LeftButton = Wiimote.A
Keyboard.ESC = Wiimote.Home
Keyboard.ESC = Wiimote.One
Keyboard.Up = Wiimote.Up
Keyboard.Down = Wiimote.Down
Keyboard.Left = Wiimote.Left
Keyboard.Right = Wiimote.Right
//Keyboard.F = Wiimote.Home
Keyboard.E = Wiimote.Plus
Keyboard.C = Wiimote.Minus

//Forward, Back, Up and Down

if Wiimote.B & Wiimote.Up Then
KeyBoard.Up = False
Keyboard.E = True
Wait 600ms
Keyboard.E = False
endif

if Wiimote.B & Wiimote.Down Then
KeyBoard.Down = False
Keyboard.C = True
Wait 600ms
Keyboard.C = False
endif

var.accx = Wiimote.RawForceX + var.xtrim
var.accy = Wiimote.RawForceY + var.ytrim
var.accz = Wiimote.RawForceZ + var.ztrim

                                                     // My best IR
Mouse Script, with 5DOF Tracking
// By Carl Kenner

// Change these values:
var.SensorBarSeparation = 7.5 inches  // distance between middles of
two sensor bar dots
var.NoYawAllowed = true  // Calculates X if no yaw is allowed,
otherwise calculates Yaw but not X
var.IRMulX = 1.2
var.IRMulY = 1.2
var.IROffsetX = 0  // add to mouse.x
var.IROffsetY = 0  // add to mouse.y
var.IRLeftButton = Wiimote.A
var.IRRightButton = Wiimote.B


// Compensate for roll
var.c = cos(Smooth(wiimote.roll, 10))
var.s = sin(Smooth(wiimote.roll, 10))
if wiimote.dot1vis then
  var.dot1x = var.c*(511.5-wiimote.dot1x)/511.5 -
var.s*(wiimote.dot1y-383.5)/511.5
  var.dot1y = var.s*(511.5-wiimote.dot1x)/511.5 +
var.c*(wiimote.dot1y-383.5)/511.5
end if
if wiimote.dot2vis then
  var.dot2x = var.c*(511.5-wiimote.dot2x)/511.5 -
var.s*(wiimote.dot2y-383.5)/511.5
  var.dot2y = var.s*(511.5-wiimote.dot2x)/511.5 +
var.c*(wiimote.dot2y-383.5)/511.5
end if

// if both dots are visible check which is which and how far apart
if wiimote.dot1vis and wiimote.dot2vis then
  if var.dot1x <= var.dot2x then
    var.leftdot = 1
    var.dotdeltay = var.dot2y - var.dot1y
  else
    var.leftdot = 2
    var.dotdeltay = var.dot1y - var.dot2y
  end if
  var.dotdeltax = abs(var.dot1x-var.dot2x)
  var.DotSep = hypot(var.dotdeltax, var.dotdeltay) * 511.5
  var.IRDistance = var.SensorBarSeparation * 1320 / var.DotSep
end if

// sort out the position of the left and right dots
if var.leftdot = 1 then
  if wiimote.dot1vis and wiimote.dot2vis then
    var.LeftDotX = var.dot1x
    var.LeftDotY = var.dot1y
    var.LeftDotVis = true
    var.RightDotX = var.dot2x
    var.RightDotY = var.dot2y
    var.RightDotVis = true
  else if wiimote.dot1vis then
    if hypot(var.leftdotx-var.dot1x,var.leftdoty-var.dot1y) <=
hypot(var.rightdotx-var.dot1x,var.rightdoty-var.dot1y) then
      // is the real dot 1
      var.LeftDotX = var.dot1x
      var.LeftDotY = var.dot1y
      var.RightDotX = var.dot1x + var.dotdeltax
      var.RightDotY = var.dot1y + var.dotdeltay
      var.LeftDotVis = true
      var.RightDotVis = false
    else
      // was originally dot 2, but now called dot 1.
      var.leftdot = 2 // this dot (1) is actually the right dot
      var.LeftDotX = var.dot1x - var.dotdeltax
      var.LeftDotY = var.dot1y - var.dotdeltay
      var.RightDotX = var.dot1x
      var.RightDotY = var.dot1y
      var.RightDotVis = true
      var.LeftDotVis = false
    end if
  else if wiimote.dot2vis then
    var.LeftDotX = var.dot2x - var.dotdeltax
    var.LeftDotY = var.dot2y - var.dotdeltay
    var.RightDotX = var.dot2x
    var.RightDotY = var.dot2y
    var.RightDotVis = true
    var.LeftDotVis = false
  end if
else if var.leftdot = 2 then
  if wiimote.dot1vis and wiimote.dot2vis then
    var.LeftDotX = var.dot2x
    var.LeftDotY = var.dot2y
    var.LeftDotVis = true
    var.RightDotX = var.dot1x
    var.RightDotY = var.dot1y
    var.RightDotVis = true
  else if wiimote.dot1vis then
    if hypot(var.leftdotx-var.dot1x,var.leftdoty-var.dot1y) <=
hypot(var.rightdotx-var.dot1x,var.rightdoty-var.dot1y) then
      var.leftdot = 1 // dot 1 is now the left dot
      var.LeftDotX = var.dot1x
      var.LeftDotY = var.dot1y
      var.RightDotX = var.dot1x + var.dotdeltax
      var.RightDotY = var.dot1y + var.dotdeltay
      var.LeftDotVis = true
      var.RightDotVis = false
    else
      // the real dot 1 (on the right)
      var.LeftDotX = var.dot1x - var.dotdeltax
      var.LeftDotY = var.dot1y - var.dotdeltay
      var.RightDotX = var.dot1x
      var.RightDotY = var.dot1y
      var.RightDotVis = true
      var.LeftDotVis = false
    end if
  else if wiimote.dot2vis then
    var.RightDotX = var.dot2x + var.dotdeltax
    var.RightDotY = var.dot2y + var.dotdeltay
    var.LeftDotX = var.dot2x
    var.LeftDotY = var.dot2y
    var.LeftDotVis = true
    var.RightDotVis = false
  end if
else
  var.LeftDotX = var.dot1x
  var.LeftDotY = var.dot1y
  var.RightDotX = var.LeftDotX
  var.RightDotY = var.LeftDotY
  var.LeftDotVis = true
  var.RightDotVis = true
end if


// Find the imaginary middle dot
var.MiddleDotX = (var.leftdotx + var.rightdotx)/2
var.MiddleDotY = (var.leftdoty + var.rightdoty)/2
var.MiddleDotVis = wiimote.dot1vis or wiimote.dot2vis

if var.MiddleDotVis then
  var.TotalPitch = atan2(511.5*var.MiddleDotY,1320) + Wiimote.Pitch
  var.DotYaw = atan2(-511.5*var.MiddleDotX,1320) // assume yaw is 0
  var.WiimoteYawNoX = atan2(511.5*var.MiddleDotX,1320)
  var.WiimoteXNoYaw = -sin(var.dotyaw)*var.IRDistance
  var.WiimoteY = -sin(var.totalpitch)*var.IRDistance
  var.WiimoteZ = (-sqrt(sqr(var.IRDistance) -
sqr(var.WiimoteY)))*var.IRDistance/RemoveUnits(var.IRDistance)
end if

// scale it to the screen range 0 to 1
var.IRx = var.IRMulX*var.middledotx/2 + 0.5
var.IRy = var.IRMulY*var.middledoty*1023/767/2 + 0.5
var.IRvis = wiimote.dot1vis or wiimote.dot2vis
var.IROnScreen = 0 <= var.IRx <= 1  and  0 <= var.IRy <= 1

// is it off the screen?
var.IRTooFarLeft = var.IRx < 0 or (var.IRx < 0.1 and (not var.IRvis))
var.IRTooFarRight = var.IRx > 1 or (var.IRx > 1-0.1 and (not var.IRvis))
var.IRTooFarUp = var.IRy < 0 or (var.IRy < 0.1 and (not var.IRvis))
var.IRTooFarDown = var.IRy > 1 or (var.IRy > 1-0.1 and (not var.IRvis))

// Heavily smooth small movements, but do zero lag for quick movements
var.MoveAmount = 1024*hypot(delta(var.IRx), delta(var.IRy))
if smooth(var.MoveAmount) > 12 then
  var.SmoothX = var.IRx
  var.SmoothY = var.IRy
  var.LastSureFrame = PIE.Frame
else if (PIE.frame-var.LastSureFrame) > 18 then
  var.SmoothX = Smooth(var.IRx, 18, 4/1024)
  var.SmoothY = Smooth(var.IRy, 18, 4/1024)
else if (PIE.frame-var.LastSureFrame) > 14 then
  var.SmoothX = Smooth(var.IRx, 14, 4/1024)
  var.SmoothY = Smooth(var.IRy, 14, 4/1024)
else if (PIE.frame-var.LastSureFrame) > 10 then
  var.SmoothX = Smooth(var.IRx, 10, 4/1024)
  var.SmoothY = Smooth(var.IRy, 10, 4/1024)
else if (PIE.frame-var.LastSureFrame) > 6 then
  var.SmoothX = Smooth(var.IRx, 6, 4/1024)
  var.SmoothY = Smooth(var.IRy, 6, 4/1024)
else if (PIE.frame-var.LastSureFrame) > 2 then
  var.SmoothX = Smooth(var.IRx, 2, 4/1024)
  var.SmoothY = Smooth(var.IRy, 2, 4/1024)
end if

// Freeze the mouse cursor while they start pressing the button
// otherwise it will make the cursor jump
var.Freeze = (var.IRLeftButton or var.IRRightButton) and
KeepDown(pressed(var.IRLeftButton) or pressed(var.IRRightButton),
600ms)

// Only change the mouse position if pointing at the screen
// otherwise they can still use a real mouse
if var.IRvis and (not var.Freeze) then
  mouse.x = var.SmoothX
  mouse.y = var.SmoothY
end if

// delay the buttons slightly so we have time to freeze the cursor (is
that needed?)
//mouse.LeftButton = var.IRLeftButton and (not
KeepDown(pressed(var.IRLeftButton), 40ms))
//mouse.RightButton = var.IRRightButton and (not
KeepDown(pressed(var.IRRightButton), 40ms))

// display 6DOF data
if var.NoYawAllowed then
  debug = 'X: '+var.WiimoteXNoYaw+',  Y: '+var.WiimoteY+',  Z:
'+var.WiimoteZ+',    Yaw: 0,  Pitch: '+Wiimote.Pitch+',  Roll:
'+Wiimote.Roll
else
  debug = 'X: 0,  Y: '+var.WiimoteY+',  Z: '+var.WiimoteZ+',    Yaw:
'+var.WiimoteYawNoX+',  Pitch: '+Wiimote.Pitch+',  Roll:
'+Wiimote.Roll
endif


//Debug
if Wiimote.Up
   var.Button = "Up"
elseif Wiimote.Down
   var.Button = "Down"
elseif wiimote.Left
   var.Button = "Left"
else if wiimote.Right
   var.Button = "Right"
elseif wiimote.A and not wiimote.B
   var.Button = "A"
elseif wiimote.B and not wiimote.A
   var.button = "B"
elseif wiimote.A and wiimote.B
   var.button = "A + B"
elseif wiimote.Home
   var.button = "Home"
elseif wiimote.Plus
   var.button = "Plus"
elseif wiimote.Minus
   var.button = "Minus"
else
   var.button = ""
endif

debug = "x:" + var.accx + ", y:" + var.accy + ", z:" + var.accz + " "
+ var.Button