Mindbulletz

X-55 Axis Recalibration in FreePIE (with vJoy)

Jan 25th, 2015
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.04 KB | None | 0 0
  1. if starting:
  2.     import time
  3.     #The following is the tweaxis function. Don't change this unless you know how to program. Call on this function in the Axis Rebinds section.
  4.     def tweaxis(HID, HID_range_min, adjusted_center, HID_range_max, dband):
  5.         if HID >= adjusted_center:
  6.             if HID >= adjusted_center + dband:
  7.                 return filters.ensureMapRange(filters.ensureMapRange(HID, adjusted_center + dband, HID_range_max, 0, 1000), 0, 1000, 0, vJoy[0].axisMax)
  8.             else:
  9.                 return 0
  10.         else:
  11.             if HID <= adjusted_center - dband:
  12.                 return filters.ensureMapRange(filters.ensureMapRange(HID, HID_range_min, adjusted_center - dband, -1000, 0), -1000, 0, -vJoy[0].axisMax, 0)
  13.             else:
  14.                 return 0
  15.     #The tweaxis function's variables explained:
  16.     #HID: Human Interface Device. This specifies the input to be modified and passed to the vJoy.
  17.     #HID_range_min: The value of the lower end of the physical axis you want to pass to the vJoy. Usually -1000.
  18.     #adjusted_center: Assign a new center point to your physical axis with this value.
  19.     #HID_range_max: The value of the upper end of the physical axis you want to pass to the vJoy. Usually 1000.
  20.     #dband: Deadband. The distance in either direction that you must move the input from adjusted_center before the smallest value is passed to the vJoy.
  21.     #NOTE:HID_range_min and _max can be changed to alter the effective range of an axis on a physical device. For example, if you wanted to use only half the axis for the full range of values. If making asymmetrical changes as in the example, the adjusted_center value will usually need to change to the average of these two values, or at the very least should probably stay between them; I have not tested what happens if it doesn't.
  22.  
  23. t0 = time.clock()
  24.  
  25. #Axis Rebinds (CUSTOMIZE HERE)
  26. #I left all my personal settings here as an example. On my computer, the vJoy is joystick[0], the X-55 Stick is joystick[1], and the X-55 Throttle is joystick[2].
  27. #X-55 Stick
  28. vJoy[0].x = tweaxis(joystick[1].x, -1000, 9, 1000, 0)   #Main stick x to vJoy x
  29. vJoy[0].y = tweaxis(joystick[1].y, -1000, 0, 1000, 0)   #Main stick y to vJoy y
  30.  
  31. #X-55 Throttle
  32. vJoy[0].slider = tweaxis(joystick[2].x, -1000, -500, 0, 0)  #Throttle left to vJoy slider, with asymmetric shortened travel
  33. vJoy[0].dial = -tweaxis(joystick[2].y, -1000, -8, 1000, 120)    #Throttle right to vJoy dial
  34. vJoy[0].z = tweaxis(joystick[2].z, -300, 0, 300, 100)       #Throttle top dial to vJoy z, with symmetric shortened travel
  35. vJoy[0].rx = -tweaxis(joystick[2].xRotation, -500, -24, 500, 100)   #Throttle bottom dial to vJoy x rotation, " " " "
  36.  
  37. #(END OF CUSTOM SECTION)
  38.  
  39. #"Watch" tab joystick state monitors
  40. #Physical joystick 1. This number should be changed to the index of your Stick.
  41. diagnostics.watch(joystick[1].x)
  42. diagnostics.watch(joystick[1].y)
  43. diagnostics.watch(joystick[1].zRotation)
  44. #Physical joystick 2. This number should be changed to the index of your Throttle.
  45. diagnostics.watch(joystick[2].x)
  46. diagnostics.watch(joystick[2].y)
  47. diagnostics.watch(joystick[2].z)
  48. diagnostics.watch(joystick[2].xRotation)
  49. diagnostics.watch(joystick[2].yRotation)
  50. diagnostics.watch(joystick[2].zRotation)
  51. #Virtual joystick driver internal values. These are proportional to the set of vJoy external values. This number probably does not need changing.
  52. diagnostics.watch(vJoy[0].x)
  53. diagnostics.watch(vJoy[0].y)
  54. diagnostics.watch(vJoy[0].z)
  55. diagnostics.watch(vJoy[0].rx)
  56. diagnostics.watch(vJoy[0].ry)
  57. diagnostics.watch(vJoy[0].rz)
  58. diagnostics.watch(vJoy[0].slider)
  59. diagnostics.watch(vJoy[0].dial)
  60. #Virtual joystick driver external values. These are proportional to the set of vJoy[0] values. This number (except for the slider[]s) should be changed to the index of your virtual joystick.
  61. diagnostics.watch(joystick[0].x)
  62. diagnostics.watch(joystick[0].y)
  63. diagnostics.watch(joystick[0].z)
  64. diagnostics.watch(joystick[0].xRotation)
  65. diagnostics.watch(joystick[0].yRotation)
  66. diagnostics.watch(joystick[0].zRotation)
  67. diagnostics.watch(joystick[0].sliders[0])
  68. diagnostics.watch(joystick[0].sliders[1])
  69. #Cycle time in seconds
  70. diagnostics.watch(time.clock() - t0)
  71. """"""
Add Comment
Please, Sign In to add comment