Controls: Added trim to position for rudder and aileron
This commit is contained in:
parent
1d8246f23c
commit
09adb59959
3 changed files with 95 additions and 1 deletions
|
@ -274,6 +274,9 @@ var slewProp = func(prop, delta) {
|
|||
# range of a trim axis is 2.0. Should probably read this out of a
|
||||
# property...
|
||||
var TRIM_RATE = 0.045;
|
||||
|
||||
#
|
||||
# Trim elevator to current stick position (on release)
|
||||
var setElevatorTrimToPosition_listener = nil;
|
||||
setElevatorTrimToPosition = func() {
|
||||
if (setElevatorTrimToPosition_listener != nil) {
|
||||
|
@ -297,6 +300,56 @@ setElevatorTrimToPosition = func() {
|
|||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Trim aileron to current stick position (on release)
|
||||
var setAileronTrimToPosition_listener = nil;
|
||||
setAileronTrimToPosition = func() {
|
||||
if (setAileronTrimToPosition_listener != nil) {
|
||||
removelistener(setAileronTrimToPosition_listener);
|
||||
setAileronTrimToPosition_listener = nil;
|
||||
}
|
||||
var nv = getprop("/controls/flight/aileron")+getprop("/controls/flight/aileron-trim");
|
||||
nv = math.min(math.max(-1.0,nv),1.0);
|
||||
var lv = getprop("/controls/flight/aileron");
|
||||
if (math.abs(lv) <= 0.001){
|
||||
setprop("/controls/flight/aileron-trim", 0);
|
||||
} else {
|
||||
setAileronTrimToPosition_listener = setlistener("/controls/flight/aileron", func(v){
|
||||
if (math.abs(v.getValue()) <= 0.001) {
|
||||
setprop("controls/flight/aileron",0);
|
||||
removelistener(setAileronTrimToPosition_listener);
|
||||
setAileronTrimToPosition_listener = nil;
|
||||
setprop("/controls/flight/aileron-trim", nv);
|
||||
}
|
||||
}, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Trim rudder to current stick position (on release)
|
||||
var setRudderTrimToPosition_listener = nil;
|
||||
setRudderTrimToPosition = func() {
|
||||
if (setRudderTrimToPosition_listener != nil) {
|
||||
removelistener(setRudderTrimToPosition_listener);
|
||||
setRudderTrimToPosition_listener = nil;
|
||||
}
|
||||
var nv = getprop("/controls/flight/rudder")+getprop("/controls/flight/rudder-trim");
|
||||
nv = math.min(math.max(-1.0,nv),1.0);
|
||||
var lv = getprop("/controls/flight/rudder");
|
||||
if (math.abs(lv) <= 0.001){
|
||||
setprop("/controls/flight/rudder-trim", 0);
|
||||
} else {
|
||||
setRudderTrimToPosition_listener = setlistener("/controls/flight/rudder", func(v){
|
||||
if (math.abs(v.getValue()) <= 0.001) {
|
||||
setprop("controls/flight/rudder",0);
|
||||
removelistener(setRudderTrimToPosition_listener);
|
||||
setRudderTrimToPosition_listener = nil;
|
||||
setprop("/controls/flight/rudder-trim", nv);
|
||||
}
|
||||
}, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# Handlers. These are suitable for binding to repeatable button press
|
||||
# events. They are *not* good for binding to the keyboard, since (at
|
||||
|
|
|
@ -550,6 +550,8 @@ var buttonBindings = [
|
|||
NasalButton.new("Rudder Trim Right", "controls.rudderTrim(1);", 1),
|
||||
NasalButton.new("Aileron Trim Left", "controls.aileronTrim(-1);", 1),
|
||||
NasalButton.new("Aileron Trim Right", "controls.aileronTrim(1);", 1),
|
||||
NasalButton.new("Aileron Trim Pos", "controls.setAileronToPosition();", 1),
|
||||
NasalButton.new("Trim to Positions", "controls.setElevatorTrimToPosition();controls.setAileronTrimToPosition();controls.setRudderTrimToPosition();", 1),
|
||||
NasalHoldButton.new("FGCom PTT", "controls.ptt(1);", "controls.ptt(0);"),
|
||||
NasalHoldButton.new("FGCom PTT(2)", "controls.ptt(2);", "controls.ptt(0);"),
|
||||
NasalHoldButton.new("Trigger", "controls.trigger(1);", "controls.trigger(0);"),
|
||||
|
|
|
@ -148,6 +148,19 @@ var assignButton = func(cmd) {
|
|||
<row>6</row>
|
||||
<col>0</col>
|
||||
<halign>fill</halign>
|
||||
<legend>Rudder Trim Pos</legend>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
assignButton("Rudder Trim Pos");
|
||||
</script>
|
||||
</binding>
|
||||
</button>
|
||||
|
||||
<button>
|
||||
<row>7</row>
|
||||
<col>0</col>
|
||||
<halign>fill</halign>
|
||||
<legend>Aileron Trim Left</legend>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
|
@ -158,7 +171,7 @@ var assignButton = func(cmd) {
|
|||
</button>
|
||||
|
||||
<button>
|
||||
<row>7</row>
|
||||
<row>8</row>
|
||||
<col>0</col>
|
||||
<halign>fill</halign>
|
||||
<legend>Aileron Trim Right</legend>
|
||||
|
@ -170,6 +183,32 @@ var assignButton = func(cmd) {
|
|||
</binding>
|
||||
</button>
|
||||
|
||||
<button>
|
||||
<row>9</row>
|
||||
<col>0</col>
|
||||
<halign>fill</halign>
|
||||
<legend>Aileron Trim Pos</legend>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
assignButton("Aileron Trim Pos");
|
||||
</script>
|
||||
</binding>
|
||||
</button>
|
||||
|
||||
<button>
|
||||
<row>10</row>
|
||||
<col>0</col>
|
||||
<halign>fill</halign>
|
||||
<legend>Trim to Positions</legend>
|
||||
<binding>
|
||||
<command>nasal</command>
|
||||
<script>
|
||||
assignButton("Trim to Positions");
|
||||
</script>
|
||||
</binding>
|
||||
</button>
|
||||
|
||||
<text>
|
||||
<row>0</row>
|
||||
<col>1</col>
|
||||
|
|
Loading…
Add table
Reference in a new issue