a6c2cfa172
These files take complexity out of the main joystick file, while not adding much code. They also update the description (<desc>) used by the Help->Joystick information dialog. All <nasal> code is executed in the joystick's namespace, so variables and funtions of the main file (popup()) can be accessed.
239 lines
5.4 KiB
XML
239 lines
5.4 KiB
XML
<?xml version="1.0"?>
|
|
<!--
|
|
Copyright (c) 2011 Melchior FRANZ mfranz # aon : at
|
|
Work In Progress
|
|
-->
|
|
|
|
<PropertyList>
|
|
<name>Thustmaster Joystick - HOTAS Warthog</name>
|
|
|
|
<nasal>
|
|
<command>nasal</command>
|
|
<script>
|
|
var this = cmdarg().getParent();
|
|
var popup = func gui.popupTip(call(sprintf, arg));
|
|
var is_helicopter = (var _ = props.globals.getNode("rotors", 0)) != nil and _.getAttribute("children");
|
|
|
|
var load_overlay = func(name) {
|
|
foreach (var dir; [getprop("/sim/fg-home"), getprop("/sim/fg-root")]) {
|
|
var file = dir ~ "/Input/Joysticks/ThrustMaster/Warthog/Joystick/" ~ name;
|
|
if (io.stat(file) != nil) {
|
|
printlog("info", "WARTHOG: loading overlay " ~ file);
|
|
cmdarg().getNode("script").setValue("");
|
|
io.read_properties(file, this);
|
|
props.runBinding(cmdarg());
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var b; this.getChildren("button")) {
|
|
if (b.getAttribute("children") == 1) {
|
|
var name = b.getNode("name", 1).getValue() or "??";
|
|
b.setValues({binding: {command: "nasal", script: 'popup("' ~ name ~ '")'}});
|
|
}
|
|
}
|
|
|
|
var mod = 0;
|
|
var _ = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT");
|
|
setlistener(_, func(n) mod = n.getValue());
|
|
|
|
var trimstep = 0.75;
|
|
|
|
load_overlay("generic.xml");
|
|
if (is_helicopter)
|
|
load_overlay("helicopter.xml");
|
|
load_overlay(getprop("/sim/aircraft") ~ ".xml");
|
|
</script>
|
|
</nasal>
|
|
|
|
<axis n="0">
|
|
<name>X-axis</name>
|
|
<desc>aileron</desc>
|
|
<tolerance>0.00001</tolerance>
|
|
<binding>
|
|
<command>property-scale</command>
|
|
<property>/controls/flight/aileron</property>
|
|
</binding>
|
|
</axis>
|
|
|
|
<axis n="1">
|
|
<name>Y-axis</name>
|
|
<desc>elevator</desc>
|
|
<tolerance>0.00001</tolerance>
|
|
<binding>
|
|
<command>property-scale</command>
|
|
<property>/controls/flight/elevator</property>
|
|
<factor type="double">-1.0</factor>
|
|
</binding>
|
|
</axis>
|
|
|
|
<axis n="2">
|
|
<name>Trim Coolie Left/Right</name>
|
|
<desc>adjust aileron trim, +mod: reset aileron trim</desc>
|
|
<low>
|
|
<repeatable>true</repeatable>
|
|
<binding>
|
|
<command>nasal</command>
|
|
<script>
|
|
if (mod)
|
|
controls.aileronTrim(-trimstep);
|
|
else
|
|
setprop("/controls/flight/aileron-trim", 0);
|
|
</script>
|
|
</binding>
|
|
</low>
|
|
<high>
|
|
<repeatable>true</repeatable>
|
|
<binding>
|
|
<command>nasal</command>
|
|
<script>
|
|
if (mod)
|
|
controls.aileronTrim(trimstep);
|
|
else
|
|
setprop("/controls/flight/aileron-trim", 0);
|
|
</script>
|
|
</binding>
|
|
</high>
|
|
</axis>
|
|
|
|
<axis n="3">
|
|
<name>Trim Coolie Down/Up</name>
|
|
<desc>adjust elevator trim, +mod: reset elevator trim</desc>
|
|
<low>
|
|
<repeatable>true</repeatable>
|
|
<binding>
|
|
<command>nasal</command>
|
|
<script>
|
|
if (mod)
|
|
controls.elevatorTrim(trimstep);
|
|
else
|
|
setprop("/controls/flight/elevator-trim", 0);
|
|
</script>
|
|
</binding>
|
|
</low>
|
|
<high>
|
|
<repeatable>true</repeatable>
|
|
<binding>
|
|
<command>nasal</command>
|
|
<script>
|
|
if (mod)
|
|
controls.elevatorTrim(-trimstep);
|
|
else
|
|
setprop("/controls/flight/elevator-trim", 0);
|
|
</script>
|
|
</binding>
|
|
</high>
|
|
</axis>
|
|
|
|
<button n="0">
|
|
<name>Trigger Button/Half Pushed</name>
|
|
<desc>gun trigger stage 1</desc>
|
|
<binding>
|
|
<command>nasal</command>
|
|
<script>controls.trigger(1)</script>
|
|
</binding>
|
|
<mod-up>
|
|
<binding>
|
|
<command>nasal</command>
|
|
<script>controls.trigger(0)</script>
|
|
</binding>
|
|
</mod-up>
|
|
</button>
|
|
|
|
<button n="1">
|
|
<name>Weapons Release</name>
|
|
</button>
|
|
|
|
<button n="2">
|
|
<name>Nosewheel Steering Button</name>
|
|
</button>
|
|
|
|
<button n="3">
|
|
<name>Paddle Switch</name>
|
|
<desc>modifier button</desc>
|
|
<binding>
|
|
<command>property-assign</command>
|
|
<property>/devices/status/joysticks/warthog/modifier</property>
|
|
<value>1</value>
|
|
</binding>
|
|
<mod-up>
|
|
<binding>
|
|
<command>property-assign</command>
|
|
<property>/devices/status/joysticks/warthog/modifier</property>
|
|
<value>0</value>
|
|
</binding>
|
|
</mod-up>
|
|
</button>
|
|
|
|
<button n="4">
|
|
<name>Master Mode Control Button</name>
|
|
</button>
|
|
|
|
<button n="5">
|
|
<name>Trigger Button/Fully Pushed</name>
|
|
<desc>gun trigger stage 2</desc>
|
|
<binding>
|
|
<command>nasal</command>
|
|
<script>controls.trigger(2)</script>
|
|
</binding>
|
|
<mod-up>
|
|
<binding>
|
|
<command>nasal</command>
|
|
<script>controls.trigger(0)</script>
|
|
</binding>
|
|
</mod-up>
|
|
</button>
|
|
|
|
<button n="6">
|
|
<name>Target Management Switch (TMS) up</name>
|
|
</button>
|
|
|
|
<button n="7">
|
|
<name>Target Management Switch (TMS) right</name>
|
|
</button>
|
|
|
|
<button n="8">
|
|
<name>Target Management Switch (TMS) down</name>
|
|
</button>
|
|
|
|
<button n="9">
|
|
<name>Target Management Switch (TMS) left</name>
|
|
</button>
|
|
|
|
<button n="10">
|
|
<name>Data Management Switch (DMS) up</name>
|
|
</button>
|
|
|
|
<button n="11">
|
|
<name>Data Management Switch (DMS) right</name>
|
|
</button>
|
|
|
|
<button n="12">
|
|
<name>Data Management Switch (DMS) down</name>
|
|
</button>
|
|
|
|
<button n="13">
|
|
<name>Data Management Switch (DMS) left</name>
|
|
</button>
|
|
|
|
<button n="14">
|
|
<name>Countermeasures Management Switch (CMS) up</name>
|
|
</button>
|
|
|
|
<button n="15">
|
|
<name>Countermeasures Management Switch (CMS) right</name>
|
|
</button>
|
|
|
|
<button n="16">
|
|
<name>Countermeasures Management Switch (CMS) down</name>
|
|
</button>
|
|
|
|
<button n="17">
|
|
<name>Countermeasures Management Switch (CMS) left</name>
|
|
</button>
|
|
|
|
<button n="18">
|
|
<name>Countermeasures Management Switch (CMS) push</name>
|
|
</button>
|
|
</PropertyList>
|