All pastes #2003942 Raw Edit

wiimote minecraft!

public text v1 · immutable
#2003942 ·published 2010-11-27 19:57 UTC
rendered paste body
/*
    WiiMotion Plus Mouse                                  v 2010.01.14
    by lednerg <- thanks, you!

    Emulates the basic functionality of a Gyration Air Mouse.
    Requires GlovePIE version .42 or higher.

    Leave the Wiimote on your desk when starting so it can calibrate.
    Hold B to move, A = Left-Click, + = Right-Click, Down = Middle-Click.
*/

/* modified by pierut */

var.MoveButton = wiimote.B
Mouse.LeftButton = Nunchuk.C
Mouse.RightButton = Nunchuk.Z
mouse.MiddleButton = wiimote.Down

var.Speed = 85   // 0 to 100

PIE.FrameRate = 120hz
if wiimote.HasMotionPlus = false then debug = "WiiMotion Plus NOT DETECTED!"
if wiimote.HasMotionPlus = true and var.MoveButton = true {
   var.YawSpeed = wiimote.MotionPlus.YawSpeed
   var.PitchSpeed = wiimote.MotionPlus.PitchSpeed
   if SameValue( Smooth(wiimote.SmoothRoll, 10), wiimote.SmoothRoll, 10) then var.Roll = Smooth(wiimote.SmoothRoll, 10) else var.Roll = wiimote.SmoothRoll
   if var.Roll < 0 and var.Roll >= -90 {
      var.XYswap = 1 - EnsureMapRange(var.Roll, -90, 0, 0, 1)
      var.RightDown = -1
      var.TopUp = 1
   }
   if var.Roll <= 90 and var.Roll >= 0 {
      var.XYswap = 1 - EnsureMapRange(var.Roll, 90, 0, 0, 1)
      var.RightDown = 1
      var.TopUp = 1
   }
   if var.Roll > 90 and var.Roll <= 180 {
      var.XYswap = 1 - EnsureMapRange(var.Roll, 90, 180, 0, 1)
      var.RightDown = 1
      var.TopUp = -1
   }
   if var.Roll < -90 and var.Roll >= -180 {
      var.XYswap = 1 - EnsureMapRange(var.Roll, -90, -180, 0, 1)
      var.RightDown = -1
      var.TopUp = -1
   }
   var.SpeedX = var.TopUp * var.YawSpeed - ( var.TopUp * var.YawSpeed * var.XYswap ) + ( var.RightDown * var.PitchSpeed * var.XYswap )
   var.SpeedY = var.TopUp * var.PitchSpeed - ( var.TopUp * var.PitchSpeed * var.XYswap) + ( -var.RightDown * var.YawSpeed * var.XYswap )
   mouse.DirectInputX = int(var.MouseX)
   mouse.DirectInputY = int(var.MouseY)
   var.MouseX = var.MouseX + ( var.SpeedX / (10500000 - EnsureMapRange(var.Speed, 0, 100, 0, 10000000) ) )
   var.MouseY = var.MouseY - ( var.SpeedY / (10500000 - EnsureMapRange(var.Speed, 0, 100, 0, 10000000) ) )
/* // for mouse.x and mouse.y instead
   mouse.x = var.MouseX
   mouse.y = var.MouseY
   var.MouseX = var.MouseX + ( var.SpeedX / (20500 - EnsureMapRange(var.Speed, 0, 100, 0, 20000) ) )
   var.MouseY = var.MouseY - ( var.SpeedY / (20500 - EnsureMapRange(var.Speed, 0, 100, 0, 20000) ) )
*/
}
if var.MoveButton = false {
   var.MouseX = mouse.DirectInputX
   var.MouseY = mouse.DirectInputY
/* // for mouse.x and mouse.y instead
   var.MouseX = mouse.x
   var.MouseY = mouse.y
*/
}

/* i added this hurr */
Key.W = Nunchuk.Up
Key.A = Nunchuk.Left
Key.D = Nunchuk.Right
Key.Space = Wiimote.A
Key.R = Wiimote.Up
Mouse.WheelUp = Wiimote.Left
Mouse.WheelDown = Wiimote.Right
Key.S = DoubleClicked(Nunchuk.Down)