Created
August 17, 2015 01:40
-
-
Save candera/b93ae437cd7203f39c92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
class Utils: | |
@staticmethod | |
def mapmouse(val): | |
if abs(val) <= 13: | |
return val * 128 | |
elif abs(val) <= 25: | |
return val * 256 | |
else: | |
return val * 512 | |
if starting: | |
x = 0 | |
y = 0 | |
timeout = 0.1 # seconds | |
lastNonZeroX = time.clock() | |
lastNonZeroY = time.clock() | |
# Use the mouse to control the radar cursor | |
deltaX = mouse.deltaX | |
deltaY = mouse.deltaY | |
now = time.clock() | |
if (deltaX != 0) or (lastNonZeroX < (now - timeout)): | |
x = deltaX | |
if (deltaX != 0): | |
lastNonZeroX = now | |
if (deltaY != 0) or (lastNonZeroY < (now - timeout)): | |
y = deltaY | |
if (deltaY != 0): | |
lastNonZeroY = now | |
#diagnostics.debug(Utils.mapmouse(x)) | |
#diagnostics.debug(Utils.mapmouse(y)) | |
vJoy[0].x = Utils.mapmouse(x) | |
vJoy[0].y = Utils.mapmouse(y) | |
# Second throttle hat | |
#vJoy[0].setButton(0, joystick[5].getDown(28)) | |
#vJoy[0].setButton(1, joystick[5].getDown(29)) | |
#vJoy[0].setButton(2, joystick[5].getDown(30)) | |
#vJoy[0].setButton(3, joystick[5].getDown(31)) | |
# Speedbrake switch | |
vJoy[0].setButton(4, joystick[5].getDown(39)) | |
vJoy[0].setButton(5, joystick[5].getDown(40)) | |
# Console safe switch | |
vJoy[0].setButton(6, joystick[5].getDown(45)) | |
# Console T switches | |
vJoy[0].setButton(7, joystick[5].getDown(41)) | |
vJoy[0].setButton(8, joystick[5].getDown(42)) | |
vJoy[0].setButton(9, joystick[5].getDown(43)) | |
vJoy[0].setButton(10, joystick[5].getDown(44)) | |
# Cursor enable | |
vJoy[0].setButton(11, joystick[5].getDown(36)) | |
# Third throttle hat | |
vJoy[0].setButton(12, joystick[5].getDown(32)) | |
vJoy[0].setButton(13, joystick[5].getDown(33)) | |
vJoy[0].setButton(14, joystick[5].getDown(34)) | |
vJoy[0].setButton(15, joystick[5].getDown(35)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment