sim wrote in Sat Jul 06, 2013 10:15 pm:It'll have to get a whole lot better before I throw away the codes built into my joystick xml
especially those recent additions from yourself and philosopher. "Slewprop" for example
was a quantum leap!
Shame if it means there is less incentive to program each button and axis to meet one's own
joystick preferences. Mind bogling how many things one button will do using easy to learn
xml script. Streets ahead of X-Plane, FSX etc formatting, where one button can only be allocated
one function!
Stuart's is a welcome simple system akin to X-Plane, FSX etc. Advanced sim flyers will already
have their own joystick set up covering far more controls and functions.
I put all my code in a nas file, the xml file just calls a function named after the switch number, passing the Mode switch position and the modifier state.
<button n="2">
<!-- Labled as A1 -->
<desc>Elevator trim down - View pitch down/Alt Inc - VS Inc/</desc>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>saitekyoke.buttonA1(saitekAlter, 1)</script>
</binding>
<mod-shift>
<binding>
<command>nasal</command>
<script>saitekyoke.buttonA1(saitekAlter, 2)</script>
</binding>
</mod-shift>
<mod-ctrl>
<binding>
<command>nasal</command>
<script>saitekyoke.buttonA1(saitekAlter, 3)</script>
</binding>
</mod-ctrl>
</button>
<button n="3">
<!-- Labled as A2 -->
<desc>Elevator trim up - View pitch up/Alt Dec - VS Dec/</desc>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>saitekyoke.buttonA2(saitekAlter, 1)</script>
</binding>
<mod-shift>
<binding>
<command>nasal</command>
<script>saitekyoke.buttonA2(saitekAlter, 2)</script>
</binding>
</mod-shift>
<mod-ctrl>
<binding>
<command>nasal</command>
<script>saitekyoke.buttonA2(saitekAlter, 3)</script>
</binding>
</mod-ctrl>
</button>
var buttonA1 = func(alter, mode) {
if (mode == 1) {
if (alter) {
controls.elevatorTrim(1)
} else {
controls.slewProp("/sim/current-view/goal-pitch-offset-deg", 15)
}
}
if (mode == 2) {
if (alter) {
setprop("/instrumentation/flightdirector/Asel", getprop("/instrumentation/flightdirector/Asel") + 100)
} else {
}
}
if (mode == 3) {
if (alter) {
var vs = getprop("/autopilot/settings/target-vs-fpm");
setprop("/autopilot/settings/target-vs-fpm", vs + 1);
gui.popupTip(sprintf("VS = %d", vs + 1), 2)
} else {
var ias = getprop("/autopilot/settings/target-speed-kt");
setprop("/autopilot/settings/target-speed-kt", ias + 1);
gui.popupTip(sprintf("IAS = %d", ias + 1), 2)
}
}
}
var buttonA2 = func(alter, mode) {
if (mode == 1) {
if (alter) {
controls.elevatorTrim(-1)
} else {
controls.slewProp("/sim/current-view/goal-pitch-offset-deg", -15)
}
}
if (mode == 2) {
if (alter) {
setprop("/instrumentation/flightdirector/Asel", getprop("/instrumentation/flightdirector/Asel") - 100)
} else {
}
}
if (mode == 3) {
if (alter) {
var vs = getprop("/autopilot/settings/target-vs-fpm");
setprop("/autopilot/settings/target-vs-fpm", vs - 1);
gui.popupTip(sprintf("VS = %d", vs + 1), 2)
} else {
var ias = getprop("/autopilot/settings/target-speed-kt");
setprop("/autopilot/settings/target-speed-kt", ias - 1);
gui.popupTip(sprintf("IAS = %d", ias - 1), 2)
}
}
}
one of the big advantages is readability, especially when editing/changing.
a new Nasal API for registering invididual Nasal functions as fgcommands
<axis n="0">
<binding>
<command>Cyborg-X-axis</command>
<settings>
<!-- dead-band, power, etc. -->
<control>aileron</control>
</settings>
</binding>
</axis>
Users browsing this forum: No registered users and 5 guests