Advertisement
Guest User

Untitled

a guest
Nov 1st, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. from System import Int16
  2. from ctypes import windll, Structure, c_ulong, byref
  3.  
  4. class POINT(Structure):
  5. _fields_ = [("x", c_ulong), ("y", c_ulong)]
  6.  
  7. if starting:
  8. Joy_stat = False
  9. vJoy_Key = Key.CapsLock
  10. vJoy[0].x = 0
  11. mouse_x = 0
  12. mouse_y = 0
  13. screen_x = windll.user32.GetSystemMetrics(0)
  14. screen_y = windll.user32.GetSystemMetrics(1)
  15. pt = POINT()
  16. preci = 100
  17. multipler_x = preci * 32768 / screen_x
  18. multipler_y = preci * 32768 / screen_y
  19.  
  20.  
  21.  
  22. Freeview = mouse.middleButton
  23. #Freeview = keyboard.getKeyDown(Key.V)
  24.  
  25. # Включение и отключение калибровочной оси Z
  26. if keyboard.getPressed(vJoy_Key):
  27. if Joy_stat: # при отключении джойстик встает в 0
  28. Joy_stat = False
  29. vJoy[0].x = 0
  30. vJoy[0].y = 0
  31. vJoy[0].z = 0
  32. vJoy[0].rz = 0
  33. windll.user32.SetCursorPos(screen_x / 2, screen_y / 2)
  34. else:
  35. Joy_stat = True
  36.  
  37. # Опрос мыши
  38. windll.user32.GetCursorPos(byref(pt))
  39. if pt.x > 65536: mouse_x = 0
  40. else: mouse_x = pt.x
  41. if pt.y > 65536: mouse_y = 0
  42. else: mouse_y = pt.y
  43.  
  44. if Joy_stat:
  45. vJoy[0].rz = (mouse_y - (screen_y / 2)) * multipler_y / preci
  46. vJoy[0].z = (mouse_x - (screen_x / 2)) * multipler_x / preci
  47. else:
  48. vJoy[0].y = (mouse_y - (screen_y / 2)) * multipler_y / preci
  49. vJoy[0].x = (mouse_x - (screen_x / 2)) * multipler_x / preci
  50.  
  51. diagnostics.watch(Joy_stat)
  52. diagnostics.watch(vJoy[0].x)
  53. diagnostics.watch(vJoy[0].y)
  54. diagnostics.watch(vJoy[0].z)
  55. diagnostics.watch(vJoy[0].rz)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement