From FlightGear wiki
Jump to: navigation, search

Bindings define what happens when a user:

In other words, bindings are simply the term for actions that are associated with certain events in FlightGear.

There are different types of events supported by various subsystems, but the resulting action that can be triggered will typically involve either a hard-coded command (a so called fgcommand), or a block of scripted code (using Nasal). Bindings can be parameterized/customized using properties as arguments that are passed to each binding as a props.Node object. And Nasal code can also be registered to become available as a dedicated fgcommand.

You can assign multiple bindings to one object, button or key. Bindings may contain conditions to make them conditionally executed. Each binding must specify a command node with its particular type, see below.

Note  Planes are free to override key bindings to fullfill their needs. The Space Shuttle for instance has no mixture control, so the m-key switches from translational to rotational hand controller.

The key only performs as mixture control if the plane has mixture settings and if the plane didn't re-assign the key - so dependent on what plane you try, it may or may not. Usually the aircraft-specific help spells it out.[1]

This article gives a small overview of frequently used bindings. Please refer to $FG_ROOT/Docs/README.commands for additional information and refer to $FG_SRC/Main/commands.cxx for a complete list of available bindings.

All given codes are examples, found on various places in the FlightGear package.


Below are a number of useful commands, some also with their equivalent Nasal call. For the complete list, see flightgear/src/Main/fg_commands.cxx (line 1382).

To learn more about adding your own custom fgcommands to the source code, see Howto:Add new fgcommands to FlightGear.


Toggles replay.



Closes the active dialog.



Shows a dialog, which should be present in $FG_ROOT/gui/dialogs. In addition, from FlightGear 2.8, dialog files located in <aircraft directory>/gui/dialogs are also loaded. This should be used for dialogs specific to a certain aircraft.

fgcommand("dialog-show",{"dialog-name": "location-in-air"}));
The name of the dialog, as designated in its XML file.


Nasal is frequently used for complicated systems, because it can execute virtually any function and allows running previously-defined Nasal functions.

The Nasal script to execute.
Note Make sure that the script does not conflict with the predefined XML entities This is a link to a Wikipedia article. If it does, you can either put it in a CDATA section This is a link to a Wikipedia article or use a non-interpreted version (e.g., &gt; in place of >).

The cmdarg() function is often useful in these situations to extract offset values passed to the binding. It returns the specific <binding> node, which contains a <setting> node at runtime if used in a joystick axis that represents the value of that axis.

In joysticks and keyboard keys, the script is run in a specific namespace; please see Howto:Understand Namespaces and Methods for more information on namespaces.


Increases or decreases a property's value with a given step. Maximum and minimum values are optional.

Property that will be changed.
Amount to increase or decrease the property's value. Defaults to 0.
Offset from the property's current value. If step is not given, this is multiplied by factor.
When step is not given, offset is multiplied by this. Defaults to 1.
The minimum allowed value. Defaults to "no minimum."
The maximum allowed value. Defaults to "no maximum."
If true, the value will be wrapped when it passes min or max; both min and max must be present for this to work. Defaults to false.
This argument accepts three value: "integer," "decimal" and "all" (default). "integer" means that step or offset * factor is applied to the part of the property's current value left of the decimal point first. "decimal" does the same, but applies it to the prt to the right of the decimal point. "all" simply applies it to the whole number. This parameter does not seem to affect the resulting new value of the property, and so is not needed.


One of the most important commands. It sets a property to a predefined value.



Cycles between a list of values and assigns one to a property. The value-list can vary in length. If the current value is "value1", it will change to "value2"; if it is "value2", it will change to "value3", and so on, wrapping around the end. If the current value is not in the list, it will jump to the first one.

  <value type="string">ARM</value>
  <value type="string">DISARM</value>
  <value type="string">OFF</value>

As of May 2013, the command supports additional behaviours to simplify use with the new knob and slider animations. The wrapping behaviour can be disabled by setting <wrap>0</wrap>, and the command uses the 'offset' argument to select a direction of movement. This means a property-cycle bound to a multi-position knob will function as expected for movement in both directions.


Interpolates to a value with a given rate of change (per second).

  <value type="double">0</value>
  <rate>0.5</rate><!-- 2 seconds to 0 from 1 or -1 -->

Instead of using <rate>, one could use

  <value type="double">0</value>
  <time>2</time><!-- 2 seconds to 0 from 1, 0.5, -1 etc. -->

You can also interpolate to a value given by a property.

  <property>/controls/flight/default-aileron-trim</property><!-- the value to interpolate to, is 0 -->
  <rate>0.5</rate><!-- 2 seconds to 0 from 1 or -1 -->


Multiply the value of a property by a given factor.

  • factor: the amount to multiply by.
  • min: minimum value.
  • max: maximum value.
  • mask:
    • integer: mutiply only left of the decimal point.
    • decimal: multiply only the right of the decimal point.
    • all: multiply the entire value.
  • wrap: true if the value should be wrapped if it passes min/max. It is required to set both min and max in that case.


Assigns a random value (between min and max) to a property.



Set the value of a property based on an axis, often used in joystick configuration files.

  • offset: the offset to shift by, before applying the factor.
  • factor: the factor to multiply by (use negative to reverse).
  • squared: if true will square the resulting value (same as power=2).
  • power: the resulting value will be taken to the power of this integer value (overrides squared).

Remember: ((property+offset)*factor)^power=result


Swaps the values of two properties, useful for radio panels.



Toggles the value of a property on each click, between true (1) and false (0).


Or - if defined - it toggles between two custom values.



fgcommand("request-metar",{"path": "/foo/mymetar", "station": "LOWI"}));

If you pass an existing path, the station ID will be updated, and if you pass the same station ID as before, no additional request is made. As usual for metar-properties, there's a time-to-live and valid flags you can check, and the metar refreshes automatically every 900 seconds. You can also write to the station ID directly to change station, update the time-to-live, and wait for the valid signal.

There's also an unregister command ('clear-metar') to cancel the binding into the property tree.[2]
— James Turner
  1. Thorsten  (Nov 9th, 2016).  Re: trouble with m-key .
  2. James Turner (Sun, 23 Sep 2012 08:56:48 -0700). [Flightgear-devel] Requesting arbitrary metar.

Related content