1
0
Fork 0

Joystick binding changes;

- added extra bindings
- reworked the view axis (usually bound to the hat); to move at a better rate.
- trim to elevator position. When selected this will remember the current position and when the joystick is centered it will apply this as the trim. Very useful for carrier approaches; and also it helps to do something that is much easier with loaded controls when you can feel the pressure being reduced by the operations of the trim switch
This commit is contained in:
Richard Harrison 2018-07-28 00:33:19 +02:00
parent f8177dcc11
commit 2322d0dbe8
4 changed files with 154 additions and 45 deletions

View file

@ -268,16 +268,28 @@ setElevatorTrimToPosition = func() {
setElevatorTrimToPosition_listener = nil;
}
var nv = getprop("/controls/flight/elevator")+getprop("/controls/flight/elevator-trim");
nv = math.min(math.max(-1.0,nv),1.0);
var lv = getprop("/controls/flight/elevator");
var setElevatorTrimToPosition_listener = setlistener("/controls/flight/elevator", func(v){
if (v.getValue() != lv) {
setprop("controls/flight/elevator",0);
removelistener(setElevatorTrimToPosition_listener);
print("set trim to ",nv);
setprop("/controls/flight/elevator-trim", nv);
}
} , 0, 0);
};
if (math.abs(lv) <= 0.001){
print("Elevator trim: centre");
setprop("/controls/flight/elevator-trim", 0);
} else {
print("Trim when centered stick");
setElevatorTrimToPosition_listener = setlistener("/controls/flight/elevator", func(v){
if (math.abs(v.getValue()) <= 0.001) {
setprop("controls/flight/elevator",0);
removelistener(setElevatorTrimToPosition_listener);
setElevatorTrimToPosition_listener = nil;
print("set trim to ",nv);
setprop("/controls/flight/elevator-trim", nv);
}
else
print("Not trimming yet ",v.getValue());
}, 0, 0);
}
}
##
# Handlers. These are suitable for binding to repeatable button press
# events. They are *not* good for binding to the keyboard, since (at
@ -471,6 +483,9 @@ var applyBrakes = func(v, which = 0) {
if (which <= 0) { interpolate("/controls/gear/brake-left", v, fullBrakeTime); }
if (which >= 0) { interpolate("/controls/gear/brake-right", v, fullBrakeTime); }
}
var applyTrigger = func(v) {
setprop("/controls/armament/pickle", v);
}
var applyParkingBrake = func(v) {
if (!v) { return; }

View file

@ -195,10 +195,11 @@ var NasalScaleAxis = {
};
var NasalLowHighAxis = {
new: func(name, lowscript, highscript, prop) {
new: func(name, lowscript, highscript, prop, repeatable) {
var m = { parents: [NasalLowHighAxis, Axis.new(name, prop, 1) ] };
m.lowscript = lowscript;
m.highscript = highscript;
m.repeatable = repeatable;
return m;
},
@ -209,6 +210,7 @@ var NasalLowHighAxis = {
m.lowscript = me.lowscript;
m.highscript = me.highscript;
m.repeatable = me.repeatable;
return m;
},
@ -238,7 +240,9 @@ var NasalLowHighAxis = {
p.getNode("desc", 1).setValue(me.name);
p.getNode("low", 1).getNode("binding", 1).getNode("command", 1).setValue("nasal");
p.getNode("low", 1).getNode("repeatable", 1).setBoolValue(me.repeatable);
p.getNode("high", 1).getNode("binding", 1).getNode("command", 1).setValue("nasal");
p.getNode("high", 1).getNode("repeatable", 1).setBoolValue(me.repeatable);
if (me.inverted) {
p.getNode("low", 1).getNode("binding", 1).getNode("script", 1).setValue(me.highscript);
@ -283,21 +287,24 @@ var axisBindings = [
PropertyScaleAxis.new("Propeller Pitch Engine 1", "/controls/engines/engine[1]/propeller-pitch"),
NasalLowHighAxis.new("View (horizontal)",
"setprop(\"/sim/current-view/goal-heading-offset-deg\", getprop(\"/sim/current-view/goal-heading-offset-deg\") + 30);",
"setprop(\"/sim/current-view/goal-heading-offset-deg\", getprop(\"/sim/current-view/goal-heading-offset-deg\") - 30);",
"/sim/current-view/goal-heading-offset-deg"),
"setprop(\"/sim/current-view/goal-heading-offset-deg\", getprop(\"/sim/current-view/goal-heading-offset-deg\") + 2);",
"setprop(\"/sim/current-view/goal-heading-offset-deg\", getprop(\"/sim/current-view/goal-heading-offset-deg\") - 2);",
"/sim/current-view/goal-heading-offset-deg",1),
NasalLowHighAxis.new("View (vertical)",
"setprop(\"/sim/current-view/goal-pitch-offset-deg\", getprop(\"/sim/current-view/goal-pitch-offset-deg\") - 20);",
"setprop(\"/sim/current-view/goal-pitch-offset-deg\", getprop(\"/sim/current-view/goal-pitch-offset-deg\") + 20);",
"/sim/current-view/goal-heading-offset-deg"),
"setprop(\"/sim/current-view/goal-pitch-offset-deg\", getprop(\"/sim/current-view/goal-pitch-offset-deg\") - 1);",
"setprop(\"/sim/current-view/goal-pitch-offset-deg\", getprop(\"/sim/current-view/goal-pitch-offset-deg\") + 1);",
"/sim/current-view/goal-heading-offset-deg",1),
PropertyScaleAxis.new("Aileron Trim", "/controls/flight/aileron-trim"),
PropertyScaleAxis.new("Elevator Trim", "/controls/flight/elevator-trim"),
PropertyScaleAxis.new("Rudder Trim", "/controls/flight/rudder-trim"),
PropertyScaleAxis.new("Brake Left", "/controls/gear/brake-left", 0.5, 1.0),
PropertyScaleAxis.new("Brake Right", "/controls/gear/brake-right", 0.5, 1.0),
NasalLowHighAxis.new("Aileron Trim Incremental", "controls.aileronTrim(-1);", "controls.aileronTrim(1);", "/controls/flight/aileron-trim-delta"),
NasalLowHighAxis.new("Elevator Trim Incremental", "controls.elevatorTrim(-1);", "controls.elevatorTrim(1);", "/controls/flight/elevator-trim-delta"),
NasalLowHighAxis.new("Rudder Trim Incremental", "controls.rudderTrim(-1);", "controls.rudderTrim(1);", "/controls/flight/rudder-trim-delta"),
PropertyScaleAxis.new("Flaps", "/controls/flight/flaps", 0.5, 1.0),
PropertyScaleAxis.new("Wings", "/controls/flight/wings", 0.5, 1.0),
PropertyScaleAxis.new("Brake Right", "/controls/gear/brake-right", 0.5, 1.0),
NasalLowHighAxis.new("Aileron Trim inc.", "controls.aileronTrim(-1);", "controls.aileronTrim(1);", "/controls/flight/aileron-trim-delta", 1),
NasalLowHighAxis.new("Elevator Trim inc.", "controls.elevatorTrim(-1);", "controls.elevatorTrim(1);", "/controls/flight/elevator-trim-delta", 1),
NasalLowHighAxis.new("Rudder Trim inc.", "controls.rudderTrim(-1);", "controls.rudderTrim(1);", "/controls/flight/rudder-trim-delta", 1),
PropertyScaleAxis.new("View Horizontal Axis", "/sim/current-view/goal-heading-offset-deg", 180, 0),
PropertyScaleAxis.new("View Vertical Axis", "/sim/current-view/goal-pitch-offset-deg", 180, 0),
@ -529,6 +536,7 @@ var buttonBindings = [
NasalButton.new("Elevator Trim Up", "controls.elevatorTrim(-1);", 1),
NasalButton.new("Elevator Trim Down", "controls.elevatorTrim(1);", 1),
NasalButton.new("Elevator Trim Pos", "controls.setElevatorTrimToPosition();", 1),
NasalButton.new("Rudder Trim Left", "controls.rudderTrim(-1);", 1),
NasalButton.new("Rudder Trim Right", "controls.rudderTrim(1);", 1),
NasalButton.new("Aileron Trim Left", "controls.aileronTrim(-1);", 1),
@ -547,8 +555,11 @@ var buttonBindings = [
NasalHoldButton.new("Parking brakes", "controls.parkingBrakeToggle(0);", "controls.parkingBrakeToggle(1);"),
NasalHoldButton.new("NWS toggle", "controls.toggleNWS(0);", "controls.toggleNWS(1);"),
PropertyToggleButton.new("Total Freeze", "/sim/freeze/clock"),
# with all of these it is expected the the armament system in the selected aircraft
# will manage the wrap around and or reset to zero.
NasalHoldButton.new("Trigger", "controls.applyTrigger(1);","controls.applyTrigger(0);"),
PropertyAdjustButton.new("Pickle", "/controls/armament/pickle-target", "1"),
PropertyAdjustButton.new("Target next", "/controls/armament/target-selected", "1"),
PropertyAdjustButton.new("Target previous", "/controls/armament/target-selected", "-1"),

View file

@ -134,6 +134,30 @@ var assignAxis = func(cmd) {
</script>
</binding>
</button>
<button>
<row>6</row>
<col>0</col>
<halign>fill</halign>
<legend>Flaps</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Flaps");
</script>
</binding>
</button>
<button>
<row>5</row>
<col>0</col>
<halign>fill</halign>
<legend>Wings</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Wings");
</script>
</binding>
</button>
<text>
@ -185,11 +209,11 @@ var assignAxis = func(cmd) {
<row>4</row>
<col>3</col>
<halign>fill</halign>
<legend>Aileron Trim Incremental</legend>
<legend>Aileron Trim inc.</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Aileron Trim Incremental");
assignAxis("Aileron Trim inc.");
</script>
</binding>
</button>
@ -197,11 +221,11 @@ var assignAxis = func(cmd) {
<row>5</row>
<col>3</col>
<halign>fill</halign>
<legend>Elevator Trim Incremental</legend>
<legend>Elevator Trim inc.</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Elevator Trim Incremental");
assignAxis("Elevator Trim inc.");
</script>
</binding>
</button>
@ -209,11 +233,11 @@ var assignAxis = func(cmd) {
<row>6</row>
<col>3</col>
<halign>fill</halign>
<legend>Rudder Trim Incremental</legend>
<legend>Rudder Trim inc.</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Rudder Trim Incremental");
assignAxis("Rudder Trim inc.");
</script>
</binding>
</button>

View file

@ -21,8 +21,17 @@ var assignButton = func(cmd) {
]]></close>
</nasal>
<name>button-config</name>
<!-- To be implemented
tiller axis
counter-measures
masterarm toggle
radar standby toggle
radar slew target selector
radar select target.
-->
<name>button-config</name>
<layout>vbox</layout>
<resizable>true</resizable>
<modal>true</modal>
@ -100,6 +109,19 @@ var assignButton = func(cmd) {
<row>3</row>
<col>0</col>
<halign>fill</halign>
<legend>Elevator Trim Pos</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Elevator Trim Pos");
</script>
</binding>
</button>
<button>
<row>4</row>
<col>0</col>
<halign>fill</halign>
<legend>Rudder Trim Left</legend>
<binding>
<command>nasal</command>
@ -110,7 +132,7 @@ var assignButton = func(cmd) {
</button>
<button>
<row>4</row>
<row>5</row>
<col>0</col>
<halign>fill</halign>
<legend>Rudder Trim Right</legend>
@ -123,7 +145,7 @@ var assignButton = func(cmd) {
</button>
<button>
<row>5</row>
<row>6</row>
<col>0</col>
<halign>fill</halign>
<legend>Aileron Trim Left</legend>
@ -136,7 +158,7 @@ var assignButton = func(cmd) {
</button>
<button>
<row>6</row>
<row>7</row>
<col>0</col>
<halign>fill</halign>
<legend>Aileron Trim Right</legend>
@ -352,6 +374,19 @@ var assignButton = func(cmd) {
<row>2</row>
<col>3</col>
<halign>fill</halign>
<legend>Auto air/ground brakes</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Brakes (air/wheel)");
</script>
</binding>
</button>
<button>
<row>3</row>
<col>3</col>
<halign>fill</halign>
<legend>Brakes (air/wheel)</legend>
<binding>
<command>nasal</command>
@ -362,7 +397,7 @@ var assignButton = func(cmd) {
</button>
<button>
<row>2</row>
<row>4</row>
<col>3</col>
<halign>fill</halign>
<legend>Parking brakes</legend>
@ -375,7 +410,7 @@ var assignButton = func(cmd) {
</button>
<button>
<row>3</row>
<row>5</row>
<col>3</col>
<halign>fill</halign>
<legend>FGCom PTT</legend>
@ -388,7 +423,7 @@ var assignButton = func(cmd) {
</button>
<button>
<row>4</row>
<row>6</row>
<col>3</col>
<halign>fill</halign>
<legend>Trigger</legend>
@ -401,7 +436,7 @@ var assignButton = func(cmd) {
</button>
<button>
<row>5</row>
<row>7</row>
<col>3</col>
<halign>fill</halign>
<legend>Custom</legend>
@ -414,7 +449,7 @@ var assignButton = func(cmd) {
</button>
<button>
<row>6</row>
<row>8</row>
<col>3</col>
<halign>fill</halign>
<legend>NWS toggle</legend>
@ -429,7 +464,7 @@ var assignButton = func(cmd) {
<text>
<row>0</row>
<col>4</col>
<label>View</label>
<label>Simulator Controls</label>
</text>
<button>
@ -535,6 +570,18 @@ var assignButton = func(cmd) {
</script>
</binding>
</button>
<button>
<row>9</row>
<col>4</col>
<halign>fill</halign>
<legend>Total Freeze</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Total Freeze");
</script>
</binding>
</button>
<text>
<row>0</row>
@ -547,6 +594,18 @@ var assignButton = func(cmd) {
<row>1</row>
<col>5</col>
<halign>fill</halign>
<legend>Trigger</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Trigger");
</script>
</binding>
</button>
<button>
<row>2</row>
<col>5</col>
<halign>fill</halign>
<legend>Pickle</legend>
<binding>
<command>nasal</command>
@ -556,7 +615,7 @@ var assignButton = func(cmd) {
</binding>
</button>
<button>
<row>2</row>
<row>3</row>
<col>5</col>
<halign>fill</halign>
<legend>Target next</legend>
@ -568,7 +627,7 @@ var assignButton = func(cmd) {
</binding>
</button>
<button>
<row>3</row>
<row>4</row>
<col>5</col>
<halign>fill</halign>
<legend>Target previous</legend>
@ -580,7 +639,7 @@ var assignButton = func(cmd) {
</binding>
</button>
<button>
<row>4</row>
<row>5</row>
<col>5</col>
<halign>fill</halign>
<legend>Weapon next</legend>
@ -592,7 +651,7 @@ var assignButton = func(cmd) {
</binding>
</button>
<button>
<row>5</row>
<row>6</row>
<col>5</col>
<halign>fill</halign>
<legend>Weapon previous</legend>
@ -604,7 +663,7 @@ var assignButton = func(cmd) {
</binding>
</button>
<button>
<row>6</row>
<row>7</row>
<col>5</col>
<halign>fill</halign>
<legend>Azimuth left</legend>
@ -616,7 +675,7 @@ var assignButton = func(cmd) {
</binding>
</button>
<button>
<row>7</row>
<row>8</row>
<col>5</col>
<halign>fill</halign>
<legend>Azimuth right</legend>
@ -628,7 +687,7 @@ var assignButton = func(cmd) {
</binding>
</button>
<button>
<row>8</row>
<row>9</row>
<col>5</col>
<halign>fill</halign>
<legend>Elevation up</legend>
@ -640,7 +699,7 @@ var assignButton = func(cmd) {
</binding>
</button>
<button>
<row>9</row>
<row>10</row>
<col>5</col>
<halign>fill</halign>
<legend>Elevation down</legend>
@ -652,7 +711,7 @@ var assignButton = func(cmd) {
</binding>
</button>
<button>
<row>10</row>
<row>11</row>
<col>5</col>
<halign>fill</halign>
<legend>Missile Reject</legend>