-Wiimote1.led1 = true\r
-Wiimote2.led1 = true\r
-Wiimote2.led4 = true\r
-Wiimote3.led2 = true\r
-Wiimote4.led2 = true\r
-Wiimote4.led4 = true\r
-Wiimote5.led3 = true\r
-Wiimote6.led3 = true\r
-Wiimote6.led4 = true\r
-//Mouse Control Script using IR\r
-//by vkapadia with much assistance from inio\r
-//vkapadia@vkapadia.com\r
-//\r
-//Calibration:\r
-//To calibrate, run this program and put the Wiimote on a flat surface face-up.\r
-//Then read the values in the debug line (next to the run button).\r
-//Change these values until the debug line reads approx. all zeros.\r
-var.xtrim1 = -1\r
-var.ytrim1 = -25\r
-var.ztrim1 = 2\r
-\r
-var.xtrim2 = 3\r
-var.ytrim2 = -30\r
-var.ztrim2 = 2\r
-\r
-var.xtrim3 = 2\r
-var.ytrim3 = -27\r
-var.ztrim3 = 2\r
-\r
-var.xtrim4 = 2\r
-var.ytrim4 = -30\r
-var.ztrim4 = 2\r
-\r
-var.coeff = 0.1\r
-\r
-//\r
-//Options:\r
-var.deadzone = 5 //distance in pixels that you have to move the wiimote in\r
- //order for it to register movement. Creates a "dead zone" around the pointer\r
- //to make it easier to click. Higher = smoother but less accurate.\r
-//fake cursor init\r
-\r
-//cursor2.visible = true\r
-\r
-//more options to be added later\r
-\r
-//Controls:\r
-//Point Wiimote = Move Mouse\r
-//D-Pad = Arrow Keys\r
-//B-Button = Left Click\r
-//Home = Middle Click\r
-//A-Button = Right Click\r
-//Plus and Minus = Control Volume\r
-//One = Unmapped\r
-//Two = Unmapped\r
-//\r
-//If the pointer hits the edge of the screen, the Wiimote will rumble a bit.\r
-//\r
-//The LEDs attempt to emulate KITT's grill from Knight Rider\r
-\r
-//WIIMOTE 1\r
-//***Do not edit anything below this line unless you know what you are doing.***\r
-var.accx1 = wiimote1.RawForceX + var.xtrim1\r
-var.accy1 = wiimote1.RawForceY + var.ytrim1\r
-var.accz1 = wiimote1.RawForceZ + var.ztrim1\r
-\r
-if wiimote1.dot1vis and wiimote1.dot2vis then\r
-\r
- if var.accy1 > -7 then\r
- var.orientation1 = 0\r
- elseif var.accy1 > -45 then\r
- if var.accx1 < 0 then\r
- var.orientation1 = 3\r
- else\r
- var.orientation1 = 1\r
- endif\r
- else\r
- var.orientation1 = 2\r
- endif\r
-\r
- if var.leftpoint1 = 0 then\r
- if var.orientation1 = 0 then\r
- if wiimote1.dot1x < wiimote1.dot2x then\r
- var.leftpoint1 = 1\r
- else\r
- var.leftpoint1 = 2\r
- endif\r
- endif\r
- if var.orientation1 = 1 then\r
- if wiimote1.dot1y > wiimote1.dot2y then\r
- var.leftpoint1 = 1\r
- else\r
- var.leftpoint1 = 2\r
- endif\r
- endif\r
- if var.orientation1 = 2 then\r
- if wiimote1.dot1x > wiimote1.dot2x then\r
- var.leftpoint1 = 1\r
- else\r
- var.leftpoint1 = 2\r
- endif\r
- endif\r
- if var.orientation1 = 3 then\r
- if wiimote1.dot1y < wiimote1.dot2y then\r
- var.leftpoint1 = 1\r
- else\r
- var.leftpoint1 = 2\r
- endif\r
- endif\r
- endif\r
-\r
- if var.leftpoint1 = 1 then\r
- var.fix1x1 = wiimote1.dot1x\r
- var.fix1y1 = wiimote1.dot1y\r
- var.fix2x1 = wiimote1.dot2x\r
- var.fix2y1 = wiimote1.dot2y\r
- else\r
- var.fix1x1 = wiimote1.dot2x\r
- var.fix1y1 = wiimote1.dot2y\r
- var.fix2x1 = wiimote1.dot1x\r
- var.fix2y1 = wiimote1.dot1y\r
- endif\r
-\r
- var.dx1 = var.fix2x1 - var.fix1x1\r
- var.dy1 = var.fix2y1 - var.fix1y1\r
- var.cx1 = (var.fix1x1+var.fix2x1)/1024.0 - 1\r
- var.cy1 = (var.fix1y1+var.fix2y1)/1024.0 - .75\r
-\r
- var.d1 = sqrt(var.dx1*var.dx1+var.dy1*var.dy1)\r
-\r
- var.dx1 = var.dx1 / var.d1\r
- var.dy1 = var.dy1 / var.d1\r
-\r
- var.ox1 = -var.dy1*var.cy1-var.dx1*var.cx1;\r
- var.oy1 = -var.dx1*var.cy1+var.dy1*var.cx1;\r
-\r
- var.ax1 = (var.ox1 * var.coeff*screen.desktopwidth) + (screen.desktopwidth* var.coeff / 2)\r
- var.ay1 = (-var.oy1* var.coeff * screen.desktopwidth) + (screen.desktopheight* var.coeff / 2)\r
-\r
- var.dx1 = var.ax1 - cursor2.posx\r
- var.dy1 = var.ay1 - cursor2.posy\r
-\r
- var.d1 = sqrt((var.dx1*var.dx1)+(var.dy1*var.dy1))\r
-\r
- var.a1 = 180 / (200 + var.d1 * var.d1 * var.d1 * .001)\r
-\r
- if var.d1 <= var.deadzone then var.a1 = 1\r
-\r
- //debug = var.d + " " + var.a\r
-\r
- var.finalx1 = cursor2.posx * var.a1 + var.ax1 * (1 - var.a1)\r
- var.finaly1 = cursor2.posy * var.a1 + var.ay1 * (1 - var.a1)\r
-\r
-\r
- cursor2.posx = smooth(var.finalx1,3,5)\r
- cursor2.posy = smooth(var.finaly1,3,5)\r
-\r
-else\r
-\r
- var.leftpoint1 = 0\r
-\r
-endif\r
-\r
-var.xpos1 = var.finalx1\r
-var.ypos1 = var.finaly1\r
-ppjoy1.analog0 = ensuremaprange(var.xpos1,0,screen.desktopwidth* var.coeff,-1,1)\r
-ppjoy1.analog1 = ensuremaprange(var.ypos1,0,screen.desktopheight* var.coeff,-1,1)\r
-\r
-if wiimote1.B or wiimote1.A or wiimote1.Up or wiimote1.down or wiimote1.Left or wiimote1.Right == true\r
- ppjoy1.digital0 = true\r
-else\r
- ppjoy1.digital0 = false\r
-endif\r
-\r
-//WIIMOTE 2\r
-//***Do not edit anything below this line unless you know what you are doing.***\r
-var.accx2 = wiimote2.RawForceX + var.xtrim2\r
-var.accy2 = wiimote2.RawForceY + var.ytrim2\r
-var.accz2 = wiimote2.RawForceZ + var.ztrim2\r
-\r
-if wiimote2.dot1vis and wiimote2.dot2vis then\r
-\r
- if var.accy2 > -7 then\r
- var.orientation2 = 0\r
- elseif var.accy2 > -45 then\r
- if var.accx2 < 0 then\r
- var.orientation2 = 3\r
- else\r
- var.orientation2 = 1\r
- endif\r
- else\r
- var.orientation2 = 2\r
- endif\r
-\r
- if var.leftpoint2 = 0 then\r
- if var.orientation2 = 0 then\r
- if wiimote2.dot1x < wiimote2.dot2x then\r
- var.leftpoint2 = 1\r
- else\r
- var.leftpoint2 = 2\r
- endif\r
- endif\r
- if var.orientation2 = 1 then\r
- if wiimote2.dot1y > wiimote2.dot2y then\r
- var.leftpoint2 = 1\r
- else\r
- var.leftpoint2 = 2\r
- endif\r
- endif\r
- if var.orientation2 = 2 then\r
- if wiimote2.dot1x > wiimote2.dot2x then\r
- var.leftpoint2 = 1\r
- else\r
- var.leftpoint2 = 2\r
- endif\r
- endif\r
- if var.orientation2 = 3 then\r
- if wiimote2.dot1y < wiimote2.dot2y then\r
- var.leftpoint2 = 1\r
- else\r
- var.leftpoint2 = 2\r
- endif\r
- endif\r
- endif\r
-\r
- if var.leftpoint2 = 1 then\r
- var.fix1x2 = wiimote2.dot1x\r
- var.fix1y2 = wiimote2.dot1y\r
- var.fix2x2 = wiimote2.dot2x\r
- var.fix2y2 = wiimote2.dot2y\r
- else\r
- var.fix1x2 = wiimote2.dot2x\r
- var.fix1y2 = wiimote2.dot2y\r
- var.fix2x2 = wiimote2.dot1x\r
- var.fix2y2 = wiimote2.dot1y\r
- endif\r
-\r
- var.dx2 = var.fix2x2 - var.fix1x2\r
- var.dy2 = var.fix2y2 - var.fix1y2\r
- var.cx2 = (var.fix1x2+var.fix2x2)/1024.0 - 1\r
- var.cy2 = (var.fix1y2+var.fix2y2)/1024.0 - .75\r
-\r
- var.d2 = sqrt(var.dx2*var.dx2+var.dy2*var.dy2)\r
-\r
- var.dx2 = var.dx2 / var.d2\r
- var.dy2 = var.dy2 / var.d2\r
-\r
- var.ox2 = -var.dy2*var.cy2-var.dx2*var.cx2;\r
- var.oy2 = -var.dx2*var.cy2+var.dy2*var.cx2;\r
-\r
- var.ax2 = (var.ox2 * var.coeff*screen.desktopwidth) + (screen.desktopwidth* var.coeff / 2)\r
- var.ay2 = (-var.oy2* var.coeff * screen.desktopwidth) + (screen.desktopheight* var.coeff / 2)\r
-\r
- var.dx2 = var.ax2 - cursor3.posx\r
- var.dy2 = var.ay2 - cursor3.posy\r
-\r
- var.d2 = sqrt((var.dx2*var.dx2)+(var.dy2*var.dy2))\r
-\r
- var.a2 = 180 / (200 + var.d2 * var.d2 * var.d2 * .001)\r
-\r
- if var.d2 <= var.deadzone then var.a2 = 1\r
-\r
- //debug = var.d + " " + var.a\r
-\r
- var.finalx2 = cursor3.posx * var.a2 + var.ax2 * (1 - var.a2)\r
- var.finaly2 = cursor3.posy * var.a2 + var.ay2 * (1 - var.a2)\r
-\r
-\r
- cursor3.posx = smooth(var.finalx2,3,5)\r
- cursor3.posy = smooth(var.finaly2,3,5)\r
-\r
-else\r
-\r
- var.leftpoint2 = 0\r
-\r
-endif\r
-\r
-var.xpos2 = var.finalx2\r
-var.ypos2 = var.finaly2\r
-ppjoy2.analog0 = ensuremaprange(var.xpos2,0,screen.desktopwidth* var.coeff,-1,1)\r
-ppjoy2.analog1 = ensuremaprange(var.ypos2,0,screen.desktopheight* var.coeff,-1,1)\r
-\r
-if wiimote2.B or wiimote2.A or wiimote2.Up or wiimote2.down or wiimote2.Left or wiimote2.Right == true\r
- ppjoy2.digital0 = true\r
-else\r
- ppjoy2.digital0 = false\r
-endif\r
-\r
-debug = var.accx2+ " " + var.accy2+ " " + var.accz2\r
-\r
-//WIIMOTE 3\r
-//***Do not edit anything below this line unless you know what you are doing.***\r
-var.accx3 = wiimote3.RawForceX + var.xtrim3\r
-var.accy3 = wiimote3.RawForceY + var.ytrim3\r
-var.accz3 = wiimote3.RawForceZ + var.ztrim3\r
-\r
-if wiimote3.dot1vis and wiimote3.dot2vis then\r
-\r
- if var.accy3 > -7 then\r
- var.orientation3 = 0\r
- elseif var.accy3 > -45 then\r
- if var.accx3 < 0 then\r
- var.orientation3 = 3\r
- else\r
- var.orientation3 = 1\r
- endif\r
- else\r
- var.orientation3 = 2\r
- endif\r
-\r
- if var.leftpoint3 = 0 then\r
- if var.orientation3 = 0 then\r
- if wiimote3.dot1x < wiimote3.dot2x then\r
- var.leftpoint3 = 1\r
- else\r
- var.leftpoint3 = 2\r
- endif\r
- endif\r
- if var.orientation3 = 1 then\r
- if wiimote3.dot1y > wiimote3.dot2y then\r
- var.leftpoint3 = 1\r
- else\r
- var.leftpoint3 = 2\r
- endif\r
- endif\r
- if var.orientation3 = 2 then\r
- if wiimote3.dot1x > wiimote3.dot2x then\r
- var.leftpoint3 = 1\r
- else\r
- var.leftpoint3 = 2\r
- endif\r
- endif\r
- if var.orientation3 = 3 then\r
- if wiimote3.dot1y < wiimote3.dot2y then\r
- var.leftpoint3 = 1\r
- else\r
- var.leftpoint3 = 2\r
- endif\r
- endif\r
- endif\r
-\r
- if var.leftpoint3 = 1 then\r
- var.fix1x3 = wiimote3.dot1x\r
- var.fix1y3 = wiimote3.dot1y\r
- var.fix2x3 = wiimote3.dot2x\r
- var.fix2y3 = wiimote3.dot2y\r
- else\r
- var.fix1x3 = wiimote3.dot2x\r
- var.fix1y3 = wiimote3.dot2y\r
- var.fix2x3 = wiimote3.dot1x\r
- var.fix2y3 = wiimote3.dot1y\r
- endif\r
-\r
- var.dx3 = var.fix2x3 - var.fix1x3\r
- var.dy3 = var.fix2y3 - var.fix1y3\r
- var.cx3 = (var.fix1x3+var.fix2x3)/1024.0 - 1\r
- var.cy3 = (var.fix1y3+var.fix2y3)/1024.0 - .75\r
-\r
- var.d3 = sqrt(var.dx3*var.dx3+var.dy3*var.dy3)\r
-\r
- var.dx3 = var.dx3 / var.d3\r
- var.dy3 = var.dy3 / var.d3\r
-\r
- var.ox3 = -var.dy3*var.cy3-var.dx3*var.cx3;\r
- var.oy3 = -var.dx3*var.cy3+var.dy3*var.cx3;\r
-\r
- var.ax3 = (var.ox3 * var.coeff*screen.desktopwidth) + (screen.desktopwidth* var.coeff / 2)\r
- var.ay3 = (-var.oy3* var.coeff * screen.desktopwidth) + (screen.desktopheight* var.coeff / 2)\r
-\r
- var.dx3 = var.ax3 - cursor4.posx\r
- var.dy3 = var.ay3 - cursor4.posy\r
-\r
- var.d3 = sqrt((var.dx3*var.dx3)+(var.dy3*var.dy3))\r
-\r
- var.a3 = 180 / (200 + var.d3 * var.d3 * var.d3 * .001)\r
-\r
- if var.d3 <= var.deadzone then var.a3 = 1\r
-\r
- //debug = var.d + " " + var.a\r
-\r
- var.finalx3 = cursor4.posx * var.a3 + var.ax3 * (1 - var.a3)\r
- var.finaly3 = cursor4.posy * var.a3 + var.ay3 * (1 - var.a3)\r
-\r
-\r
- cursor4.posx = smooth(var.finalx3,3,5)\r
- cursor4.posy = smooth(var.finaly3,3,5)\r
-\r
-else\r
-\r
- var.leftpoint3 = 0\r
-\r
-endif\r
-\r
-var.xpos3 = var.finalx3\r
-var.ypos3 = var.finaly3\r
-ppjoy3.analog0 = ensuremaprange(var.xpos3,0,screen.desktopwidth* var.coeff,-1,1)\r
-ppjoy3.analog1 = ensuremaprange(var.ypos3,0,screen.desktopheight* var.coeff,-1,1)\r
-\r
-if wiimote3.B or wiimote3.A or wiimote3.Up or wiimote3.down or wiimote3.Left or wiimote3.Right == true\r
- ppjoy3.digital0 = true\r
-else\r
- ppjoy3.digital0 = false\r
-endif\r
-\r
-debug = var.accx1+ " " + var.accy1+ " " + var.accz1\r
-\r
-//WIIMOTE 3\r
-//***Do not edit anything below this line unless you know what you are doing.***\r
-var.accx4 = wiimote4.RawForceX + var.xtrim4\r
-var.accy4 = wiimote4.RawForceY + var.ytrim4\r
-var.accz4 = wiimote4.RawForceZ + var.ztrim4\r
-\r
-if wiimote4.dot1vis and wiimote4.dot2vis then\r
-\r
- if var.accy4 > -7 then\r
- var.orientation4 = 0\r
- elseif var.accy4 > -45 then\r
- if var.accx4 < 0 then\r
- var.orientation4 = 3\r
- else\r
- var.orientation4 = 1\r
- endif\r
- else\r
- var.orientation4 = 2\r
- endif\r
-\r
- if var.leftpoint4 = 0 then\r
- if var.orientation4 = 0 then\r
- if wiimote4.dot1x < wiimote4.dot2x then\r
- var.leftpoint4 = 1\r
- else\r
- var.leftpoint4 = 2\r
- endif\r
- endif\r
- if var.orientation4 = 1 then\r
- if wiimote4.dot1y > wiimote4.dot2y then\r
- var.leftpoint4 = 1\r
- else\r
- var.leftpoint4 = 2\r
- endif\r
- endif\r
- if var.orientation4 = 2 then\r
- if wiimote4.dot1x > wiimote4.dot2x then\r
- var.leftpoint4 = 1\r
- else\r
- var.leftpoint4 = 2\r
- endif\r
- endif\r
- if var.orientation4 = 3 then\r
- if wiimote4.dot1y < wiimote4.dot2y then\r
- var.leftpoint4 = 1\r
- else\r
- var.leftpoint4 = 2\r
- endif\r
- endif\r
- endif\r
-\r
- if var.leftpoint4 = 1 then\r
- var.fix1x4 = wiimote4.dot1x\r
- var.fix1y4 = wiimote4.dot1y\r
- var.fix2x4 = wiimote4.dot2x\r
- var.fix2y4 = wiimote4.dot2y\r
- else\r
- var.fix1x4 = wiimote4.dot2x\r
- var.fix1y4 = wiimote4.dot2y\r
- var.fix2x4 = wiimote4.dot1x\r
- var.fix2y4 = wiimote4.dot1y\r
- endif\r
-\r
- var.dx4 = var.fix2x4 - var.fix1x4\r
- var.dy4 = var.fix2y4 - var.fix1y4\r
- var.cx4 = (var.fix1x4+var.fix2x4)/1024.0 - 1\r
- var.cy4 = (var.fix1y4+var.fix2y4)/1024.0 - .75\r
-\r
- var.d4 = sqrt(var.dx4*var.dx4+var.dy4*var.dy4)\r
-\r
- var.dx4 = var.dx4 / var.d4\r
- var.dy4 = var.dy4 / var.d4\r
-\r
- var.ox4 = -var.dy4*var.cy4-var.dx4*var.cx4;\r
- var.oy4 = -var.dx4*var.cy4+var.dy4*var.cx4;\r
-\r
- var.ax4 = (var.ox4 * var.coeff*screen.desktopwidth) + (screen.desktopwidth* var.coeff / 2)\r
- var.ay4 = (-var.oy4* var.coeff * screen.desktopwidth) + (screen.desktopheight* var.coeff / 2)\r
-\r
- var.dx4 = var.ax4 - cursor5.posx\r
- var.dy4 = var.ay4 - cursor5.posy\r
-\r
- var.d4 = sqrt((var.dx4*var.dx4)+(var.dy4*var.dy4))\r
-\r
- var.a4 = 180 / (200 + var.d4 * var.d4 * var.d4 * .001)\r
-\r
- if var.d4 <= var.deadzone then var.a4 = 1\r
-\r
- //debug = var.d + " " + var.a\r
-\r
- var.finalx4 = cursor5.posx * var.a4 + var.ax4 * (1 - var.a4)\r
- var.finaly4 = cursor5.posy * var.a4 + var.ay4 * (1 - var.a4)\r
-\r
-\r
- cursor5.posx = smooth(var.finalx4,3,5)\r
- cursor5.posy = smooth(var.finaly4,3,5)\r
-\r
-else\r
-\r
- var.leftpoint4 = 0\r
-\r
-endif\r
-\r
-var.xpos4 = var.finalx4\r
-var.ypos4 = var.finaly4\r
-ppjoy4.analog0 = ensuremaprange(var.xpos4,0,screen.desktopwidth* var.coeff,-1,1)\r
-ppjoy4.analog1 = ensuremaprange(var.ypos4,0,screen.desktopheight* var.coeff,-1,1)\r
-\r
-if wiimote4.B or wiimote4.A or wiimote4.Up or wiimote4.down or wiimote4.Left or wiimote4.Right == true\r
- ppjoy4.digital0 = true\r
-else\r
- ppjoy4.digital0 = false\r
-endif\r
-\r