1 contributor
<?xml version="1.0"?>
<!--
Buttons 1, 11 and 12 are modifiers
Modifier | | button 1 | button 11 | button 12
=============================================================================================
Hat up | look up | zoom in | trim elevator up |
Hat down | look down | zoom out | trim elevator down |
Hat left | look left | reset FoV + heading | trim rudder left | trim aileron left
Hat right | look right | reset FoV | trim rudder right | trim aileron right
Button 2 | heli view | permanent heli view | show/hide pins | declutter pins
Button 3 | brakes | | |
Button 4 | PTT COMM 1 | PTT COMM 2 | |
Button 5 | flaps down | inHg += 0.01 | |
Button 6 | flaps up | inHg -= 0.01 | control all engines | uncontrol all engines
Button 7 | inc mixture | | control engine 2 | uncontrol engine 2
Button 8 | dec mixture | | control engine 3 | uncontrol engine 3
Button 9 | inc proppitch | | control engine 1 | uncontrol engine 1
Button 10 | dec proppitch | | control engine 0 | uncontrol engine 0
Mouse mode:
the mouse mode to control aicraft will be disabled, and restored at the end of the session.
Pressing button 2 will also set the mouse mode to control the view direction, and restore its previous
state when back to normal view
-->
<PropertyList>
<nasal>
<script><![CDATA[
var skipFlightControls = props.globals.getNode("/sim/mouse/skip-flight-controls-mode");
setlistener("/sim/signals/fdm-initilized", func {
skipFlightControls.setBoolValue(1);
print("JOYSTICK set mouse flight control OFF: ", skipFlightControls.getValue());
}, 1 );
setlistener("/sim/signals/save", func {
skipFlightControls.setBoolValue(0);
print("JOYSTICK save mouse flight control ON: ", skipFlightControls.getValue());
} );
# determine Nasal namespace for this joystick
# stored in js[0]
string.scanf(cmdarg().getNode("module").getValue(), "__js%u", var js = []);
# array with prop path for each button status
var pressed_button = [];
for (var i = 0; i < 12; i += 1)
append(pressed_button, "/devices/status/joysticks/joystick[" ~ js[0] ~ "]/button[" ~ i ~ "]");
var previousMouseMode = 0;
var locked_view = 0;
var chinese_hat = func (heading, pitch) {
if (getprop(pressed_button[0])) {
if (pitch > 0) view.decrease();
elsif (pitch < 0) view.increase();
elsif (heading > 0){view.resetViewDir();view.resetFOV();}
elsif (heading < 0) view.resetFOV();
}
elsif (getprop(pressed_button[10])) {
if (pitch)
controls.elevatorTrim(pitch);
else
controls.rudderTrim(heading);
}
elsif (getprop(pressed_button[11]) and heading) {
controls.aileronTrim(-heading);
}
else {
if (heading) {
fgcommand("property-adjust", {
property : "/sim/current-view/goal-heading-offset-deg",
step : 2.0 * heading
});
}
elsif (pitch) {
fgcommand("property-adjust", {
property : "/sim/current-view/goal-pitch-offset-deg",
step : 2.0 * pitch
});
}
}
}
var addSelectedEngine = func (i) {
controls.engines[i].selected.setBoolValue(1);
printf("engine %d added to joystick controls", i);
gui.popupTip("engine " ~ i ~ " joystick controlled");
}
var removeSelectedEngine = func (i) {
controls.engines[i].selected.setBoolValue(0);
printf("engine %d removed from joystick controls", i);
gui.popupTip("engine " ~ i ~ " joystick uncontrolled");
}
# key = button identifier as displayed on joystick
joystick_button = {
2 : func (pressed) {
if (pressed) {
if (getprop(pressed_button[10])) {
setprop("/sim/marker-pins/master", !getprop("/sim/marker-pins/master"));
}
elsif (getprop(pressed_button[11])) {
var clutter = {
"airports": 1,
"pois" : 2,
"traffic" : 4,
"navaids" : 8,
"fixes" : 16
};
var clutter_sum = 0;
foreach (var c; keys(clutter)) {
clutter_sum += getprop("/sim/marker-pins/" ~ c) * clutter[c]
}
if (clutter_sum == 1) {
setprop("/sim/marker-pins/fixes", 0);
setprop("/sim/marker-pins/navaids", 0);
setprop("/sim/marker-pins/airports", 1);
setprop("/sim/marker-pins/pois", 1);
setprop("/sim/marker-pins/traffic", 0);
gui.popupTip("Pins: AIRPORTS + POI", 1);
}
elsif (clutter_sum == 3) {
setprop("/sim/marker-pins/fixes", 0);
setprop("/sim/marker-pins/navaids", 0);
setprop("/sim/marker-pins/airports", 0);
setprop("/sim/marker-pins/pois", 0);
setprop("/sim/marker-pins/traffic", 1);
gui.popupTip("Pins: TRAFFIC", 1);
}
elsif (clutter_sum == 4) {
setprop("/sim/marker-pins/fixes", 1);
setprop("/sim/marker-pins/navaids", 1);
setprop("/sim/marker-pins/airports", 1);
setprop("/sim/marker-pins/pois", 0);
setprop("/sim/marker-pins/traffic", 0);
gui.popupTip("Pins: AIRPORTS + NAVAIDS + FIXES", 1);
}
else {
setprop("/sim/marker-pins/fixes", 0);
setprop("/sim/marker-pins/navaids", 0);
setprop("/sim/marker-pins/airports", 1);
setprop("/sim/marker-pins/pois", 0);
setprop("/sim/marker-pins/traffic", 0);
gui.popupTip("Pins: AIRPORTS", 1);
}
setprop("/sim/marker-pins/master", 1);
}
else {
locked_view = getprop(pressed_button[0]);
setprop("/devices/status/mice/mouse[0]/mode", 2);
setprop("/sim/current-view/view-number", 1);
}
}
else {
if (locked_view)
return;
setprop("/devices/status/mice/mouse[0]/mode", 0);
setprop("/sim/current-view/view-number", 0);
}
},
3 : func (pressed) {
controls.applyBrakes(pressed)
},
4 : func (pressed) {
if (pressed) {
var comm = getprop(pressed_button[0]) + 1;
controls.ptt(comm);
gui.popupTip("PTT COMM " ~ comm);
}
else {
controls.ptt(0);
gui.popupTip("PTT COMM ends", 0.5);
}
},
5 : func {
if (getprop(pressed_button[0]))
fgcommand("property-adjust", {
property: "/instrumentation/altimeter/setting-inhg",
step: 0.01
});
else
controls.flapsDown(1)
},
6 : func {
if (getprop(pressed_button[0]))
fgcommand("property-adjust", {
property: "/instrumentation/altimeter/setting-inhg",
step: -0.01
});
elsif (getprop(pressed_button[10])) {
for (var i = 0; i < 4; i += 1)
controls.engines[i].selected.setBoolValue(1);
printf("all engines added to joystick controls");
gui.popupTip("joystick controls all engines");
}
elsif (getprop(pressed_button[11])) {
for (var i = 0; i < 4; i += 1)
controls.engines[i].selected.setBoolValue(0);
printf("joystick controls no engines", i);
gui.popupTip("joystick controls no engine");
}
else
controls.flapsDown(-1)
},
7 : func {
if (getprop(pressed_button[10])) addSelectedEngine(2);
elsif (getprop(pressed_button[11])) removeSelectedEngine(2);
else controls.adjMixture(-0.1);
},
8 : func {
if (getprop(pressed_button[10])) addSelectedEngine(3);
elsif (getprop(pressed_button[11])) removeSelectedEngine(3);
else controls.adjMixture(0.1);
},
9 : func {
if (getprop(pressed_button[10])) addSelectedEngine(1);
elsif (getprop(pressed_button[11])) removeSelectedEngine(1);
else controls.adjPropeller(0.1);
},
10 : func {
if (getprop(pressed_button[10])) addSelectedEngine(0);
elsif (getprop(pressed_button[11])) removeSelectedEngine(0);
else controls.adjPropeller(-0.1);
},
}
]]></script>
</nasal>
<name type="string">T.Flight Stick X</name>
<name type="string">Thrustmaster T.Flight Stick X</name>
<axis n="0">
<desc>Aileron</desc>
<binding>
<command>property-scale</command>
<property>/controls/flight/aileron</property>
<squared type="bool">true</squared>
</binding>
</axis>
<axis n="1">
<desc>Elevator</desc>
<binding>
<command>property-scale</command>
<property>/controls/flight/elevator</property>
<factor type="double">-1.0</factor>
<squared type="bool">true</squared>
</binding>
</axis>
<axis>
<number>
<windows>2</windows>
<unix>3</unix>
</number>
<desc>Increase/Reduce Throttle</desc>
<binding>
<command>nasal</command>
<script>controls.throttleAxis()</script>
</binding>
</axis>
<axis>
<number>
<windows>3</windows>
<unix>2</unix>
</number>
<desc>Rudder Left/Right</desc>
<binding>
<command>property-scale</command>
<property>/controls/flight/rudder</property>
<factor type="double">1.0</factor>
</binding>
</axis>
<axis>
<number>
<windows>6</windows>
<unix>4</unix>
</number>
<desc>View Direction | reset FoV | reset view direction</desc>
<low>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>chinese_hat(1, 0)</script>
</binding>
</low>
<high>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>chinese_hat(-1, 0)</script>
</binding>
</high>
</axis>
<axis>
<number>
<windows>7</windows>
<unix>5</unix>
</number>
<desc>Orientation up or down / Increase or decrease FoV</desc>
<low>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>chinese_hat(0, 1)</script>
</binding>
</low>
<high>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>chinese_hat(0, -1)</script>
</binding>
</high>
</axis>
<button n="1">
<desc>Swap first and second views | pins POIs</desc>
<binding>
<command>nasal</command>
<script>joystick_button[2](1)</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>joystick_button[2](0)</script>
</binding>
</mod-up>
</button>
<button n="2">
<desc>Apply brakes</desc>
<binding>
<command>nasal</command>
<script>joystick_button[3](1)</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>joystick_button[3](0)</script>
</binding>
</mod-up>
</button>
<button n="3">
<desc>PTT - Push To Talk (via FGCom)</desc>
<binding>
<command>nasal</command>
<script>joystick_button[4](1)</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>joystick_button[4](0)</script>
</binding>
</mod-up>
</button>
<button n="4">
<desc>Extend Flaps Incrementally</desc>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>joystick_button[5]()</script>
</binding>
</button>
<button n="5">
<desc>Retract Flaps Incrementally</desc>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>joystick_button[6]()</script>
</binding>
</button>
<button n="6">
<desc>Handle mixture | add or remove engine 0</desc>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>joystick_button[7]()</script>
</binding>
</button>
<button n="7">
<desc>Handle mixture | add or remove engine 1</desc>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>joystick_button[8]()</script>
</binding>
</button>
<button n="8">
<desc>Handle prop-pitch | add or remove engine 2</desc>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>joystick_button[9]()</script>
</binding>
</button>
<button n="9">
<desc>Handle prop-pitch | add or remove engine 3</desc>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>joystick_button[10]()</script>
</binding>
</button>
</PropertyList>
<!-- end of T.Flight Stick X.xml -->