Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if starting:
- import time
- #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.
- def tweaxis(HID, HID_range_min, adjusted_center, HID_range_max, dband):
- if HID >= adjusted_center:
- if HID >= adjusted_center + dband:
- return filters.ensureMapRange(filters.ensureMapRange(HID, adjusted_center + dband, HID_range_max, 0, 1000), 0, 1000, 0, vJoy[0].axisMax)
- else:
- return 0
- else:
- if HID <= adjusted_center - dband:
- return filters.ensureMapRange(filters.ensureMapRange(HID, HID_range_min, adjusted_center - dband, -1000, 0), -1000, 0, -vJoy[0].axisMax, 0)
- else:
- return 0
- #The tweaxis function's variables explained:
- #HID: Human Interface Device. This specifies the input to be modified and passed to the vJoy.
- #HID_range_min: The value of the lower end of the physical axis you want to pass to the vJoy. Usually -1000.
- #adjusted_center: Assign a new center point to your physical axis with this value.
- #HID_range_max: The value of the upper end of the physical axis you want to pass to the vJoy. Usually 1000.
- #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.
- #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.
- t0 = time.clock()
- #Axis Rebinds (CUSTOMIZE HERE)
- #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].
- #X-55 Stick
- vJoy[0].x = tweaxis(joystick[1].x, -1000, 9, 1000, 0) #Main stick x to vJoy x
- vJoy[0].y = tweaxis(joystick[1].y, -1000, 0, 1000, 0) #Main stick y to vJoy y
- #X-55 Throttle
- vJoy[0].slider = tweaxis(joystick[2].x, -1000, -500, 0, 0) #Throttle left to vJoy slider, with asymmetric shortened travel
- vJoy[0].dial = -tweaxis(joystick[2].y, -1000, -8, 1000, 120) #Throttle right to vJoy dial
- vJoy[0].z = tweaxis(joystick[2].z, -300, 0, 300, 100) #Throttle top dial to vJoy z, with symmetric shortened travel
- vJoy[0].rx = -tweaxis(joystick[2].xRotation, -500, -24, 500, 100) #Throttle bottom dial to vJoy x rotation, " " " "
- #(END OF CUSTOM SECTION)
- #"Watch" tab joystick state monitors
- #Physical joystick 1. This number should be changed to the index of your Stick.
- diagnostics.watch(joystick[1].x)
- diagnostics.watch(joystick[1].y)
- diagnostics.watch(joystick[1].zRotation)
- #Physical joystick 2. This number should be changed to the index of your Throttle.
- diagnostics.watch(joystick[2].x)
- diagnostics.watch(joystick[2].y)
- diagnostics.watch(joystick[2].z)
- diagnostics.watch(joystick[2].xRotation)
- diagnostics.watch(joystick[2].yRotation)
- diagnostics.watch(joystick[2].zRotation)
- #Virtual joystick driver internal values. These are proportional to the set of vJoy external values. This number probably does not need changing.
- diagnostics.watch(vJoy[0].x)
- diagnostics.watch(vJoy[0].y)
- diagnostics.watch(vJoy[0].z)
- diagnostics.watch(vJoy[0].rx)
- diagnostics.watch(vJoy[0].ry)
- diagnostics.watch(vJoy[0].rz)
- diagnostics.watch(vJoy[0].slider)
- diagnostics.watch(vJoy[0].dial)
- #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.
- diagnostics.watch(joystick[0].x)
- diagnostics.watch(joystick[0].y)
- diagnostics.watch(joystick[0].z)
- diagnostics.watch(joystick[0].xRotation)
- diagnostics.watch(joystick[0].yRotation)
- diagnostics.watch(joystick[0].zRotation)
- diagnostics.watch(joystick[0].sliders[0])
- diagnostics.watch(joystick[0].sliders[1])
- #Cycle time in seconds
- diagnostics.watch(time.clock() - t0)
- """"""
Add Comment
Please, Sign In to add comment