464 lines
11 KiB
XML
464 lines
11 KiB
XML
|
<?xml version="1.0"?>
|
||
|
|
||
|
<PropertyList>
|
||
|
<nasal>
|
||
|
<open><![CDATA[
|
||
|
|
||
|
|
||
|
var dlgRoot = cmdarg();
|
||
|
|
||
|
# Debug only
|
||
|
io.load_nasal("/home/stuart/FlightGear/data/Nasal/joystick.nas");
|
||
|
|
||
|
|
||
|
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");
|
||
|
var jsselect = gui.findElementByName(dlgRoot, "jsselect" );
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
var table = gui.findElementByName(dlgRoot, "axistable");
|
||
|
table.removeChildren("checkbox");
|
||
|
table.removeChildren("combo");
|
||
|
|
||
|
# 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);
|
||
|
|
||
|
# Binding
|
||
|
t = table.getChild("combo", i, 1);
|
||
|
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");
|
||
|
|
||
|
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 = t.getChild("binding", 1, 1);
|
||
|
b.getNode("command", 1).setValue("nasal");
|
||
|
b.getNode("script", 1).setValue("updateConfig();");
|
||
|
|
||
|
# 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(130);
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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>
|
||
|
|
||
|
<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>
|
||
|
|
||
|
<!-- Joystick selector -->
|
||
|
<group>
|
||
|
<layout>table</layout>
|
||
|
<halign>left</halign>
|
||
|
|
||
|
<text>
|
||
|
<row>0</row>
|
||
|
<col>0</col>
|
||
|
<halign>right</halign>
|
||
|
<label>Joystick</label>
|
||
|
</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>
|
||
|
|
||
|
<text>
|
||
|
<row>1</row>
|
||
|
<col>0</col>
|
||
|
<halign>right</halign>
|
||
|
<label>Configuration File</label>
|
||
|
</text>
|
||
|
|
||
|
<text>
|
||
|
<row>1</row>
|
||
|
<col>1</col>
|
||
|
<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>
|
||
|
|
||
|
|
||
|
<!-- Axes get added here based on above template -->
|
||
|
|
||
|
</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>
|
||
|
|
||
|
<buttontemplate>
|
||
|
<name>buttontemplate</name>
|
||
|
|
||
|
<checkbox>
|
||
|
<row>1</row><col>0</col>
|
||
|
<halign>right</halign>
|
||
|
<live>1</live>
|
||
|
<readonly>1</readonly>
|
||
|
<property>/devices/status/joysticks/joystick[0]/button[0]</property>
|
||
|
</checkbox>
|
||
|
|
||
|
<text>
|
||
|
<row>1</row><col>1</col>
|
||
|
<property>/sim/gui/dialogs/joystick-config/button[0]</property>
|
||
|
<label>01234567890</label>
|
||
|
<halign>left</halign>
|
||
|
<live>true</live>
|
||
|
</text>
|
||
|
|
||
|
<button>
|
||
|
<row>1</row><col>2</col>
|
||
|
<legend>...</legend>
|
||
|
<binding>
|
||
|
<command>property-assign</command>
|
||
|
<property>/sim/gui/dialogs/joystick-config/current-button</property>
|
||
|
<value>0</value>
|
||
|
</binding>
|
||
|
<binding>
|
||
|
<command>dialog-show</command>
|
||
|
<dialog-name>button-config</dialog-name>
|
||
|
</binding>
|
||
|
</button>
|
||
|
</buttontemplate>
|
||
|
|
||
|
<!-- Buttons get added here based on above template -->
|
||
|
|
||
|
</group>
|
||
|
</group>
|
||
|
|
||
|
<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>
|