* Anders Gidenstam -- Friday 13 July 2007:
> I think it might also be nice to use a nasal wrapper for the PTT key 
> binding (like most things in controls.nas), that way a user could more 
> easily add more bindings for PTT (e.g. a joystick button).

Yes, of course. I plan a two-stage wrapper. One for the key, and one
(or more) for the PTT function. The binding looks something like this:

 <key n="32">
  <name>SPACE</name>
  <desc>(Reserved for) PTT ... push to talk</desc>
  <binding>
   <command>nasal</command>
   <script>space(1, get_modifiers())</script>
  </binding>
  <mod-up>
   <binding>
    <command>nasal</command>
    <script>space(0, get_modifiers())</script>
   </binding>
  </mod-up>

And the space function calls the PTT wrapper function, depending
on the modifier value. Something like 

  var space = func(state, mod) {
      if (mod == 0)              # space (no modifier)
          controls.ptt(state);
      elsif (mod == 1)           # shift-space
          something.else();
      elsif (mod == 2)           # ctrl-space
          ...
      # cases for five more obscure modifier/space combinations  :-)
  }

Of course, key release would always call the release function of
the last function that got a press event, ignoring the modifier.

Functions like get_modifiers() and space() are defined in a nasal
block in keyboard.xml. All Nasal in keyboard.xml is since yesterday
in separate namespace __kbd, just like Nasal embedded in dialog or
joystick files.

m.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to