-
-
Save NanoPi/930b08ccb8c4f5ee7c3b to your computer and use it in GitHub Desktop.
| # https://github.com/AndersMalmgren/FreePIE/wiki/Sign | |
| def sign(val): #Returns -1 for negatives, 0 for zero and 1 for positives | |
| return (1 * (val > 0)) + (-1 * (val < 0)) | |
| # https://github.com/AndersMalmgren/FreePIE/wiki/ScaledDeadzone | |
| # (modified) | |
| def ScaledDeadzone(val, mini, maxi, dz): #Paremeters are Value, Minimum, Maximum and Deadzone Size. | |
| scaled = filters.mapRange(val,mini,maxi, -1.0,1.0) | |
| output = 0.0 | |
| if abs(scaled) > dz: | |
| output = filters.mapRange(abs(scaled), dz, 1.0, 0.0, 1.0) * sign(val) | |
| return filters.mapRange(output,-1.0,1.0, mini,maxi) | |
| def dz(a): | |
| return ScaledDeadzone(a, -jsrange,jsrange,0.03) | |
| def dzR(a): | |
| return ScaledDeadzone(a, -jsrange,jsrange,0.07) | |
| if starting: | |
| j = -1 | |
| gpa = 0 | |
| gpb = 0 | |
| mw = 0.0 | |
| jsrange = 1000 | |
| #diagnostics.debug("Press the second button on your gamepad.") | |
| # choose which joystick to use by pressing the second button | |
| if j == -1: | |
| for i in range(0, len(joystick)): | |
| # using getPressed here prevents unintended double click | |
| # (getPressed can only be used once per frame, using it a second time always returns False) | |
| if joystick[i].getPressed(1): | |
| j = i | |
| joystick[i].setRange(-jsrange,jsrange) | |
| if j >= 0: | |
| # slow down with RT analogue | |
| slow = 0.0 + float(joystick[j].sliders[1])/jsrange + 2 | |
| #diagnostics.watch(slow) | |
| # movement | |
| mouse.deltaX = x = dz(joystick[j].x)/(slow*slow) * 0.003 | |
| mouse.deltaY = y = dz(joystick[j].y)/(slow*slow) * 0.003 | |
| diagnostics.watch(x) | |
| diagnostics.watch(y) | |
| """ | |
| if joystick[j].getPressed(0): | |
| gpa += 1 | |
| if joystick[j].getPressed(0): | |
| gpb += 1 | |
| diagnostics.watch(gpa) | |
| diagnostics.watch(gpb) | |
| """ | |
| # buttons | |
| mouse.leftButton = joystick[j].getDown(0) | |
| mouse.rightButton = joystick[j].getDown(2) | |
| mouse.middleButton = joystick[j].getDown(3) | |
| # double click | |
| if joystick[j].getPressed(1): | |
| mouse.setButton(0,True) | |
| mouse.setButton(0,False) | |
| mouse.setButton(0,True) | |
| mouse.setButton(0,False) | |
| #smooth scrolling in web browsers. chaos everywhere else | |
| if dzR(joystick[j].zRotation) != 0.0: | |
| # use gamecube's RT-click to dramatically boost slowness | |
| if joystick[j].getDown(5): | |
| slow*=slow | |
| mw += -math.tan(dzR(joystick[j].zRotation)/jsrange) * mouse.wheelMax/(slow*slow*30) | |
| if abs(mw) >= 1.0: | |
| mouse.wheel = mw | |
| mw -= int(mw) | |
| diagnostics.watch(mw) | |
| diagnostics.watch(mouse.wheel) | |
| #diagnostics.watch(math.tan(dzR(joystick[j].zRotation)/jsrange)) | |
Hi, could you please write a new script with VJoy for DCS World? I would be really appreciates if you do so!
Concerning the content, it will be :
- Three axes (X,Y,Z), several buttons (or not, I will add some by myself)
- X and Y axe has two mode, absolutive and relative, and a hotkey to toggle them between each other, and a sound beep when toggle.
- Configurable axes sensitivity.
- Global suspend (Also not necessary, I could finish that), and a sound beep when script suspended.
- Axes could remember the last coordinate position before the script suspended, after resume, the axe will continue with that coordinate.
That's all !
Thanks in advanced, and sorry for my poor English.
hey i have a problem, it works exept one thing. for example If I want to steer to the right, the steering wheel just jumps from left to right in one go. and the same for when I want to steer to the left. can someone help me?
i got an error from freepie "29 len() of unsized object"
i got an error from freepie "29 len() of unsized object"
same
Same here. Did any of you guys figure it out?
not sure what problem needs to be solved in carx.
it's available on pc and also mobile and also mobile emulated on pc.