// Original code by Kasten // Modified to fit the needs of Deetee. /* Here you want to change the offset so it matches your mote. To do this, you first have to put the wiimote down on a flat surface, then running the script. When running the script, you will notice some X, Y, Z numbers on the rightside of the run button. You want these to be 0,28,0 - so change the numbers under to make your X,Y,Z fit these. My numbers were -2, 30, -4 so I changed them to 0,28,0 by setting x to 2 y to -2 z to 4 After you have done this, push the run button to make sure its 0,28,0.*/ var.xOffset = 2 var.yOffset = -2 var.zOffset = 4 var.xRot = Wiimote.RawForceX + var.xOffset var.yRot = Wiimote.RawForceY + var.yOffset var.zRot = Wiimote.RawForceZ + var.zOffset // This controls the cursorspeed - set it higher to get faster mouseaction. var.speed = 2 // These settings controls the jittering of the control. If you have very steady // hands, you can lower these settings, if you are a very jittery person // ( like the one in duskwood ) you set the values higher var.xCutoff = 4 var.zCutoff = 4 // Sets the mote straight by using the offset we used as inputs earlier in // the script, and print it out at the debug screen. var.xRot = Wiimote.RawForceX + var.xOffset var.yRot = Wiimote.RawForceY + var.yOffset var.zRot = Wiimote.RawForceZ + var.zOffset debug = 'X:' + var.xRot + ', ' + 'Y:' + var.yRot + ', ' + 'Z:' + var.zRot // The code for making the mouse move. Incorporates mouse x,y to the wiimotes // X,Y,Z system //Mouse Control Script using IR //by vkapadia with much assistance from inio //vkapadia@vkapadia.com // //Calibration: //To calibrate, run this program and put the Wiimote on a flat surface face-up. //Then read the values in the debug line (next to the run button). //Change these values until the debug line reads approx. all zeros. var.xtrim = 6 var.ytrim = -31 var.ztrim = 6 // //Options: var.deadzone = 5 //distance in pixels that you have to move the wiimote in //order for it to register movement. Creates a "dead zone" around the pointer //to make it easier to click. Higher = smoother but less accurate. var.KITTspeed = 100 ms //delay speed for flashing LEDs. higher = slower var.rumble = false //makes the wiimote rumble if you hit the edge of the screen //more options to be added later //Controls: //Point Wiimote = Move Mouse //D-Pad = Arrow Keys //B-Button = Left Click //Home = Middle Click //A-Button = Right Click //Plus and Minus = Control Volume //One = Unmapped //Two = Unmapped // //If the pointer hits the edge of the screen, the Wiimote will rumble a bit. // //The LEDs attempt to emulate KITT's grill from Knight Rider //***Do not edit anything below this line unless you know what you are doing.*** //Set the D-Pad to function as the Arrow Keys if wiimote.Up Up = true else Up = false endif if wiimote.Down Down = true else Down = false endif if wiimote.Left Left = true else Left = false endif if wiimote.Right Right = true else Right = false endif //Mouse Buttons mouse.RightButton = wiimote.A mouse.leftButton = wiimote.B //Plus and Minus handle Volume if wiimote.plus then volumeup = true wait 60 ms volumeup = false endif if wiimote.minus then volumedown = true wait 60 ms volumedown = false endif //wiimote.One //wiimote.Two //LEDs look somewhat like KITT's grill from Knight Rider if 0 = 0 then if var.kitt = 0 then wiimote.Leds = 1 endif if var.kitt = 1 then wiimote.Leds = 3 endif if var.kitt = 2 then wiimote.Leds = 6 endif if var.kitt = 3 then wiimote.Leds = 12 endif if var.kitt = 4 then wiimote.Leds = 8 endif if var.kitt = 5 then wiimote.Leds = 12 endif if var.kitt = 6 then wiimote.Leds = 6 endif if var.kitt = 7 then wiimote.Leds = 3 endif wait var.KITTspeed var.kitt = (var.kitt + 1) % 8 endif var.accx = wiimote.RawForceX + var.xtrim var.accy = wiimote.RawForceY + var.ytrim var.accz = wiimote.RawForceZ + var.ztrim if var.xRot > var.xCutoff then mouse.x = mouse.x - .001 * var.speed * (var.xRot - var.xCutoff) if var.xRot < -var.xCutoff then mouse.x = mouse.x - .001 * var.speed * (var.xRot + var.xCutoff) if var.zRot > var.zCutoff then mouse.y = mouse.y - .001 * var.speed * (var.zRot - var.zCutoff) if var.zRot < -var.zCutoff then mouse.y = mouse.y - .001 * var.speed * (var.zRot + var.zCutoff) //debug = var.accx + " " + var.accy + " " + var.accz // Setting up the wiimote so that the controls on top of the wiimote works // as WASD that is commonly used in FPS and other games. w = Wiimote.Up s = Wiimote.Down a = Wiimote.Left d = Wiimote.Right // Here I set the nunchuk so it corresponts with my direction keys. Right = 1 > Wiimote1.Nunchuk.JoyX > 0.5 Left = -1 < Wiimote1.Nunchuk.JoyX < -0.5 down = 1 > Wiimote1.Nunchuk.JoyY > 0.5 up = -1 < Wiimote1.Nunchuk.JoyY < -0.5 // Bind some keys to the mote, you can bind your own. h = Wiimote.Plus q = Wiimote.Minus key.3 = Wiimote.HOME key.4 = Wiimote.ONE key.5 = Wiimote.TWO // Nunchuck u = Wiimote.Nunchuk.CButton f = Wiimote.Nunchuk.ZButton if var.yRot >= 60 then press(key.2) wiimote.rumble = 1 wait 400 ms wiimote.rumble = 0 release(key.2) endif if var.xRot >= 60 then press(key.2) wiimote.rumble = 1 wait 400 ms wiimote.rumble = 0 release(key.2) endif // B for left click and A for right click mouse.LeftButton = Wiimote.B mouse.RightButton = Wiimote.A // You can use a combination of keys by adding a + in between, like this - if // you want to bind one of the buttons for SHIFT+Loot. // shift + mouse.RightButton = Wiimote.A // Nothin' like a little rumblin' if key.2 = true then wiimote.rumble = true wait 400 ms wiimote.rumble = false endif if wiimote.home = true then wiimote.rumble = true wait 400 ms wiimote.rumble = false endif // Using the leds when pressing the buttons. Almost like having a GF. Wiimote.Led1 = w Wiimote.Led2 = s Wiimote.Led3 = a Wiimote.Led4 = d Wiimote.Led1 = j Wiimote.Led2 = k Wiimote.Led3 = h Wiimote.Led4 = alt+g // Sets the wiimote rotation bindings - for jumping and mounting. // By flicking it upwards, you jump // By flicking it to the side, you mount ( or whatever you bound to alt+g ). // You could probably do an Z rotation too, but that movement is strictly // for watching pr0n.