Advertisement
Guest User

Joyemu#1

a guest
Aug 13th, 2013
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1.  
  2. PIE.FrameRate = 500hz
  3.  
  4.  
  5. //Configuration
  6. var.SensitivityAxisX = 1/190
  7. var.SensitivityAxisY = 1/190
  8. var.SensitivityAxisZ = 1/10
  9. var.RecenteringSpeedXY = 30
  10. var.RecenteringSpeedZ = 8
  11. var.MaxRadiusRecentering = 0.7/1
  12. var.DeadZoneRecenteringSpeed = 1/1
  13. var.DeadZone = 0.01
  14. var.MouseCompensation = 860
  15.  
  16.  
  17.  
  18. //Mouse Axis Mapping
  19. var.AxisX = delta(RealMouse.DirectInputX)*var.SensitivityAxisX
  20. var.AxisY = delta(RealMouse.DirectInputY)*var.SensitivityAxisY
  21. var.AxisZ = delta(RealMouse.DirectInputZ)
  22.  
  23. //Joystick Axis Mapping
  24. if var.AxisZ < 0 then PPJoy1.Analog2 -= var.SensitivityAxisZ else
  25. if var.AxisZ > 0 then PPJoy1.Analog2 += var.SensitivityAxisZ
  26.  
  27. PPJoy1.Analog0 += var.AxisX
  28. PPJoy1.Analog1 += var.AxisY
  29.  
  30.  
  31. //Coordinates
  32. var.JoyCoordinateX = PPJoy1.Analog0
  33. var.JoyCoordinateY = PPJoy1.Analog1
  34. var.JoyCoordinateZ = PPJoy1.Analog2
  35. var.AbsoluteJoyCoordinateZ = |PPJoy1.Analog2|
  36.  
  37. //Absolute distance between Joystick center and (X,Y) coordinates
  38. var.JoyVector = sqrt(sqr(var.JoyCoordinateX) + sqr(var.JoyCoordinateY))
  39.  
  40.  
  41. //Recentering
  42.  
  43. //Recentering speed (increases exponentially based on Mouse movement speed)
  44. var.RecenterSpeedXY = (0.999 - (var.JoyVector / var.RecenteringSpeedXY))
  45. var.RecenterSpeedZ = (0.994 - (var.AbsoluteJoyCoordinateZ / var.RecenteringSpeedZ))
  46.  
  47. //AxisX Recentering
  48.  
  49. //1st line: Rendering the Joystick coordinate field to a circle, thus reducing sensitivity to edges
  50. //2nd line: Regular Joystick Recentering
  51. //3rd line: Joystick DeadZone
  52. if var.JoyVector >= 1.00005 then PPJoy1.Analog0 *= var.MaxRadiusRecentering else
  53. if 1.00005 > var.JoyVector > var.DeadZone then PPJoy1.Analog0 *= var.RecenterSpeedXY else
  54. if var.DeadZone > var.JoyVector > 0.00 then PPJoy1.Analog0 *= var.DeadZoneRecenteringSpeed
  55. endif
  56. //AxisY Recentering
  57. if var.JoyVector >= 1.00005 then PPJoy1.Analog1 *= var.MaxRadiusRecentering else
  58. if 1.00005 > var.JoyVector > var.DeadZone then PPJoy1.Analog1 *= var.RecenterSpeedXY else
  59. if var.DeadZone > var.JoyVector > 0.00 then PPJoy1.Analog1 *= var.DeadZoneRecenteringSpeed
  60. endif
  61. //AxisZ Recentering
  62. if not var.AbsoluteJoyCoordinateZ = 0.00 then PPJoy1.Analog2 *= var.RecenterSpeedZ
  63. endif
  64.  
  65.  
  66.  
  67. //Mouse Compensation
  68.  
  69.  
  70. //Failed attempt,(aside from obvious stuttering it hinders joystick movement as well)
  71. /*
  72. toggle(var.Toggle) = pressed(key.F2)
  73.  
  74. if var.Toggle = true
  75. if Mouse.DirectInputX > 0 then FakeMouse.DirectInputX -= |Mouse.DirectInputX| else
  76. if Mouse.DirectInputX < 0 then FakeMouse.DirectInputX += |Mouse.DirectInputX|
  77. endif
  78.  
  79. if var.Toggle = true
  80. if Mouse.DirectInputY > 0 then FakeMouse.DirectInputY -= |Mouse.DirectInputY| else
  81. if Mouse.DirectInputY < 0 then FakeMouse.DirectInputY += |Mouse.DirectInputY|
  82. endif
  83. */
  84.  
  85. //---------------------
  86.  
  87. /*
  88. if var.Toggle = true
  89. if RealMouse.DirectInputX > 0 then FakeMouse.DirectInputX -= delta(RealMouse.DirectInputX) else
  90. if RealMouse.DirectInputX < 0 then FakeMouse.DirectInputX += delta(RealMouse.DirectInputX)
  91. endif
  92. */
  93.  
  94. //---------------------
  95.  
  96. //An idea that didn't work out
  97. /*
  98. var.CompensationCoefficient = (|delta(Mouse.DirectInputX)| / var.MouseCompensation)
  99.  
  100. if var.JoyCoordinateX > 0 then PPJoy1.Analog2 -= var.CompensationCoefficient else
  101. if var.JoyCoordinateX < 0 then PPJoy1.Analog2 += var.CompensationCoefficient
  102. endif
  103. */
  104.  
  105. var.Debug = Mouse.DirectInputX
  106.  
  107. if Pressed (Key.F1)
  108. Say var.Debug
  109. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement