1
0
Fork 0

Add Joystick Config dialog for individual engines

This commit is contained in:
Stuart Buchanan 2017-04-20 21:06:42 +01:00
parent 60f63cb2af
commit 5c62d4663c
2 changed files with 28 additions and 19 deletions

View file

@ -110,9 +110,9 @@ var perIndexAxisHandler = func(pre, post) {
# 2 - propeller-pitch
# The argument engine to the returned function can be either an
# engine number or a list of engine numbers.
# Usage example (controlling the mixture of engines 1 and 2):
# Usage example (controlling the mixture of engines 0 and 1):
# <script>
# controls.perEngineSelectedAxisHandler(1)([1,2]);
# controls.perEngineSelectedAxisHandler(1)([0,1]);
# </script>
var _axisMode = {
0: perIndexAxisHandler("/controls/engines/engine[",
@ -513,19 +513,19 @@ var speedup = func(speed_up)
t = (t < 32) ? t*2 : 32;
}
setprop("/sim/speed-up", t);
# reformat as a string, this is borrowed from replay.xml
if (t<0.9)
{
t=1/t; # invert the value
t = "1/" ~ t; # convert to a string and show inverted
}
gui.popupTip("Time speed-up: " ~ t ~ "x");
}
# mouse-mode handling
# mouse-mode handling
var cycleMouseMode = func(node)
{
@ -535,36 +535,36 @@ var cycleMouseMode = func(node)
return;
}
}
var modeNode = props.globals.getNode('/devices/status/mice/mouse[0]/mode');
var modeNode = props.globals.getNode('/devices/status/mice/mouse[0]/mode');
var mode = modeNode.getValue() + 1;
if ((mode == 1) and getprop('/sim/mouse/skip-flight-controls-mode')) {
mode +=1;
}
if (mode == 3) mode = 0;
modeNode.setIntValue(mode);
# this is really a 'show on-screen hints' control
if (getprop('/sim/view-name-popup') == 0)
return;
# some people like popups but strongly object to this one. As you wish.
# some people like popups but strongly object to this one. As you wish.
if (getprop('/sim/mouse/cycle-mode-popup') == 0)
return;
if (mode == 0) {
fgcommand("clear-message", props.Node.new({ "id":"mouse-mode" }));
return;
}
var msg = "";
if (mode == 1)
msg = "Mouse is controlling flight controls. Press TAB to change.";
else
msg = "Mouse is controlling view direction. Press TAB to change.";
fgcommand("show-message", props.Node.new({ "label": msg, "id":"mouse-mode" }));
}

View file

@ -257,9 +257,18 @@ var axisBindings = [
PropertyScaleAxis.new("Aileron", "/controls/flight/aileron"),
PropertyScaleAxis.new("Elevator", "/controls/flight/elevator"),
PropertyScaleAxis.new("Rudder", "/controls/flight/rudder"),
NasalScaleAxis.new("Throttle", "controls.throttleAxis();", "/controls/engines/engine[0]/throttle") ,
NasalScaleAxis.new("Mixture", "controls.mixtureAxis();", "/controls/engines/engine[0]/mixture") ,
NasalScaleAxis.new("Propeller", "controls.propellerAxis();", "/controls/engines/engine[0]/propeller-pitch") ,
NasalScaleAxis.new("Throttle (all)", "controls.throttleAxis();", "/controls/engines/engine[0]/throttle") ,
NasalScaleAxis.new("Mixture (all)", "controls.mixtureAxis();", "/controls/engines/engine[0]/mixture") ,
NasalScaleAxis.new("Propeller (all)", "controls.propellerAxis();", "/controls/engines/engine[0]/propeller-pitch") ,
# Controls of individual throttles, mixtures, propellers
NasalScaleAxis.new("Throttle 1", "controls.perEngineSelectedAxisHandler(0)([0]);", "/controls/engines/engine[0]/throttle") ,
NasalScaleAxis.new("Mixture 1", "controls.perEngineSelectedAxisHandler(1)([0]);", "/controls/engines/engine[0]/mixture") ,
NasalScaleAxis.new("Propeller 1", "controls.perEngineSelectedAxisHandler(2)([0]);", "/controls/engines/engine[0]/propeller-pitch") ,
NasalScaleAxis.new("Throttle 2", "controls.perEngineSelectedAxisHandler(0)([1]);", "/controls/engines/engine[1]/throttle") ,
NasalScaleAxis.new("Mixture 2", "controls.perEngineSelectedAxisHandler(1)([1]);", "/controls/engines/engine[1]/mixture") ,
NasalScaleAxis.new("Propeller 2", "controls.perEngineSelectedAxisHandler(2)([1]);", "/controls/engines/engine[1]/propeller-pitch") ,
NasalLowHighAxis.new("View (horizontal)",
"setprop(\"/sim/current-view/goal-heading-offset-deg\", getprop(\"/sim/current-view/goal-heading-offset-deg\") + 30);",
"setprop(\"/sim/current-view/goal-heading-offset-deg\", getprop(\"/sim/current-view/goal-heading-offset-deg\") - 30);",