1
0
Fork 0

warthog: don't attach listener again on "Reload Input"; fix overlay path

This commit is contained in:
Melchior FRANZ 2011-09-22 18:10:51 +02:00
parent 321f9f6bbd
commit 4cdc3a64aa
2 changed files with 11 additions and 5 deletions

View file

@ -16,6 +16,7 @@
<command>nasal</command> <command>nasal</command>
<script> <script>
var this = cmdarg().getParent(); var this = cmdarg().getParent();
var init = !contains(caller(0)[0], "init");
var popup = func gui.popupTip(call(sprintf, arg)); var popup = func gui.popupTip(call(sprintf, arg));
var is_helicopter = (var _ = props.globals.getNode("rotors", 0)) != nil and _.getAttribute("children"); var is_helicopter = (var _ = props.globals.getNode("rotors", 0)) != nil and _.getAttribute("children");
var aircraft_type = getprop("/sim/type"); var aircraft_type = getprop("/sim/type");
@ -23,7 +24,7 @@
var load_overlay = func(name) { var load_overlay = func(name) {
foreach (var dir; [getprop("/sim/fg-home"), getprop("/sim/fg-root")]) { foreach (var dir; [getprop("/sim/fg-home"), getprop("/sim/fg-root")]) {
var file = dir ~ "/Input/Joysticks/ThrustMaster/Warthog/Joystick/" ~ 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().getNode("script").setValue("");
@ -42,8 +43,10 @@
} }
var mod = 0; var mod = 0;
if (init) {
var _ = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT"); var _ = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT");
setlistener(_, func(n) mod = n.getValue()); setlistener(_, func(n) mod = n.getValue());
}
var trimstep = 0.75; var trimstep = 0.75;
var viewstep = 0.5; var viewstep = 0.5;

View file

@ -12,6 +12,7 @@
<command>nasal</command> <command>nasal</command>
<script> <script>
var this = cmdarg().getParent(); var this = cmdarg().getParent();
var init = !contains(caller(0)[0], "init");
var popup = func gui.popupTip(call(sprintf, arg)); var popup = func gui.popupTip(call(sprintf, arg));
var is_helicopter = (var _ = props.globals.getNode("rotors", 0)) != nil and _.getAttribute("children"); var is_helicopter = (var _ = props.globals.getNode("rotors", 0)) != nil and _.getAttribute("children");
var aircraft_type = getprop("/sim/type"); var aircraft_type = getprop("/sim/type");
@ -38,8 +39,10 @@
} }
var mod = 0; var mod = 0;
if (init) {
var _ = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT"); var _ = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT");
setlistener(_, func(n) mod = n.getValue()); setlistener(_, func(n) mod = n.getValue());
}
var left_engines = [0, 2, 4, 6, 8, 10]; var left_engines = [0, 2, 4, 6, 8, 10];
var right_engines = [1, 3, 5, 7, 9, 11]; var right_engines = [1, 3, 5, 7, 9, 11];