123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /*
- WiiMotion Plus Mouse v 2010.01.14
- by lednerg
-
- 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.
- */
-
- var.MoveButton = wiimote.B
- mouse.LeftButton = wiimote.A
- mouse.RightButton = wiimote.Plus
- mouse.MiddleButton = wiimote.Down
-
- var.Speed = 75 // 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
- */
- }
|