No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lednerg WiiMotion Plus Mouse.PIE 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. WiiMotion Plus Mouse v 2010.01.14
  3. by lednerg
  4. Emulates the basic functionality of a Gyration Air Mouse.
  5. Requires GlovePIE version .42 or higher.
  6. Leave the Wiimote on your desk when starting so it can calibrate.
  7. Hold B to move, A = Left-Click, + = Right-Click, Down = Middle-Click.
  8. */
  9. var.MoveButton = wiimote.B
  10. mouse.LeftButton = wiimote.A
  11. mouse.RightButton = wiimote.Plus
  12. mouse.MiddleButton = wiimote.Down
  13. var.Speed = 75 // 0 to 100
  14. PIE.FrameRate = 120hz
  15. if wiimote.HasMotionPlus = false then debug = "WiiMotion Plus NOT DETECTED!"
  16. if wiimote.HasMotionPlus = true and var.MoveButton = true {
  17. var.YawSpeed = wiimote.MotionPlus.YawSpeed
  18. var.PitchSpeed = wiimote.MotionPlus.PitchSpeed
  19. if SameValue( Smooth(wiimote.SmoothRoll, 10), wiimote.SmoothRoll, 10) then var.Roll = Smooth(wiimote.SmoothRoll, 10) else var.Roll = wiimote.SmoothRoll
  20. if var.Roll < 0 and var.Roll >= -90 {
  21. var.XYswap = 1 - EnsureMapRange(var.Roll, -90, 0, 0, 1)
  22. var.RightDown = -1
  23. var.TopUp = 1
  24. }
  25. if var.Roll <= 90 and var.Roll >= 0 {
  26. var.XYswap = 1 - EnsureMapRange(var.Roll, 90, 0, 0, 1)
  27. var.RightDown = 1
  28. var.TopUp = 1
  29. }
  30. if var.Roll > 90 and var.Roll <= 180 {
  31. var.XYswap = 1 - EnsureMapRange(var.Roll, 90, 180, 0, 1)
  32. var.RightDown = 1
  33. var.TopUp = -1
  34. }
  35. if var.Roll < -90 and var.Roll >= -180 {
  36. var.XYswap = 1 - EnsureMapRange(var.Roll, -90, -180, 0, 1)
  37. var.RightDown = -1
  38. var.TopUp = -1
  39. }
  40. var.SpeedX = var.TopUp * var.YawSpeed - ( var.TopUp * var.YawSpeed * var.XYswap ) + ( var.RightDown * var.PitchSpeed * var.XYswap )
  41. var.SpeedY = var.TopUp * var.PitchSpeed - ( var.TopUp * var.PitchSpeed * var.XYswap) + ( -var.RightDown * var.YawSpeed * var.XYswap )
  42. mouse.DirectInputX = int(var.MouseX)
  43. mouse.DirectInputY = int(var.MouseY)
  44. var.MouseX = var.MouseX + ( var.SpeedX / (10500000 - EnsureMapRange(var.Speed, 0, 100, 0, 10000000) ) )
  45. var.MouseY = var.MouseY - ( var.SpeedY / (10500000 - EnsureMapRange(var.Speed, 0, 100, 0, 10000000) ) )
  46. /* // for mouse.x and mouse.y instead
  47. mouse.x = var.MouseX
  48. mouse.y = var.MouseY
  49. var.MouseX = var.MouseX + ( var.SpeedX / (20500 - EnsureMapRange(var.Speed, 0, 100, 0, 20000) ) )
  50. var.MouseY = var.MouseY - ( var.SpeedY / (20500 - EnsureMapRange(var.Speed, 0, 100, 0, 20000) ) )
  51. */
  52. }
  53. if var.MoveButton = false {
  54. var.MouseX = mouse.DirectInputX
  55. var.MouseY = mouse.DirectInputY
  56. /* // for mouse.x and mouse.y instead
  57. var.MouseX = mouse.x
  58. var.MouseY = mouse.y
  59. */
  60. }