Bindings: Difference between revisions
m (→Commands: link to source) |
|||
Line 60: | Line 60: | ||
<value type="string">OFF</value> | <value type="string">OFF</value> | ||
</binding> | </binding> | ||
As of May 2013, the command supports additional behaviours to simplify use with the new [[Knob_/_slider_animation|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. | |||
=== property-interpolate === | === property-interpolate === |
Revision as of 15:08, 12 May 2013
Bindings define what happens when a user:
- clicks an object in the scenery or an aircraft
- press a key on the keyboard or joystick
- clicks a menu item
- click a buttons or fields in a dialog
You can assign multiple bindings to one object/button/key.
All give codes are examples, found on various places in the FlightGear package.
Commands
Below are a number of useful commands. See further fg_commands.cxx.
dialog-close
Closes the active dialog.
<binding> <command>dialog-close</command> </binding>
dialog-show
Shows a dialog, which should be present in $FG ROOT/gui/dialogs. Starting with FlightGear 2.7 dialog files located in <Current aircraft directory>/gui/dialogs are also loaded. This should be used for dialogs specific to a certain aircraft.
<binding> <command>dialog-show</command> <dialog-name>location-in-air</dialog-name> </binding>
- dialog-name: the name of the dialog, as designated in its .xml file.
nasal
Nasal is frequently used for complicated systems.
<binding> <command>nasal</command> <script>b777.afds.input(0,1);</script> </binding>
property-adjust
Increases or decreases a property's value with a given step. Maximum and minimum values are optional.
<binding> <command>property-adjust</command> <property>/controls/lighting/panel-norm</property> <step>-0.05</step> <min>0</min> <max>1</max> </binding>
property-assign
One of the most important commands. It sets a property to a predefined value.
<binding> <command>property-assign</command> <property>/autopilot/settings/target-speed-kt</property> <value>0</value> </binding>
property-cycle
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.
<binding> <command>property-cycle</command> <property>/autopilot/autobrake/setting</property> <value type="string">ARM</value> <value type="string">DISARM</value> <value type="string">OFF</value> </binding>
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.
property-interpolate
Interpolates to a value with a given rate of change (per second).
<binding>
<command>property-interpolate</command>
<property>/controls/flight/aileron-trim</property>
<value type="double">0</value>
<rate>0.5</rate><!-- 2 seconds to 0 from 1 or -1 -->
</binding>
Instead of using <rate>, one could use
<binding>
<command>property-interpolate</command>
<property>/controls/flight/aileron-trim</property>
<value type="double">0</value>
<time>2</time><!-- 2 seconds to 0 from 1, 0.5, -1 etc. -->
</binding>
You can also interpolate to a value given by a property.
<binding>
<command>property-interpolate</command>
<property>/controls/flight/aileron-trim</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 -->
</binding>
property-multiply
Multiply the value of a property by a given factor.
<binding> <command>property-multiply</command> <property>/controls/flight/aileron</property> <factor>0.5</factor> <min>-1</min> <max>1</max> <mask>all</mask> <wrap>true</wrap> </binding>
- 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.
property-randomize
Assigns a random value (between min and max) to a property.
<binding> <command>property-randomize</command> <property>/orientation/pitch-deg</property> <min>0</min> <max>360</max> </binding>
property-scale
Sett the value of a property based on an axis, often used in joystick configuration files.
<binding> <command>property-scale</command> <property>/controls/flight/aileron</property> <offset>0.001</offset> <factor>-1</factor> <power>3</power> </binding>
- 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
property-swap
Swaps the values of two properties, useful for radio panels.
<binding> <command>property-swap</command> <property>/instrumentation/comm/frequencies/selected-mhz</property> <property>/instrumentation/comm/frequencies/standby-mhz</property> </binding>
property-toggle
Toggles the value of a property on each click, between true (1) and false (0).
<binding> <command>property-toggle</command> <property>/controls/gear/gear-down</property> </binding>
Or - if defined - it toggles between two custom values.
<binding> <command>property-toggle</command> <property>/controls/gear/gear-down</property> <value>2</value> <value>3</value> </binding>
Related content
- $FG_ROOT/Docs/README.commands view online
- Howto: Make a clickable panel