2012-08-24 21:53:21 +00:00
<?xml version="1.0"?>
<PropertyList >
<nasal >
2018-02-16 17:43:27 +00:00
<open >
< ![CDATA[
2012-08-24 21:53:21 +00:00
var dlgRoot = cmdarg();
var DIALOG_ROOT = "/sim/gui/dialogs/joystick-config";
# Read the current bindings
joystick.readConfig();
# Fill in the joystick names combo box.
var joysticks = props.globals.getNode("/input/joysticks").getChildren("js");
2012-08-26 20:48:53 +00:00
if (size(joysticks) == 0) {
# No joysticks found - no point filling in rest of dialog
setprop(DIALOG_ROOT ~ "joystick-count", 0);
} else {
2012-08-24 21:53:21 +00:00
2012-08-26 20:48:53 +00:00
var jsselect = gui.findElementByName(dlgRoot, "jsselect" );
2012-08-24 21:53:21 +00:00
2012-08-26 20:48:53 +00:00
forindex (var joystick_index; joysticks) {
var js = joysticks[joystick_index];
var js_id = "unknown";
if ((js.getNode("id") != nil) and (js.getNode("id").getValue() != nil))
{
js_id = js.getNode("id").getValue();
}
jsselect.getNode("value[" ~ joystick_index ~ "]", 1).setValue(js_id);
2012-08-24 21:53:21 +00:00
}
2012-08-26 20:48:53 +00:00
var joystick_index = getprop(DIALOG_ROOT ~ "/selected-joystick-index");
2012-08-24 21:53:21 +00:00
2012-08-26 20:48:53 +00:00
var table = gui.findElementByName(dlgRoot, "axistable");
table.removeChildren("checkbox");
table.removeChildren("combo");
2012-08-24 21:53:21 +00:00
2012-08-26 20:48:53 +00:00
# Fill in the valid axis bindings
for (var i = 0; i < joystick.MAX_AXES ; i = i + 1 ) {
# Label
var t = table.getChild("text", 2*i + 4, 1);
t.getNode("row", 1).setValue(i + 1);
t.getNode("col", 1).setValue(0);
t.getNode("label", 1).setValue("Axis " ~ i);
# Raw data
t = table.getChild("text", 2*i + 5, 1);
t.getNode("property", 1).setValue("/devices/status/joysticks/joystick[" ~ joystick_index ~ "]/axis[" ~ i ~ "]");
t.getNode("row", 1).setValue(i +1 );
t.getNode("col", 1).setValue(1);
t.getNode("label", 1).setValue("01234");
t.getNode("format", 1).setValue("%2.2f");
t.getNode("halign", 1).setValue("right");
t.getNode("live", 1).setValue(1);
2018-02-16 17:43:27 +00:00
# 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);
2012-08-26 20:48:53 +00:00
t.getNode("name", 1).setValue("axis" ~ i ~ "binding");
t.getNode("row", 1).setValue(i + 1);
t.getNode("col", 1).setValue("2");
t.getNode("halign", 1).setValue("fill");
t.getNode("pref-width", 1).setValue("150");
t.getNode("live", 1).setValue(1);
t.getNode("property", 1).setValue(DIALOG_ROOT ~ "/axis[" ~ i ~ "]/binding");
2018-02-16 17:43:27 +00:00
t.getNode("legend", 1).setValue(getprop(DIALOG_ROOT ~ "/axis[" ~ i ~ "]/binding"));
2012-08-26 20:48:53 +00:00
var b = t.getChild("binding", 0, 1);
2018-02-16 17:43:27 +00:00
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);
2012-08-26 20:48:53 +00:00
b = t.getChild("binding", 1, 1);
2018-02-16 17:43:27 +00:00
b.getNode("command", 1).setValue("dialog-show");
b.getNode("dialog-name", 1).setValue("button-axis-config");
2012-08-26 20:48:53 +00:00
# Inverted
t = table.getChild("checkbox", i, 1);
t.getNode("name", 1).setValue("axis" ~ i ~ "inverted");
t.getNode("property", 1).setValue(DIALOG_ROOT ~ "/axis[" ~ i ~ "]/inverted");
t.getNode("row", 1).setValue(i +1 );
t.getNode("col", 1).setValue(3);
t.getNode("visible", 1).getNode("property", 1).setValue(DIALOG_ROOT ~ "/axis[" ~ i ~ "]/invertable");
t.getNode("live", 1).setValue(1);
var b = t.getChild("binding", 0, 1);
b.getNode("command", 1).setValue("dialog-apply");
b.getNode("object-name", 1).setValue("axis" ~ i ~ "inverted");
b = t.getChild("binding", 1, 1);
b.getNode("command", 1).setValue("nasal");
b.getNode("script", 1).setValue("updateConfig();");
}
# Set up the buttons.
table = gui.findElementByName(dlgRoot, "buttontable");
table.removeChildren("checkbox");
table.removeChildren("button");
var row = 1;
var col = 0;
for (var button = 0; button < joystick.MAX_BUTTONS ; button = button + 1 ) {
t = table.getChild("checkbox", button, 1);
t.getNode("property", 1).setValue("/devices/status/joysticks/joystick[" ~ joystick_index ~ "]/button[" ~ button ~ "]");
t.getNode("row", 1).setValue(row );
t.getNode("col", 1).setValue(col);
t.getNode("live", 1).setValue(1);
t = table.getChild("button", button, 1);
t.getNode("name", 1).setValue("button" ~ button);
t.getNode("pref-width", 1).setValue(140);
t.getNode("halign", 1).setValue("fill");
t.getNode("live", 1).setValue("fill");
t.getNode("row", 1).setValue(row );
t.getNode("col", 1).setValue(col +1);
t.getNode("legend", 1).setValue(getprop(DIALOG_ROOT ~ "/button[" ~ button ~ "]/binding"));
var b = t.getChild("binding", 0, 1);
b.getNode("command", 1).setValue("property-assign");
b.getNode("property", 1).setValue("/sim/gui/dialogs/joystick-config/current-button");
b.getNode("value", 1).setValue(button);
b = t.getChild("binding", 1, 1);
b.getNode("command", 1).setValue("dialog-show");
b.getNode("dialog-name", 1).setValue("button-config");
col = col + 2;
if (col > 5) {
row = row +1;
col = 0;
}
}
2012-08-24 21:53:21 +00:00
}
var updateConfig = func() {
joystick.writeConfig();
fgcommand("reinit", props.Node.new({"subsystem": "input"}));
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 > joystick-config</name>
<layout > vbox</layout>
<resizable > true</resizable>
<default-padding > 3</default-padding>
<group >
<layout > hbox</layout>
<default-padding > 1</default-padding>
<empty > <stretch > true</stretch> </empty>
<text >
<label > Joystick 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>
2012-08-26 20:48:53 +00:00
2012-08-24 21:53:21 +00:00
<hrule />
2012-08-26 20:48:53 +00:00
<text >
<halign > left</halign>
2015-05-03 16:13:50 +00:00
<label > To configure your joystick/yoke/pedals:</label>
2012-08-26 20:48:53 +00:00
</text>
2012-08-24 21:53:21 +00:00
2012-08-26 20:48:53 +00:00
<text >
<halign > left</halign>
2015-05-03 16:13:50 +00:00
<label > 1) Select the device your wish to configure from the drop-down.</label>
2012-08-26 20:48:53 +00:00
</text>
2012-08-24 21:53:21 +00:00
2012-08-26 20:48:53 +00:00
<text >
<halign > left</halign>
2015-05-03 16:13:50 +00:00
<label > 2) Identify the control you wish to configure by moving the joystick or pressing the button. The result is shown in the Input column.</label>
2012-08-26 20:48:53 +00:00
</text>
2012-08-24 21:53:21 +00:00
2012-08-26 20:48:53 +00:00
<text >
<halign > left</halign>
2015-05-03 16:13:50 +00:00
<label > 3) Using the drop-down or dialog button, select what you want the control to do. "Custom" indicates a manually configured command.</label>
2012-08-26 20:48:53 +00:00
</text>
2012-08-24 21:53:21 +00:00
2012-08-26 20:48:53 +00:00
<text >
<halign > left</halign>
2015-05-03 16:13:50 +00:00
<label > Your selection will take effect immediately.</label>
2012-08-26 20:48:53 +00:00
</text>
<text >
<halign > left</halign>
2015-05-03 16:13:50 +00:00
<label > 4) Test your control. Some joystick controls can be "inverted" if you wish the control to take effect in the opposite direction.</label>
2012-08-26 20:48:53 +00:00
</text>
2012-08-24 21:53:21 +00:00
2012-08-26 20:48:53 +00:00
<text >
<halign > left</halign>
2015-05-03 16:13:50 +00:00
<label > Your modified joystick configuration is saved automatically. You can reset the configuration to the default by pressing Reset Configuration. </label>
2012-08-26 20:48:53 +00:00
</text>
<hrule />
2012-08-24 21:53:21 +00:00
<!-- Joystick selector -->
<group >
<layout > table</layout>
<halign > left</halign>
<text >
<row > 0</row>
<col > 0</col>
<halign > right</halign>
2012-08-26 20:48:53 +00:00
<label > Joystick:</label>
2012-08-24 21:53:21 +00:00
</text>
<combo >
<name > jsselect</name>
<row > 0</row>
<col > 1</col>
<halign > left</halign>
<property > /sim/gui/dialogs/joystick-config/selected-joystick</property>
<pref-width > 350</pref-width>
<binding >
<command > dialog-apply</command>
<object-name > jsselect</object-name>
</binding>
<binding >
<command > nasal</command>
<script >
fgcommand("dialog-close", props.Node.new({"dialog-name": "joystick-config"}));
fgcommand("dialog-show", props.Node.new({"dialog-name": "joystick-config"}));
</script>
</binding>
</combo>
2012-08-26 20:48:53 +00:00
<button >
<row > 0</row>
<col > 2</col>
<halign > center</halign>
2012-12-07 22:42:18 +00:00
<legend > Reset Configuration</legend>
<binding >
<command > nasal</command>
<script >
joystick.resetConfig();
fgcommand("reinit", props.Node.new({"subsystem": "input"}));
fgcommand("dialog-close", props.Node.new({"dialog-name": "joystick-config"}));
fgcommand("dialog-show", props.Node.new({"dialog-name": "joystick-config"}));
</script>
</binding>
</button>
<button >
<row > 0</row>
<col > 3</col>
<halign > center</halign>
2012-08-26 20:48:53 +00:00
<legend > Refresh Joysticks</legend>
<binding >
<command > nasal</command>
<script >
fgcommand("reinit", props.Node.new({"subsystem": "input"}));
fgcommand("dialog-close", props.Node.new({"dialog-name": "joystick-config"}));
fgcommand("dialog-show", props.Node.new({"dialog-name": "joystick-config"}));
</script>
</binding>
</button>
2012-08-24 21:53:21 +00:00
<text >
<row > 1</row>
<col > 0</col>
<halign > right</halign>
2015-05-03 16:13:50 +00:00
<label > Configuration File:</label>
2012-08-24 21:53:21 +00:00
</text>
<text >
<row > 1</row>
<col > 1</col>
2012-12-07 22:42:18 +00:00
<colspan > 3</colspan>
2012-08-24 21:53:21 +00:00
<halign > left</halign>
<label > Joystick Confgig</label>
<property > /sim/gui/dialogs/joystick-config/selected-joystick-config</property>
</text>
</group>
<hrule />
<group >
<layout > hbox</layout>
<valign > top</valign>
<halign > fill</halign>
<!-- Axis list -->
<group >
<layout > table</layout>
<valign > top</valign>
<name > axistable</name>
<!-- Header Row -->
<text >
<row > 0</row>
<col > 0</col>
<label > Axis</label>
</text>
<text >
<row > 0</row>
<col > 1</col>
<label > Input</label>
</text>
<text >
<row > 0</row>
<col > 2</col>
<label > Control</label>
</text>
<text >
<row > 0</row>
<col > 3</col>
<label > Inverted?</label>
</text>
2012-08-26 20:48:53 +00:00
<!-- Axes get added here -->
2012-08-24 21:53:21 +00:00
</group>
<vrule />
<!-- Buttons -->
<group >
<layout > table</layout>
<valign > top</valign>
<name > buttontable</name>
<!-- Header row -->
<text >
<row > 0</row> <col > 0</col>
<label > Input</label>
</text>
<text >
<row > 0</row> <col > 1</col>
<label > Control</label>
</text>
<text >
<row > 0</row> <col > 2</col>
<label > Input</label>
</text>
<text >
<row > 0</row> <col > 3</col>
<label > Control</label>
</text>
<text >
<row > 0</row> <col > 4</col>
<label > Input</label>
</text>
<text >
<row > 0</row> <col > 5</col>
<label > Control</label>
</text>
2012-08-26 20:48:53 +00:00
<!-- Buttons get added here -->
2012-08-24 21:53:21 +00:00
</group>
</group>
2012-08-26 20:48:53 +00:00
<hrule />
<group >
<layout > table</layout>
<default-padding > 2</default-padding>
<empty >
<width > 150</width>
<col > 0</col>
<row > 0</row>
</empty>
<text >
<label > Aileron: </label>
<halign > right</halign>
<col > 1</col>
<row > 0</row>
</text>
<text >
<label > -0.00000</label>
<halign > left</halign>
<format > %.5f</format>
<property > /controls/flight/aileron</property>
<live > 1</live>
<col > 2</col>
<row > 0</row>
</text>
<text >
<label > Elevator: </label>
<halign > right</halign>
<col > 1</col>
<row > 1</row>
</text>
<text >
<label > -0.00000</label>
<halign > left</halign>
<format > %.5f</format>
<property > /controls/flight/elevator</property>
<live > 1</live>
<col > 2</col>
<row > 1</row>
</text>
<text >
<label > Rudder: </label>
<halign > right</halign>
<col > 3</col>
<row > 0</row>
</text>
<text >
<label > -0.00000</label>
<halign > left</halign>
<format > %.5f</format>
<property > /controls/flight/rudder</property>
<live > 1</live>
<col > 4</col>
<row > 0</row>
</text>
<text >
<label > Throttle: </label>
<halign > right</halign>
<col > 3</col>
<row > 1</row>
</text>
<text >
<label > -0.00000</label>
<halign > left</halign>
<format > %.5f</format>
<property > /controls/engines/engine/throttle</property>
<live > 1</live>
<col > 4</col>
<row > 1</row>
</text>
<empty >
<width > 150</width>
<col > 5</col>
<row > 0</row>
</empty>
</group>
2012-08-24 21:53:21 +00:00
<hrule />
<!-- Button bar -->
<group >
<layout > hbox</layout>
<empty >
<stretch > true</stretch>
</empty>
<button >
<legend > Close</legend>
<binding >
<command > dialog-close</command>
</binding>
</button>
<empty >
<stretch > true</stretch>
</empty>
</group>
</PropertyList>