Add support for <nasal> blocks in the joystick nasal config library.
This commit is contained in:
parent
f14ba2466f
commit
fd4e61869b
1 changed files with 25 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
# Joystick configuration library.
|
||||
var DIALOGROOT = "/sim/gui/dialogs/joystick-config";
|
||||
var MAX_AXES = 8;
|
||||
var MAX_NASALS = 8;
|
||||
var MAX_BUTTONS = 24;
|
||||
|
||||
# Hash of the custom axis/buttons
|
||||
|
@ -630,6 +631,23 @@ var readConfig = func(dialog_root="/sim/gui/dialogs/joystick-config") {
|
|||
btn.removeChild("original_binding");
|
||||
}
|
||||
}
|
||||
|
||||
# Set up Nasal code.
|
||||
var nasals = js.getChildren("nasal");
|
||||
|
||||
for (var nasal = 0; nasal < MAX_NASALS; nasal = nasal + 1) {
|
||||
var nas = props.globals.getNode(dialog_root ~ "/nasal[" ~ nasal ~ "]", 1);
|
||||
nas.remove();
|
||||
nas = props.globals.getNode(dialog_root ~ "/nasal[" ~ nasal ~ "]", 1);
|
||||
|
||||
# Note that we can't simply use an index into the buttons array
|
||||
# as that doesn't work for a sparsley populated set of buttons.
|
||||
# E.g. one with n="3"
|
||||
var a = js.getNode("nasal[" ~ nasal ~ "]");
|
||||
if (a != nil) {
|
||||
props.copy(a, nas.getNode("original_script", 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var writeConfig = func(dialog_root="/sim/gui/dialogs/joystick-config", reset=0) {
|
||||
|
@ -647,6 +665,12 @@ var writeConfig = func(dialog_root="/sim/gui/dialogs/joystick-config", reset=0)
|
|||
config.getNode("name", 1).setValue(id);
|
||||
}
|
||||
|
||||
var nasals = props.globals.getNode(dialog_root).getChildren("nasal");
|
||||
forindex (var nas; nasals) {
|
||||
var nasalscript = config.getNode("nasal[" ~ nas ~ "]", 1);
|
||||
props.copy(props.globals.getNode(dialog_root ~ "/nasal[" ~ nas ~ "]/original_script", 1), nasalscript);
|
||||
}
|
||||
|
||||
var axes = props.globals.getNode(dialog_root).getChildren("axis");
|
||||
forindex (var axis; axes) {
|
||||
var name = getprop(dialog_root ~ "/axis[" ~ axis ~ "]/binding");
|
||||
|
|
Loading…
Reference in a new issue