* Melchior FRANZ -- Wednesday 22 June 2005 22:51:
> * Giles Robertson -- Wednesday 22 June 2005 21:58:
> > which would allow us to deal with the kb 
> > localisation issues that were mentioned earlier this month.

> Better in *this* respect would be files with a few swap instructions:
> keyboard-fr.xml:  -> swap US/65 bindings with US/81 bindings.

What about this: fgfs first loads $FG_ROOT/keyboard.xml into the property tree,
as it always did. Then, if localization is requested, the same part that loads/
loaded the strings file does also load a stripped down keyboard file, e.g.
$FG_ROOT/Translations/keyboard-fr.xml. No bindings here, only references:


  <?xml version="1.0"?>

  <PropertyList>
      <input>
          <keyboard-map>
              <desc>Tableaux des clefs franc,oiwhatever</desc>

              <key n="97">
                  <name>a</name>
                  <desc>translation of: what used to be q</desc>
                  <property>/input/keyboard/key[113]</property>
              </key>

              <key n="113">
                  <name>q</name>
                  <desc>translation of: increase speed-up (formerly known as 
'a')</desc>
                  <property>/input/keyboard/key[97]/</property>
                  <mod-up>
                      <property>/input/keyboard/key[97]/mod-up</property>
                  </mod-up>
                  <mod-alt>
                      <property>/input/keyboard/key[1234]</property>
                  </mod-alt>
              </key>
          </keyboard-map>
      </input>
  </PropertyList>


And finally, if such a subtree "/input/keyboard-map" exists, _init_keyboard()
goes through this and replaces all occurrences of <property> by the contents
of this referenced node. When it's done, it dumps /input/keyboard (Erik:
delTree()! :-) and moves /input/keyboard-map to /input/keyboard. Viola!



> BTW: with both (and other) solutions one could easily write a script
> that extracts all existing bindings from a running fgfs, and makes a key
> overview table. Could even be done as nasal module that writes TeX code
> (as soon as Nasal can write files, that is).

It doesn't write TeX (or PostScript) yet, but it's a start.
See attachment. Just dump it into $FG_ROOT/Nasal/.

m.
stripPeriod = func {
        substr(arg[0], 0, strc(arg[0], (n = size(arg[0])) - 1) == 46 ? n - 1 : 
n);
}

writeMap = func {
        kbd = props.globals.getNode("/input/keyboard");
        foreach (k; kbd.getChildren("key")) {
                writeKey(k);
        }
}

writeKey = func(key) {
        name = (n = key.getNode("name")) != nil ? n.getValue() : "<noname>";
        out = name ~ " (" ~ key.getIndex() ~ "): ";

        if ((n = key.getNode("desc")) != nil) {
                out ~= stripPeriod(n.getValue());
        }
        addDesc = func(key, name, tag) {
                if ((n = key.getNode(name ~ "/desc")) != nil) {
                        out ~= "; " ~ tag ~ ": " ~ stripPeriod(n.getValue());
                }
        }
        addDesc(key, "mod-up", "UP");
        addDesc(key, "mod-shift", "SHIFT");
        addDesc(key, "mod-ctrl", "CTRL");
        addDesc(key, "mod-alt", "ALT");
        print(out);
}

settimer(writeMap, 0);
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to