1
0
Fork 0

warthog: tailwheel/reverser/speedbrake + cleanup

Unfortunately, some aircraft (seahawk) don't play nice and ignore the
common speedbrake property, inventing their own. (These basic concepts
must be *really* hard to understand ...)
This commit is contained in:
Melchior FRANZ 2011-09-24 21:26:56 +02:00
parent f4cb3863c8
commit fa1593f9f0
2 changed files with 44 additions and 13 deletions

View file

@ -11,9 +11,9 @@
<PropertyList> <PropertyList>
<name>Thustmaster Joystick - HOTAS Warthog</name> <name>Thustmaster Joystick - HOTAS Warthog</name>
<name>Thrustmaster Joystick - HOTAS Warthog</name> <!-- in case they ever manage to fix their name -->
<nasal> <nasal>
<command>nasal</command>
<script> <script>
var this = cmdarg().getParent(); var this = cmdarg().getParent();
var init = !contains(caller(0)[0], "init"); var init = !contains(caller(0)[0], "init");
@ -27,7 +27,7 @@
var file = dir ~ "/Input/Joysticks/ThrustMaster/Warthog/Stick/" ~ name ~ ".xml"; var file = dir ~ "/Input/Joysticks/ThrustMaster/Warthog/Stick/" ~ name ~ ".xml";
if (io.stat(file) != nil) { if (io.stat(file) != nil) {
printlog("info", "WARTHOG: loading overlay " ~ file); printlog("info", "WARTHOG: loading overlay " ~ file);
cmdarg().getNode("script").setValue(""); cmdarg().setValues({command: "nasal", script: ""});
io.read_properties(file, this); io.read_properties(file, this);
props.runBinding(cmdarg()); props.runBinding(cmdarg());
break; break;
@ -44,13 +44,13 @@
var mod = 0; var mod = 0;
if (init) { if (init) {
var n = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT"); var m = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT");
setlistener(n, func(n) mod = n.getValue()); setlistener(m, func(n) mod = n.getValue());
} }
var trimstep = 0.75; var trimstep = 0.75;
var viewstep = 0.5; var viewstep = 0.5;
var button = { 18: { id: 0 }}; var button = {18: {id: 0}};
var reset_zoom = func setprop("/sim/current-view/field-of-view", 55); var reset_zoom = func setprop("/sim/current-view/field-of-view", 55);
var viewdir = props.globals.getNode("/sim").getChildren("view"); var viewdir = props.globals.getNode("/sim").getChildren("view");
@ -160,6 +160,16 @@
<button n="2"> <button n="2">
<name>Nosewheel Steering Button</name> <name>Nosewheel Steering Button</name>
<desc>toggle nosewheel steering/tailwheel lock</desc>
<binding>
<command>nasal</command>
<script>
var i = !(getprop("/controls/gear/nose-wheel-steering") or 0);
setprop("/controls/gear/nose-wheel-steering", i);
setprop("/controls/gear/tailwheel-lock", !i);
popup("Tail Wheel %sLOCKED!", i ? "UN" : "");
</script>
</binding>
</button> </button>
<button n="3"> <button n="3">
@ -212,7 +222,6 @@
if (mod) { if (mod) {
var i = controls.applyParkingBrake(1); var i = controls.applyParkingBrake(1);
popup("Parking Brake %s", i ? "ON" : "OFF"); popup("Parking Brake %s", i ? "ON" : "OFF");
controls.applyBrakes(0);
} }
controls.applyBrakes(0) controls.applyBrakes(0)
</script> </script>
@ -249,7 +258,6 @@
if (mod) { if (mod) {
var i = controls.applyParkingBrake(1); var i = controls.applyParkingBrake(1);
popup("Parking Brake %s", i ? "ON" : "OFF"); popup("Parking Brake %s", i ? "ON" : "OFF");
controls.applyBrakes(0);
} }
controls.applyBrakes(0) controls.applyBrakes(0)
</script> </script>
@ -380,8 +388,8 @@
<binding> <binding>
<command>nasal</command> <command>nasal</command>
<script> <script>
view.resetView();
button[18].id += 1; button[18].id += 1;
view.resetView();
</script> </script>
</binding> </binding>
</mod-up> </mod-up>

View file

@ -9,7 +9,6 @@
<name>Thrustmaster Throttle - HOTAS Warthog</name> <name>Thrustmaster Throttle - HOTAS Warthog</name>
<nasal> <nasal>
<command>nasal</command>
<script> <script>
var this = cmdarg().getParent(); var this = cmdarg().getParent();
var init = !contains(caller(0)[0], "init"); var init = !contains(caller(0)[0], "init");
@ -23,7 +22,7 @@
var file = dir ~ "/Input/Joysticks/ThrustMaster/Warthog/Throttle/" ~ name ~ ".xml"; var file = dir ~ "/Input/Joysticks/ThrustMaster/Warthog/Throttle/" ~ name ~ ".xml";
if (io.stat(file) != nil) { if (io.stat(file) != nil) {
printlog("info", "WARTHOG: loading overlay " ~ file); printlog("info", "WARTHOG: loading overlay " ~ file);
cmdarg().getNode("script").setValue(""); cmdarg().setValues({command: "nasal", script: ""});
io.read_properties(file, this); io.read_properties(file, this);
props.runBinding(cmdarg()); props.runBinding(cmdarg());
break; break;
@ -40,8 +39,8 @@
var mod = 0; var mod = 0;
if (init) { if (init) {
var n = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT"); var m = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT");
setlistener(n, func(n) mod = n.getValue()); setlistener(m, func(n) mod = n.getValue());
} }
var left_engines = [0, 2, 4, 6, 8, 10]; var left_engines = [0, 2, 4, 6, 8, 10];
@ -191,7 +190,20 @@
</button> </button>
<button n="6"> <button n="6">
<name>Speedbrake Forward</name> <name>Speedbrake Forward (right throttle, top grey)</name>
<desc>apply speed brake</desc>
<binding>
<command>property-assign</command>
<property>/controls/flight/speedbrake</property>
<value>1</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/controls/flight/speedbrake</property>
<value>0</value>
</binding>
</mod-up>
</button> </button>
<button n="7"> <button n="7">
@ -204,6 +216,17 @@
<button n="9"> <button n="9">
<name>Boat Switch Aft</name> <name>Boat Switch Aft</name>
<desc>apply thrust reverser</desc>
<binding>
<command>nasal</command>
<script>props.setAll("/controls/engines/engine", "reverser", 1)</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>props.setAll("/controls/engines/engine", "reverser", 0)</script>
</binding>
</mod-up>
</button> </button>
<button n="10"> <button n="10">