make axis wrappers a tad faster (and a whole lot cooler :-)
This commit is contained in:
parent
c35f3207d3
commit
30f3dff563
1 changed files with 13 additions and 15 deletions
|
@ -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) {
|
||||||
|
func(invert = 0) {
|
||||||
var val = cmdarg().getNode("setting").getValue();
|
var val = cmdarg().getNode("setting").getValue();
|
||||||
if(invert) val = -val;
|
if(invert) val = -val;
|
||||||
foreach(var e; engines)
|
foreach(var e; engines)
|
||||||
if(e.selected.getValue())
|
if(e.selected.getValue())
|
||||||
setprop(pre ~ e.index ~ post, (1 - val)/2);
|
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
|
||||||
|
|
Loading…
Reference in a new issue