1
0
Fork 0

Joystick dialog changes

- Engines control now use the same axis methods as the flight controls; which allows for these to have an inverted checkbox.

- Change the axis combo boxes to instead show a popup dialog (much like the button config). This is better because the items can be grouped sensibly.

- Changed the way that the "all engines" controls work - the dialog binds these to a "engines/XXXX-all" for which there is a listener in controls.nas which propogates over all engines.

- Added extra bindings to both the buttons and the axis dialogs.

- moved the "None" button to the bottom and renamed it to the more comprehensible "Remove assignment"
This commit is contained in:
Richard Harrison 2018-02-16 18:43:27 +01:00
parent 9aea8096cc
commit d7a9b36c08
5 changed files with 792 additions and 32 deletions

View file

@ -65,6 +65,35 @@ var throttleMouse = func {
}
}
setprop("/controls/engines/throttle-all",0);
setprop("/controls/engines/mixture-all",0);
setprop("/controls/engines/propeller-pitch-all",0);
setForAllEnginesProperty= func(type){
var engineRoot = props.globals.getNode("/controls/engines");
var v = getprop("/controls/engines/"~type~"-all");
v = -v;
v = (v+1)*0.5; # scale from -1..1 to 0..1
foreach( var c; engineRoot.getChildren() ){
if (c.getName() =="engine"){
var n = c.getNode(type);
if(n!=nil) {
n.setValue(v);
}
}
}
}
_setlistener("/controls/engines/throttle-all", func{
setForAllEnginesProperty("throttle");
},0,0);
_setlistener("/controls/engines/mixture-all", func{
setForAllEnginesProperty("mixture");
},0,0);
_setlistener("/controls/engines/propeller-pitch-all", func{
setForAllEnginesProperty("propeller-pitch");
},0,0);
# Joystick axis handlers (use cmdarg). Shouldn't be called from
# other contexts. A non-null argument reverses the axis direction.
var axisHandler = func(pre, post) {
@ -232,7 +261,23 @@ 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;
var setElevatorTrimToPosition_listener = nil;
setElevatorTrimToPosition = func() {
if (setElevatorTrimToPosition_listener != nil) {
removelistener(setElevatorTrimToPosition_listener);
setElevatorTrimToPosition_listener = nil;
}
var nv = getprop("/controls/flight/elevator")+getprop("/controls/flight/elevator-trim");
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);
};
##
# Handlers. These are suitable for binding to repeatable button press
# events. They are *not* good for binding to the keyboard, since (at
@ -394,14 +439,26 @@ var elevatorTrimAxis = func { elevatorTrim(cmdarg().getNode("setting").getValue(
var aileronTrimAxis = func { aileronTrim(cmdarg().getNode("setting").getValue()); }
var rudderTrimAxis = func { rudderTrim(cmdarg().getNode("setting").getValue()); }
#
# to avoid clash with "gearToggle"; this will only toggle when
# given a parameter of 1; as the controls button binding will pass 0 when the button is pressed and
# 1 when the button is released.
var gearTogglePosition = func(v) {
if (v){
if (getprop("/controls/gear/gear-down"))
setprop("/controls/gear/gear-down", 0);
else
setprop("/controls/gear/gear-down", 1);
}
}
##
# Gear handling.
#
# - parameter v is either 1 (down), -1 up (retracted)
var gearDown = func(v) {
if (v < 0) {
setprop("/controls/gear/gear-down", 0);
setprop("/controls/gear/gear-down", 0);
} elsif (v > 0) {
setprop("/controls/gear/gear-down", 1);
setprop("/controls/gear/gear-down", 1);
}
}
var gearToggle = func { gearDown(getprop("/controls/gear/gear-down") > 0 ? -1 : 1); }
@ -421,6 +478,62 @@ var applyParkingBrake = func(v) {
setprop(p, var i = !getprop(p));
return i;
}
var parkingBrakeToggle = func(v) {
if (v){
if (getprop("/controls/gear/brake-parking"))
setprop("/controls/gear/brake-parking", 0);
else
setprop("/controls/gear/brake-parking", 1);
}
}
var toggleNWS = func(v) {
if (v){
if (getprop("/controls/gear/nose-wheel-steering"))
setprop("/controls/gear/nose-wheel-steering", 0);
else
setprop("/controls/gear/nose-wheel-steering", 1);
}
}
var weAppliedSpeedBrake = 99;
var weAppliedWheelBrake = 99;
#
# allows one binding to do airbrakes and wheel brakes
var applyApplicableBrakes = func(v, which = 0) {
var wow = getprop ("/gear/gear[0]/wow")
or getprop ("/gear/gear[1]/wow")
or getprop ("/gear/gear[2]/wow")
or getprop ("/gear/gear[3]/wow")
or getprop ("/gear/gear[4]/wow")
or getprop ("/gear/gear[5]/wow")
or getprop ("/gear/gear[6]/wow")
;
if (wow) {
if (!v and weAppliedSpeedBrake != 99) {
setprop("controls/flight/speedbrake", 0);
weAppliedSpeedBrake=0;
}
if (which <= 0) {
interpolate("/controls/gear/brake-left", v, controls.fullBrakeTime);
}
if (which >= 0) {
interpolate("/controls/gear/brake-right", v, controls.fullBrakeTime);
}
weAppliedWheelBrake = which;
}
else {
if (!v and weAppliedWheelBrake != 99) {
if (weAppliedWheelBrake <= 0) { interpolate("/controls/gear/brake-left", 0, controls.fullBrakeTime); }
if (weAppliedWheelBrake >= 0) { interpolate("/controls/gear/brake-right", 0, controls.fullBrakeTime); }
weAppliedWheelBrake=0;
}
weAppliedSpeedBrake=which;
setprop("controls/flight/speedbrake", v);
}
}
# 1: Deploy, -1: Release
var deployChute = func(v) setprop("/controls/flight/drag-chute", v);

View file

@ -269,6 +269,19 @@ var axisBindings = [
NasalScaleAxis.new("Mixture 2", "controls.perEngineSelectedAxisHandler(1)([1]);", "/controls/engines/engine[1]/mixture") ,
NasalScaleAxis.new("Propeller 2", "controls.perEngineSelectedAxisHandler(2)([1]);", "/controls/engines/engine[1]/propeller-pitch") ,
# 2018.2 (RJH); change engine bindings to use the scaled axis configuration; the -all property
# that is used has a listener in controls.nas that will propogate the value to all configured engines.
# - mainly to allow the use of the "invert" option.
PropertyScaleAxis.new("Throttle All Engines", "/controls/engines/throttle-all") ,
PropertyScaleAxis.new("Mixture All Engines", "/controls/engines/mixture-all") ,
PropertyScaleAxis.new("Propeller All Engines", "/controls/engines/propeller-pitch-all") ,
PropertyScaleAxis.new("Throttle Engine 0", "/controls/engines/engine[0]/throttle") ,
PropertyScaleAxis.new("Mixture Engine 0", "/controls/engines/engine[0]/mixture") ,
PropertyScaleAxis.new("Propeller Pitch Engine 0", "/controls/engines/engine[0]/propeller-pitch") ,
PropertyScaleAxis.new("Throttle Engine 1", "/controls/engines/engine[1]/throttle") ,
PropertyScaleAxis.new("Mixture Engine 1", "/controls/engines/engine[1]/mixture") ,
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);",
@ -277,14 +290,17 @@ var axisBindings = [
"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"),
# 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("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", "controls.aileronTrim(-1);", "controls.aileronTrim(1);", "/controls/flight/aileron-trim"),
NasalLowHighAxis.new("Elevator Trim", "controls.elevatorTrim(-1);", "controls.elevatorTrim(1);", "/controls/flight/elevator-trim"),
NasalLowHighAxis.new("Rudder Trim", "controls.rudderTrim(-1);", "controls.rudderTrim(1);", "/controls/flight/rudder-trim"),
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("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),
CustomAxis.new(),
UnboundAxis.new(),
];
@ -519,13 +535,30 @@ var buttonBindings = [
NasalButton.new("Aileron Trim Right", "controls.aileronTrim(1);", 1),
NasalHoldButton.new("FGCom PTT", "controls.ptt(1);", "controls.ptt(0);"),
NasalHoldButton.new("Trigger", "controls.trigger(1);", "controls.trigger(0);"),
NasalHoldButton.new("Flaps Up", "controls.flapsDown(-1);", "controls.flapsDown(0);"),
NasalHoldButton.new("Flaps Down", "controls.flapsDown(1);", "controls.flapsDown(0);"),
NasalHoldButton.new("Gear Up", "controls.gearDown(-1);", "controls.gearDown(0);"),
NasalHoldButton.new("Gear Down", "controls.gearDown(1);", "controls.gearDown(0);"),
NasalButton.new("Flaps Up", "controls.flapsDown(-1);",0),
NasalButton.new("Flaps Down", "controls.flapsDown(1);",0),
NasalButton.new("Gear Up", "controls.gearDown(-1);",0),
NasalButton.new("Gear Down", "controls.gearDown(1);",0),
NasalButton.new("Gear Toggle", "controls.gearTogglePosition(1);",0),
NasalHoldButton.new("Spoilers Retract", "controls.stepSpoilers(-1);", "controls.stepSpoilers(0);"),
NasalHoldButton.new("Spoilers Deploy", "controls.stepSpoilers(1);", "controls.stepSpoilers(0);"),
NasalHoldButton.new("Brakes", "controls.applyBrakes(1);", "controls.applyBrakes(0);"),
NasalHoldButton.new("Brakes (air/wheel)", "controls.applyApplicableBrakes(1);", "controls.applyApplicableBrakes(0);"),
NasalHoldButton.new("Parking brakes", "controls.parkingBrakeToggle(0);", "controls.parkingBrakeToggle(1);"),
NasalHoldButton.new("NWS toggle", "controls.toggleNWS(0);", "controls.toggleNWS(1);"),
# 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.
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"),
PropertyAdjustButton.new("Weapon next", "/controls/armament/weapon-selected", "1"),
PropertyAdjustButton.new("Weapon previous", "/controls/armament/weapon-selected", "-1"),
PropertyAdjustButton.new("Azimuth left", "/controls/radar/azimuth-deg", "-5"),
PropertyAdjustButton.new("Azimuth right", "/controls/radar/azimuth-deg", "5"),
PropertyAdjustButton.new("Elevation up", "/controls/radar/elevation-deg", "5"),
PropertyAdjustButton.new("Elevation down", "/controls/radar/elevation-deg", "-5"),
PropertyAdjustButton.new("Missile Reject", "/controls/armament/missile-reject", "1"),
NasalButton.new("View Decrease", "view.decrease(0.75);", 1),
NasalButton.new("View Increase", "view.increase(0.75);", 1),

View file

@ -0,0 +1,438 @@
<?xml version="1.0"?>
<PropertyList>
<nasal>
<open><![CDATA[
var assignAxis = func(cmd) {
var i = getprop("/sim/gui/dialogs/joystick-config/current-axis");
setprop("/sim/gui/dialogs/joystick-config/axis[" ~ i ~ "]/binding", cmd);
joystick.writeConfig();
fgcommand("reinit", props.Node.new({"subsystem": "input"}));
fgcommand("dialog-close", props.Node.new({"dialog-name": "button-axis-config"}));
fgcommand("dialog-close", props.Node.new({"dialog-name": "joystick-config"}));
fgcommand("dialog-show", props.Node.new({"dialog-name": "joystick-config"}));
}
]]></open>
<close><![CDATA[
]]></close>
</nasal>
<name>button-axis-config</name>
<layout>vbox</layout>
<resizable>true</resizable>
<modal>true</modal>
<default-padding>3</default-padding>
<group>
<layout>hbox</layout>
<default-padding>1</default-padding>
<empty><stretch>true</stretch></empty>
<text>
<label>Joystick Axis Configuration</label>
</text>
<empty><stretch>true</stretch></empty>
<button>
<legend></legend>
<key>Esc</key>
<pref-width>16</pref-width>
<pref-height>16</pref-height>
<border>2</border>
<binding>
<command>dialog-close</command>
</binding>
</button>
</group>
<hrule/>
<text>
<halign>left</halign>
<label>Select the operation to assign to this axis.</label>
</text>
<hrule/>
<group>
<layout>table</layout>
<text>
<row>0</row>
<col>0</col>
<label>Flight Controls</label>
</text>
<button>
<row>1</row>
<col>0</col>
<halign>fill</halign>
<legend>Aileron</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Aileron");
</script>
</binding>
</button>
<button>
<row>2</row>
<col>0</col>
<halign>fill</halign>
<legend>Elevator</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Elevator");
</script>
</binding>
</button>
<button>
<row>3</row>
<col>0</col>
<halign>fill</halign>
<legend>Rudder</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Rudder");
</script>
</binding>
</button>
<button>
<row>4</row>
<col>0</col>
<halign>fill</halign>
<legend>Brake Left</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Brake Left");
</script>
</binding>
</button>
<button>
<row>5</row>
<col>0</col>
<halign>fill</halign>
<legend>Brake Right</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Brake Right");
</script>
</binding>
</button>
<text>
<row>0</row>
<col>3</col>
<label>Trim</label>
</text>
<button>
<row>1</row>
<col>3</col>
<halign>fill</halign>
<legend>Aileron Trim to position</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Aileron Trim");
</script>
</binding>
</button>
<button>
<row>2</row>
<col>3</col>
<halign>fill</halign>
<legend>Elevator Trim to position</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Elevator Trim");
</script>
</binding>
</button>
<button>
<row>3</row>
<col>3</col>
<halign>fill</halign>
<legend>Rudder Trim to position</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Rudder Trim");
</script>
</binding>
</button>
<button>
<row>4</row>
<col>3</col>
<halign>fill</halign>
<legend>Aileron Trim Incremental</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Aileron Trim Incremental");
</script>
</binding>
</button>
<button>
<row>5</row>
<col>3</col>
<halign>fill</halign>
<legend>Elevator Trim Incremental</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Elevator Trim Incremental");
</script>
</binding>
</button>
<button>
<row>6</row>
<col>3</col>
<halign>fill</halign>
<legend>Rudder Trim Incremental</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Rudder Trim Incremental");
</script>
</binding>
</button>
<text>
<row>0</row>
<col>1</col>
<label>Engines</label>
</text>
<button>
<row>1</row>
<col>1</col>
<halign>fill</halign>
<legend>Throttle All Engines</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Throttle All Engines");
</script>
</binding>
</button>
<button>
<row>2</row>
<col>1</col>
<halign>fill</halign>
<legend>Mixture All Engines</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Mixture All Engines");
</script>
</binding>
</button>
<button>
<row>3</row>
<col>1</col>
<halign>fill</halign>
<legend>Propeller All Engines</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Propeller All Engines");
</script>
</binding>
</button>
<button>
<row>4</row>
<col>1</col>
<halign>fill</halign>
<legend>Throttle Engine 0</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Throttle Engine 0");
</script>
</binding>
</button>
<button>
<row>5</row>
<col>1</col>
<halign>fill</halign>
<legend>Mixture Engine 0</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Mixture Engine 0");
</script>
</binding>
</button>
<button>
<row>6</row>
<col>1</col>
<halign>fill</halign>
<legend>Propeller Pitch Engine 0</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Propeller Pitch Engine 0");
</script>
</binding>
</button>
<button>
<row>7</row>
<col>1</col>
<halign>fill</halign>
<legend>Throttle Engine 1</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Throttle Engine 1");
</script>
</binding>
</button>
<button>
<row>8</row>
<col>1</col>
<halign>fill</halign>
<legend>Mixture Engine 1</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Mixture Engine 1");
</script>
</binding>
</button>
<button>
<row>9</row>
<col>1</col>
<halign>fill</halign>
<legend>Propeller Pitch Engine 1</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("Propeller Pitch Engine 1");
</script>
</binding>
</button>
<text>
<row>0</row>
<col>2</col>
<label>Other</label>
</text>
<button>
<row>1</row>
<col>2</col>
<halign>fill</halign>
<legend>View (horizontal)</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("View (horizontal)");
</script>
</binding>
</button>
<button>
<row>2</row>
<col>2</col>
<halign>fill</halign>
<legend>View (vertical)</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("View (vertical)");
</script>
</binding>
</button>
<button>
<row>3</row>
<col>2</col>
<halign>fill</halign>
<legend>View Horizontal Axis</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("View Horizontal Axis");
</script>
</binding>
</button>
<button>
<row>4</row>
<col>2</col>
<halign>fill</halign>
<legend>View Vertical Axis</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("View Vertical Axis");
</script>
</binding>
</button>
</group>
<group>
<empty>
<stretch>true</stretch>
</empty>
<layout>hbox</layout>
<button>
<row>5</row>
<col>2</col>
<halign>fill</halign>
<legend>Remove assignment</legend>
<binding>
<command>nasal</command>
<script>
assignAxis("None");
</script>
</binding>
</button>
<button>
<legend>Close</legend>
<default>true</default>
<key>Esc</key>
<binding>
<command>dialog-close</command>
</binding>
</button>
<empty>
<stretch>true</stretch>
</empty>
</group>
</PropertyList>

View file

@ -205,11 +205,24 @@ var assignButton = func(cmd) {
</script>
</binding>
</button>
<button>
<row>5</row>
<col>1</col>
<halign>fill</halign>
<legend>Gear Toggle</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Gear Toggle");
</script>
</binding>
</button>
<button>
<row>6</row>
<col>1</col>
<halign>fill</halign>
<legend>Spoilers Retract</legend>
<binding>
<command>nasal</command>
@ -220,7 +233,7 @@ var assignButton = func(cmd) {
</button>
<button>
<row>6</row>
<row>7</row>
<col>1</col>
<halign>fill</halign>
<legend>Spoilers Deploy</legend>
@ -339,6 +352,32 @@ var assignButton = func(cmd) {
<row>2</row>
<col>3</col>
<halign>fill</halign>
<legend>Brakes (air/wheel)</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Brakes (air/wheel)");
</script>
</binding>
</button>
<button>
<row>2</row>
<col>3</col>
<halign>fill</halign>
<legend>Parking brakes</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Parking brakes");
</script>
</binding>
</button>
<button>
<row>3</row>
<col>3</col>
<halign>fill</halign>
<legend>FGCom PTT</legend>
<binding>
<command>nasal</command>
@ -349,7 +388,7 @@ var assignButton = func(cmd) {
</button>
<button>
<row>3</row>
<row>4</row>
<col>3</col>
<halign>fill</halign>
<legend>Trigger</legend>
@ -362,7 +401,7 @@ var assignButton = func(cmd) {
</button>
<button>
<row>4</row>
<row>5</row>
<col>3</col>
<halign>fill</halign>
<legend>Custom</legend>
@ -375,14 +414,14 @@ var assignButton = func(cmd) {
</button>
<button>
<row>5</row>
<row>6</row>
<col>3</col>
<halign>fill</halign>
<legend>None</legend>
<legend>NWS toggle</legend>
<binding>
<command>nasal</command>
<script>
assignButton("None");
assignButton("NWS toggle");
</script>
</binding>
</button>
@ -497,6 +536,133 @@ var assignButton = func(cmd) {
</binding>
</button>
<text>
<row>0</row>
<col>5</col>
<label>Military</label>
</text>
<button>
<row>1</row>
<col>5</col>
<halign>fill</halign>
<legend>Pickle</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Pickle");
</script>
</binding>
</button>
<button>
<row>2</row>
<col>5</col>
<halign>fill</halign>
<legend>Target next</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Target next");
</script>
</binding>
</button>
<button>
<row>3</row>
<col>5</col>
<halign>fill</halign>
<legend>Target previous</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Target previous");
</script>
</binding>
</button>
<button>
<row>4</row>
<col>5</col>
<halign>fill</halign>
<legend>Weapon next</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Weapon next");
</script>
</binding>
</button>
<button>
<row>5</row>
<col>5</col>
<halign>fill</halign>
<legend>Weapon previous</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Weapon previous");
</script>
</binding>
</button>
<button>
<row>6</row>
<col>5</col>
<halign>fill</halign>
<legend>Azimuth left</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Azimuth left");
</script>
</binding>
</button>
<button>
<row>7</row>
<col>5</col>
<halign>fill</halign>
<legend>Azimuth right</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Azimuth right");
</script>
</binding>
</button>
<button>
<row>8</row>
<col>5</col>
<halign>fill</halign>
<legend>Elevation up</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Elevation up");
</script>
</binding>
</button>
<button>
<row>9</row>
<col>5</col>
<halign>fill</halign>
<legend>Elevation down</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Elevation down");
</script>
</binding>
</button>
<button>
<row>10</row>
<col>5</col>
<halign>fill</halign>
<legend>Missile Reject</legend>
<binding>
<command>nasal</command>
<script>
assignButton("Missile Reject");
</script>
</binding>
</button>
</group>
<group>
@ -505,6 +671,16 @@ var assignButton = func(cmd) {
</empty>
<layout>hbox</layout>
<button>
<legend>Remove assignment</legend>
<binding>
<command>nasal</command>
<script>
assignButton("None");
</script>
</binding>
</button>
<button>
<legend>Close</legend>
<default>true</default>

View file

@ -2,7 +2,8 @@
<PropertyList>
<nasal>
<open><![CDATA[
<open>
<![CDATA[
var dlgRoot = cmdarg();
@ -60,8 +61,9 @@ if (size(joysticks) == 0) {
t.getNode("halign", 1).setValue("right");
t.getNode("live", 1).setValue(1);
# Binding
t = table.getChild("combo", i, 1);
# Axis Binding. Changed for 2018.1 to have a button rather than a dropdown as this
# allows us to have a nicer UI and to keep compatible with the old engine bindings
t = table.getChild("button", i, 1);
t.getNode("name", 1).setValue("axis" ~ i ~ "binding");
t.getNode("row", 1).setValue(i + 1);
t.getNode("col", 1).setValue("2");
@ -69,18 +71,16 @@ if (size(joysticks) == 0) {
t.getNode("pref-width", 1).setValue("150");
t.getNode("live", 1).setValue(1);
t.getNode("property", 1).setValue(DIALOG_ROOT ~ "/axis[" ~ i ~ "]/binding");
t.getNode("legend", 1).setValue(getprop(DIALOG_ROOT ~ "/axis[" ~ i ~ "]/binding"));
forindex (var idx; joystick.axisBindings) {
t.getChild("value", idx, 1).setValue(joystick.axisBindings[idx].getName());
}
var b = t.getChild("binding", 0, 1);
b.getNode("command", 1).setValue("dialog-apply");
b.getNode("object-name", 1).setValue("axis" ~ i ~ "binding");
b.getNode("command", 1).setValue("property-assign");
b.getNode("property", 1).setValue("/sim/gui/dialogs/joystick-config/current-axis");
b.getNode("value", 1).setValue(i);
b = t.getChild("binding", 1, 1);
b.getNode("command", 1).setValue("nasal");
b.getNode("script", 1).setValue("updateConfig();");
b.getNode("command", 1).setValue("dialog-show");
b.getNode("dialog-name", 1).setValue("button-axis-config");
# Inverted
t = table.getChild("checkbox", i, 1);