1
0
Fork 0

Anders GIDENSTAM:

- Page up/down changes the selected throttles one step up/down, i.e.
  if the original throttle settings were x steps apart they remain
  steps apart (unless the boundary is reached).
- Mouse + MMB drag changes the selected throttles by the delta amount
  (length of drag).
- The throttleAxis() wrapper for joysticks sets the selected
  throttles to correspond to the joystick's axis position. I.e. all
  selected engines will get the same throttle setting. Since most
  joystick throttles are positional devices I think this behaviour
  is more logical than using a relative adjustment in this case. """

mf: slightly modified, added var etc. (more such changes in controls.nas
    to come)
This commit is contained in:
mfranz 2007-07-19 16:18:39 +00:00
parent 3ec61cdd5f
commit 7c2a88a98a

View file

@ -27,6 +27,20 @@ selectEngine = func {
foreach(node; sel) { node.setBoolValue(node.getIndex() == arg[0]); } foreach(node; sel) { node.setBoolValue(node.getIndex() == arg[0]); }
} }
# Selects (state=1) or deselects (state=0) a list of engines, or all
# engines if no list is specified. Example: selectEngines(1, 1, 3, 5);
#
var selectEngines = func (state, engines...) {
var sel = props.globals.getNode("/sim/input/selected");
if(size(engines)) {
foreach(var e; engines)
sel.getChild("engine", e, 1).setBoolValue(state);
} else {
foreach(var e; sel.getChildren("engine"))
e.setBoolValue(state);
}
}
selectAllEngines = func { selectAllEngines = func {
sel = props.globals.getNode("/sim/input/selected").getChildren("engine"); sel = props.globals.getNode("/sim/input/selected").getChildren("engine");
foreach(node; sel) { node.setBoolValue(1); } foreach(node; sel) { node.setBoolValue(1); }
@ -51,20 +65,29 @@ centerFlightControls = func {
setprop("/controls/flight/rudder", 0); setprop("/controls/flight/rudder", 0);
} }
throttleMouse = func { var throttleMouse = func {
if(!getprop("/devices/status/mice/mouse[0]/button[1]")) { return; } if(!getprop("/devices/status/mice/mouse[0]/button[1]")) return;
val = (cmdarg().getNode("offset").getValue() * -4 var sel = props.globals.getNode("/sim/input/selected").getChildren("engine");
+ getprop("/controls/engines/engine/throttle")); var delta = cmdarg().getNode("offset").getValue() * -4;
if(size(arg) > 0) { val = -val; } foreach(var n; sel) {
props.setAll("/controls/engines/engine", "throttle", val); if(!n.getValue()) continue;
var throttle = "/controls/engines/engine[" ~ n.getIndex() ~ "]/throttle";
var val = getprop(throttle) + delta;
if(size(arg) > 0) val = -val;
setprop(throttle, val);
}
} }
# Joystick axis handlers (uses cmdarg). Shouldn't be called from # Joystick axis handlers (uses cmdarg). Shouldn't be called from
# other contexts. # other contexts.
throttleAxis = func { var throttleAxis = func {
val = cmdarg().getNode("setting").getValue(); var val = cmdarg().getNode("setting").getValue();
if(size(arg) > 0) { val = -val; } if(size(arg) > 0) val = -val;
props.setAll("/controls/engines/engine", "throttle", (1 - val)/2); var sel = props.globals.getNode("/sim/input/selected").getChildren("engine");
foreach(var n; sel)
if(n.getValue())
setprop("/controls/engines/engine[" ~ n.getIndex() ~ "]/throttle",
(1 - val)/2);
} }
mixtureAxis = func { mixtureAxis = func {
val = cmdarg().getNode("setting").getValue(); val = cmdarg().getNode("setting").getValue();
@ -216,18 +239,16 @@ adjEngControl = func {
## ##
# arg[0] is the throttle increment # arg[0] is the throttle increment
# arg[1] is the auto-throttle target speed increment # arg[1] is the auto-throttle target speed increment
incThrottle = func { var incThrottle = func {
auto = props.globals.getNode("/autopilot/locks/speed", 1); var auto = props.globals.getNode("/autopilot/locks/speed", 1);
var sel = props.globals.getNode("/sim/input/selected");
if ( !auto.getValue() ) { if ( !auto.getValue() ) {
engs = props.globals.getNode("/controls/engines").getChildren("engine"); var engs = props.globals.getNode("/controls/engines").getChildren("engine");
foreach(e; engs) { foreach(var e; engs) {
node = e.getNode("throttle", 1); if(sel.getChild("engine", e.getIndex(), 1).getBoolValue()) {
node.setValue(node.getValue() + arg[0]); var node = e.getNode("throttle", 1);
if ( node.getValue() < -1.0 ) { var val = node.getValue() + arg[0];
node.setValue( -1.0 ); node.setValue(val < -1.0 ? -1.0 : val > 1.0 ? 1.0 : val);
}
if ( node.getValue() > 1.0 ) {
node.setValue( 1.0 );
} }
} }
} else { } else {