Advertisement
hamzaalloush

TrackIR.py

Feb 6th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. import sys
  2.  
  3. def toIntSafe(value):
  4.     if value > sys.maxint: return sys.maxint
  5.     if value < -sys.maxint: return -sys.maxint
  6.     return value
  7.  
  8. def update():
  9.     yaw = filters.mapRange(trackIR.yaw, -90, 90, -vJoy[0].axisMax, vJoy[0].axisMax)
  10.     pitch = filters.mapRange(trackIR.pitch, -90, 90, -vJoy[0].axisMax, vJoy[0].axisMax)
  11.     roll = filters.mapRange(trackIR.roll, -120, 120, -vJoy[0].axisMax, vJoy[0].axisMax)
  12.     side = filters.mapRange(trackIR.x, -120, 120, -vJoy[0].axisMax, vJoy[0].axisMax)
  13.     zoom = filters.mapRange(trackIR.z, -120, 120, -vJoy[0].axisMax, vJoy[0].axisMax)
  14.     updown = filters.mapRange(trackIR.y, -120, 120, -vJoy[0].axisMax, vJoy[0].axisMax)
  15.  
  16.     vJoy[0].x = toIntSafe(yaw)
  17.     vJoy[0].y = toIntSafe(pitch)
  18.     vJoy[0].z = toIntSafe(roll)
  19.     vJoy[0].rx = toIntSafe(side)
  20.     vJoy[0].rz = toIntSafe(zoom)
  21.     vJoy[0].ry = toIntSafe(updown)
  22.  
  23. if starting:
  24.     trackIR.update += update
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement