Advertisement
Guest User

sending c stick command to dolphin pipe

a guest
Jul 27th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import os
  2. import random
  3. import time
  4.  
  5.  
  6. # paths to the controller configuration and the dolphin pipe
  7. flatbot_pipe_path = "/home/maximillian/.local/share/dolphin-emu/Pipes/flatbot"
  8. # open or create pipe if none exists
  9. if not os.path.exists(flatbot_pipe_path):
  10. os.mkfifo(flatbot_pipe_path)
  11.  
  12. dolphin_pipe = os.open(flatbot_pipe_path, os.O_WRONLY | os.O_NONBLOCK)
  13. iterations = 200
  14. for k in range(2):
  15. for i in range(0, iterations + 1):
  16. for j in range(0, iterations + 1):
  17. time.sleep(0.01**2)
  18. # cmd = b"SET C %f %f\n" % (i / iterations, 1)
  19. # cmd = b"SET C %f %f\n" % (1, i / iterations)
  20. cmd = ""
  21. if k == 0:
  22. cmd = b"SET C %f %f\n" % (j / iterations, i / iterations)
  23. else:
  24. cmd = b"SET C %f %f\n" % (i / iterations, j / iterations)
  25. os.write(dolphin_pipe, cmd)
  26. os.write(1, cmd)
  27.  
  28. # while True:
  29. # try:
  30. # rx = random.random()
  31. # ry = random.random()
  32. # time.sleep(0.5)
  33. # input()
  34. # cmd = b"SET C %f %f\n" % (rx, ry)
  35. # # cmd = b"SET C %f %f\n" % (0.0, 0.0)
  36. # # cmd = b"SET C %f\n" % (rx * 100)
  37.  
  38. # os.write(dolphin_pipe, cmd)
  39. # os.write(1, cmd)
  40. # except KeyboardInterrupt:
  41. # break
  42.  
  43. # close the pipe pointer
  44. os.close(dolphin_pipe)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement