I'm looking forward to configure a joystick axis in order to set the property change ratio as opposed to setting its absolute value directly. The idea behind this is to be able to achieve smooth precise adjustments on a given property.
Let me use an example to clarify:
Imagine that you want to map the "pitch" axis of your joystick to the "vertical view" property. If you mapped the property directly using the 'property-scale' command, releasing the stick would make the "vertical view" go back to "default position", as the joystick would return to the axis center position. Instead, imagine you want this "pitch" axis to control the "vertical view" movement ratio: Pushing the stick a 50% would make the view go up, for instance, 1 unit per second, while pushing it 100% would make the view go up at 2 units per second ratio. In that fashion, releasing the stick would make the view to stay still (at the current value) and pulling it a 25% would make the view go down 0.5 units per second, just to say something.
I've tried to achieve a similar behaviour using the following nasal binding (following the pitch - vertical view example):
- Code: Select all
<axis n="1">
<desc>Vertical view</desc>
<binding>
<command>nasal</command>
<script>
var input_value = cmdarg().getNode("setting").getValue();
var step = 2.0;
var value = getprop("/sim/current-view/goal-pitch-offset-deg") + input_value*step;
setprop("/sim/current-view/goal-pitch-offset-deg", value);
</script>
</binding>
</axis>
The previous code has in mind the idea of "change ratio" but it has an important issue: The nasal code is only called once for each different value the axis takes. That is, if you push the stick to 50% and hold it there steadily, the 'setprop' function will only be called once, and this makes it unusable for this purpose.
For me, this is somehow related to repeatable buttons, I would like to be able to specify that an axis is "repeatable", meaning that the binding should be called more than one time for a given value.
Is there any way to achieve this kind of behaviour?
I haven't been able to find any post/XML configuration trying to achieve the same, but maybe I'm just using the wrong keywords.
In any case, I would really appreciate any help!
PS. This might seem a weird question, but just think of how movement/camera are controlled when using a video game console controller analog joysticks.