Investigating a query on the forum, set the following simple settings for a two-throttle ( AV8R) joystick:
<!-- Analog axis 2. Throttle 1 -->
<axis>
<number>
<unix>2</unix>
<mac>3</mac>
<windows>3</windows>
</number>
<desc>Throttles</desc>
<binding>
<command>nasal</command>
<script>
controls.propellerAxis(invert:1);
</script>
</binding>
</axis>
<!-- Analog axis 4. Throttle 2 -->
<axis n="4">
<desc>Prop Pitch; +Trg Mode0: Mixture; </desc>
<binding>
<command>nasal</command>
<script>
controls.throttleAxis(invert:1);
</script>
</binding>
</axis>
moitoring property tree at
/controls/engines/engine/propellor-pitch
and
/controls/engines/engine/throttle
the propellor pitch value is properly inverted while the throttle value is not.
Exchanging the bindings to the alternate axes does not change the situation, while propellorAxis() honours (invert:1) the throttle axis remains unaffected.
Inserting print statements in controls.nas @ 108 ff :
# Joystick axis handlers (use cmdarg). Shouldn't be called from
# other contexts. A non-null argument reverses the axis direction.
var axisHandler = func(pre, post) {
print("entr axisHandler");
func(invert = 0) {
print("entr innerFunc");
var val = cmdarg().getNode("setting").getValue();
if(invert) val = -val;
foreach(var e; engines)
if(e.selected.getValue())
setprop(pre ~ e.index ~ post, (1 - val) / 2);
}
}
results in console printouts only for the propellorAxis movement, not for the throttle axis.
The commentary for the above function sould read 'uses cmdarg', descriptive, not 'use cmdarg', imperative.
ref joystick.nas @ 285. RJH' comments suggest that
controls.nas @ 72 setfor allenginesProperty() may be involved; this functio does not seem to honour 'invert'
The entire code path seems a little esoteric bearing in mind the skill level of a user simply attempting to get an input device working !
Additionally the default model, c172p, has its own flavour of throttleAxis:
at fgdata/Aircraft/c172p/Nasal/engine.nas @ 475
The commentary is unclear as to who should be obeying the 'should not be overridden like this'
In any case, if the forum user is attempting to configure a device using the default model it looks as if completely different behaviour to that noted in controls.nas will be experienced.
The problem is that the c172 overrides throttleAxis without implementing all of the parameters that are defined in controls.nas.
I have previously recommended that aircraft models should never do this; and instead use a listener on the engine property to perform any special functions.
This is why there is no output for throttle by adding print into controls.nas
@lightwork, Nice analysis work. I agree with your conclusions. This will need to be addressed by the aircraft maintainers.
Someone have submitted this analyse to the aircraft maintainers ? I have the same problem see the ticket 1849
I have now: https://github.com/c172p-team/c172p/issues/1524, so closing it here (as invalid, because c172p bugs are not tracked here).
I have a possible fix for this, but I need someone to test it.
See https://github.com/c172p-team/c172p/issues/1524#issuecomment-2465630634