Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. import math
  2. import time
  3.  
  4. import gremlin
  5.  
  6. t16000 = gremlin.input_devices.JoystickDecorator(
  7. "T.16000M",
  8. 72331530,
  9. "Default"
  10. )
  11.  
  12. g_last_axis_value = 0.0
  13.  
  14. # Macros to send the throttle increase / decrease ccommands
  15. increase = gremlin.input_devices.macro.Macro()
  16. increase.tap("-")
  17. decrease = gremlin.input_devices.macro.Macro()
  18. decrease.tap("=")
  19.  
  20. @t16000.axis(4)
  21. def fs2_throttle(event):
  22. """Sets the throttle to the desired value ensuring a consistent amount
  23. of key presses are sent, i.e. one per 5% of change in an axis.
  24. """
  25. global g_last_axis_value
  26. cur_value = event.value
  27.  
  28. delta = cur_value - g_last_axis_value
  29. count = math.floor(abs(delta) / 0.05)
  30. action = increase if delta > 0 else decrease
  31.  
  32. if count > 0:
  33. g_last_axis_value = cur_value
  34.  
  35. for _ in range(count):
  36. action.run()
  37. time.sleep(0.025)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement