1
0
Fork 0

Merge pull request from jan-hudec/throttle-binding

Throttle binding update
This commit is contained in:
Jonathan Redpath 2020-02-18 14:46:03 +00:00 committed by GitHub
commit 4d13527147
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 72 deletions

View file

@ -1451,28 +1451,6 @@
<script>libraries.fovZoom(0);</script> <script>libraries.fovZoom(0);</script>
</binding> </binding>
</key> </key>
<key n="33">
<name>PAGE UP</name>
<desc>Throttle Increase</desc>
<binding>
<command>nasal</command>
<script>
setprop("controls/engines/engine[0]/throttle", getprop("controls/engines/engine[0]/throttle") + 0.01);
setprop("controls/engines/engine[1]/throttle", getprop("controls/engines/engine[0]/throttle") + 0.01); # Not a typo, always use engine[0] as a reference
</script>
</binding>
</key>
<key n="34">
<name>PAGE DN</name>
<desc>Throttle Decrease</desc>
<binding>
<command>nasal</command>
<script>
setprop("controls/engines/engine[0]/throttle", getprop("controls/engines/engine[0]/throttle") - 0.01);
setprop("controls/engines/engine[1]/throttle", getprop("controls/engines/engine[0]/throttle") - 0.01); # Not a typo, always use engine[0] as a reference
</script>
</binding>
</key>
<key n="49"> <key n="49">
<name>1</name> <name>1</name>
<desc>Captain View/Elevator Trim Up</desc> <desc>Captain View/Elevator Trim Up</desc>
@ -1531,8 +1509,7 @@
</condition> </condition>
<command>nasal</command> <command>nasal</command>
<script> <script>
setprop("controls/engines/engine[0]/throttle", getprop("controls/engines/engine[0]/throttle") - 0.01); controls.incThrottle(-0.01, -1.0);
setprop("controls/engines/engine[1]/throttle", getprop("controls/engines/engine[0]/throttle") - 0.01); # Not a typo, always use engine[0] as a reference
</script> </script>
</binding> </binding>
</key> </key>
@ -1659,8 +1636,7 @@
</condition> </condition>
<command>nasal</command> <command>nasal</command>
<script> <script>
setprop("controls/engines/engine[0]/throttle", getprop("controls/engines/engine[0]/throttle") + 0.01); controls.incThrottle(0.01, 1.0);
setprop("controls/engines/engine[1]/throttle", getprop("controls/engines/engine[0]/throttle") + 0.01); # Not a typo, always use engine[0] as a reference
</script> </script>
</binding> </binding>
</key> </key>

View file

@ -100,23 +100,37 @@ var apuBleedChk = maketimer(0.1, func {
# Various Other Stuff # Various Other Stuff
var doIdleThrust = func { var doIdleThrust = func {
# Idle does not respect selected engines, because it is used to respond
# to "Retard" and both engines must be idle for spoilers to deploy
setprop("controls/engines/engine[0]/throttle", 0.0); setprop("controls/engines/engine[0]/throttle", 0.0);
setprop("controls/engines/engine[1]/throttle", 0.0); setprop("controls/engines/engine[1]/throttle", 0.0);
} }
var doCLThrust = func { var doCLThrust = func {
setprop("controls/engines/engine[0]/throttle", 0.63); if (getprop("sim/input/selected/engine[0]") == 1) {
setprop("controls/engines/engine[1]/throttle", 0.63); setprop("controls/engines/engine[0]/throttle", 0.63);
}
if (getprop("sim/input/selected/engine[1]") == 1) {
setprop("controls/engines/engine[1]/throttle", 0.63);
}
} }
var doMCTThrust = func { var doMCTThrust = func {
setprop("controls/engines/engine[0]/throttle", 0.8); if (getprop("sim/input/selected/engine[0]") == 1) {
setprop("controls/engines/engine[1]/throttle", 0.8); setprop("controls/engines/engine[0]/throttle", 0.8);
}
if (getprop("sim/input/selected/engine[1]") == 1) {
setprop("controls/engines/engine[1]/throttle", 0.8);
}
} }
var doTOGAThrust = func { var doTOGAThrust = func {
setprop("controls/engines/engine[0]/throttle", 1.0); if (getprop("sim/input/selected/engine[0]") == 1) {
setprop("controls/engines/engine[1]/throttle", 1.0); setprop("controls/engines/engine[0]/throttle", 1.0);
}
if (getprop("sim/input/selected/engine[1]") == 1) {
setprop("controls/engines/engine[1]/throttle", 1.0);
}
} }
# Reverse Thrust System # Reverse Thrust System
@ -124,15 +138,19 @@ var toggleFastRevThrust = func {
var state1 = getprop("systems/thrust/state1"); var state1 = getprop("systems/thrust/state1");
var state2 = getprop("systems/thrust/state2"); var state2 = getprop("systems/thrust/state2");
if (state1 == "IDLE" and state2 == "IDLE" and getprop("controls/engines/engine[0]/reverser") == "0" and getprop("controls/engines/engine[1]/reverser") == "0" and getprop("gear/gear[1]/wow") == 1 and getprop("gear/gear[2]/wow") == 1) { if (state1 == "IDLE" and state2 == "IDLE" and getprop("controls/engines/engine[0]/reverser") == "0" and getprop("controls/engines/engine[1]/reverser") == "0" and getprop("gear/gear[1]/wow") == 1 and getprop("gear/gear[2]/wow") == 1) {
interpolate("/engines/engine[0]/reverser-pos-norm", 1, 1.4); if (getprop("sim/input/selected/engine[0]") == 1) {
interpolate("/engines/engine[1]/reverser-pos-norm", 1, 1.4); interpolate("/engines/engine[0]/reverser-pos-norm", 1, 1.4);
setprop("controls/engines/engine[0]/reverser", 1); setprop("controls/engines/engine[0]/reverser", 1);
setprop("controls/engines/engine[1]/reverser", 1); setprop("controls/engines/engine[0]/throttle-rev", 0.65);
setprop("controls/engines/engine[0]/throttle-rev", 0.65); setprop("fdm/jsbsim/propulsion/engine[0]/reverser-angle-rad", 3.14);
setprop("controls/engines/engine[1]/throttle-rev", 0.65); }
setprop("fdm/jsbsim/propulsion/engine[0]/reverser-angle-rad", 3.14); if (getprop("sim/input/selected/engine[1]") == 1) {
setprop("fdm/jsbsim/propulsion/engine[1]/reverser-angle-rad", 3.14); interpolate("/engines/engine[1]/reverser-pos-norm", 1, 1.4);
} else if ((getprop("controls/engines/engine[0]/reverser") == "1") or (getprop("controls/engines/engine[1]/reverser") == "1") and (getprop("gear/gear[1]/wow") == 1) and (getprop("gear/gear[2]/wow") == 1)) { setprop("controls/engines/engine[1]/reverser", 1);
setprop("controls/engines/engine[1]/throttle-rev", 0.65);
setprop("fdm/jsbsim/propulsion/engine[1]/reverser-angle-rad", 3.14);
}
} else if ((getprop("controls/engines/engine[0]/reverser") == "1") or (getprop("controls/engines/engine[1]/reverser") == "1")) {
setprop("controls/engines/engine[0]/throttle-rev", 0); setprop("controls/engines/engine[0]/throttle-rev", 0);
setprop("controls/engines/engine[1]/throttle-rev", 0); setprop("controls/engines/engine[1]/throttle-rev", 0);
interpolate("/engines/engine[0]/reverser-pos-norm", 0, 1.0); interpolate("/engines/engine[0]/reverser-pos-norm", 0, 1.0);
@ -145,54 +163,59 @@ var toggleFastRevThrust = func {
} }
var doRevThrust = func { var doRevThrust = func {
if (getprop("controls/engines/engine[0]/reverser") == "1" and getprop("controls/engines/engine[1]/reverser") == "1" and getprop("gear/gear[1]/wow") == 1 and getprop("gear/gear[2]/wow") == 1) { if (getprop("gear/gear[1]/wow") != 1 and getprop("gear/gear[2]/wow") != 1) {
var pos1 = getprop("controls/engines/engine[0]/throttle-rev"); # Can't select reverse if not on the ground
var pos2 = getprop("controls/engines/engine[1]/throttle-rev"); return;
if (pos1 < 0.649) { }
setprop("controls/engines/engine[0]/throttle-rev", pos1 + 0.15); if (getprop("sim/input/selected/engine[0]") == 1 and getprop("controls/engines/engine[0]/reverser") == "1") {
var pos = getprop("controls/engines/engine[0]/throttle-rev");
if (pos < 0.649) {
setprop("controls/engines/engine[0]/throttle-rev", pos + 0.15);
} }
if (pos2 < 0.649) { }
setprop("controls/engines/engine[1]/throttle-rev", pos2 + 0.15); if (getprop("sim/input/selected/engine[1]") == 1 and getprop("controls/engines/engine[1]/reverser") == "1") {
var pos = getprop("controls/engines/engine[1]/throttle-rev");
if (pos < 0.649) {
setprop("controls/engines/engine[1]/throttle-rev", pos + 0.15);
} }
} }
var state1 = getprop("systems/thrust/state1"); var state1 = getprop("systems/thrust/state1");
var state2 = getprop("systems/thrust/state2"); var state2 = getprop("systems/thrust/state2");
if (state1 == "IDLE" and state2 == "IDLE" and getprop("controls/engines/engine[0]/reverser") == "0" and getprop("controls/engines/engine[1]/reverser") == "0" and getprop("gear/gear[1]/wow") == 1 and getprop("gear/gear[2]/wow") == 1) { if (getprop("sim/input/selected/engine[0]") == 1 and state1 == "IDLE" and getprop("controls/engines/engine[0]/reverser") == "0") {
setprop("controls/engines/engine[0]/throttle-rev", 0.05); setprop("controls/engines/engine[0]/throttle-rev", 0.05);
setprop("controls/engines/engine[1]/throttle-rev", 0.05);
interpolate("/engines/engine[0]/reverser-pos-norm", 1, 1.4); interpolate("/engines/engine[0]/reverser-pos-norm", 1, 1.4);
interpolate("/engines/engine[1]/reverser-pos-norm", 1, 1.4);
setprop("controls/engines/engine[0]/reverser", 1); setprop("controls/engines/engine[0]/reverser", 1);
setprop("controls/engines/engine[1]/reverser", 1);
setprop("fdm/jsbsim/propulsion/engine[0]/reverser-angle-rad", 3.14); setprop("fdm/jsbsim/propulsion/engine[0]/reverser-angle-rad", 3.14);
}
if (getprop("sim/input/selected/engine[1]") == 1 and state2 == "IDLE" and getprop("controls/engines/engine[1]/reverser") == "0") {
setprop("controls/engines/engine[1]/throttle-rev", 0.05);
interpolate("/engines/engine[1]/reverser-pos-norm", 1, 1.4);
setprop("controls/engines/engine[1]/reverser", 1);
setprop("fdm/jsbsim/propulsion/engine[1]/reverser-angle-rad", 3.14); setprop("fdm/jsbsim/propulsion/engine[1]/reverser-angle-rad", 3.14);
} }
} }
var unRevThrust = func { var unRevThrust = func {
if (getprop("controls/engines/engine[0]/reverser") == "1" or getprop("controls/engines/engine[1]/reverser") == "1") { if (getprop("sim/input/selected/engine[0]") == 1 and getprop("controls/engines/engine[0]/reverser") == "1") {
var pos1 = getprop("controls/engines/engine[0]/throttle-rev"); var pos = getprop("controls/engines/engine[0]/throttle-rev");
var pos2 = getprop("controls/engines/engine[1]/throttle-rev"); if (pos > 0.051) {
if (pos1 > 0.051) { setprop("controls/engines/engine[0]/throttle-rev", pos - 0.15);
setprop("controls/engines/engine[0]/throttle-rev", pos1 - 0.15);
} else { } else {
unRevThrust_b(); setprop("controls/engines/engine[0]/throttle-rev", 0);
interpolate("/engines/engine[0]/reverser-pos-norm", 0, 1.0);
setprop("fdm/jsbsim/propulsion/engine[0]/reverser-angle-rad", 0);
setprop("controls/engines/engine[0]/reverser", 0);
} }
if (pos2 > 0.051) { }
setprop("controls/engines/engine[1]/throttle-rev", pos2 - 0.15); if (getprop("sim/input/selected/engine[1]") == 1 and getprop("controls/engines/engine[1]/reverser") == "1") {
var pos = getprop("controls/engines/engine[1]/throttle-rev");
if (pos > 0.051) {
setprop("controls/engines/engine[1]/throttle-rev", pos - 0.15);
} else { } else {
unRevThrust_b(); setprop("controls/engines/engine[1]/throttle-rev", 0);
interpolate("/engines/engine[1]/reverser-pos-norm", 0, 1.0);
setprop("fdm/jsbsim/propulsion/engine[1]/reverser-angle-rad", 0);
setprop("controls/engines/engine[1]/reverser", 0);
} }
} }
} }
var unRevThrust_b = func {
setprop("controls/engines/engine[0]/throttle-rev", 0);
setprop("controls/engines/engine[1]/throttle-rev", 0);
interpolate("/engines/engine[0]/reverser-pos-norm", 0, 1.0);
interpolate("/engines/engine[1]/reverser-pos-norm", 0, 1.0);
setprop("fdm/jsbsim/propulsion/engine[0]/reverser-angle-rad", 0);
setprop("fdm/jsbsim/propulsion/engine[1]/reverser-angle-rad", 0);
setprop("controls/engines/engine[0]/reverser", 0);
setprop("controls/engines/engine[1]/reverser", 0);
}