1
0
Fork 0

make axis wrappers a tad faster (and a whole lot cooler :-)

This commit is contained in:
mfranz 2008-01-30 21:52:29 +00:00
parent c35f3207d3
commit 30f3dff563

View file

@ -55,22 +55,20 @@ var throttleMouse = func {
} }
# Joystick axis handlers (uses cmdarg). Shouldn't be called from # Joystick axis handlers (uses cmdarg). Shouldn't be called from
# other contexts. # other contexts. A non-null argument inverts the direction of the axis.
var adjustAxis = func(invert, pre, post) { var axisHandler = func(pre, post) {
var val = cmdarg().getNode("setting").getValue(); func(invert = 0) {
if(invert) val = -val; var val = cmdarg().getNode("setting").getValue();
foreach(var e; engines) if(invert) val = -val;
if(e.selected.getValue()) foreach(var e; engines)
setprop(pre ~ e.index ~ post, (1 - val)/2); if(e.selected.getValue())
setprop(pre ~ e.index ~ post, (1 - val) / 2);
}
} }
var throttleAxis = func var throttleAxis = axisHandler("/controls/engines/engine[", "]/throttle");
adjustAxis(size(arg), "/controls/engines/engine[", "]/throttle"); var mixtureAxis = axisHandler("/controls/engines/engine[", "]/mixture");
var mixtureAxis = func var propellerAxis = axisHandler("/controls/engines/engine[", "]/propeller-pitch");
adjustAxis(size(arg), "/controls/engines/engine[", "]/mixture"); var carbHeatAxis = axisHandler("/controls/anti-ice/engine[", "]/carb-heat");
var propellerAxis = func
adjustAxis(size(arg), "/controls/engines/engine[", "]/propeller-pitch");
var carbHeatAxis = func
adjustAxis(size(arg), "/controls/anti-ice/engine[", "]/carb-heat");
## ##
# Wrapper around stepProps() which emulates the "old" flap behavior for # Wrapper around stepProps() which emulates the "old" flap behavior for