]> git.mxchange.org Git - flightgear.git/blob - docs-mini/README.commands
Major overhaul by Frederic Bouvier to make options table-driven.
[flightgear.git] / docs-mini / README.commands
1 Binding New Commands in FlightGear
2 ----------------------------------
3
4
5 To add a new command to FlightGear, you first need to create a
6 function that takes a single SGPropertyNode const pointer as an
7 argument:
8
9   void
10   do_something (SGPropertyNode * arg)
11   {
12     something();
13   }
14
15 Next, you need to register it with the command manager:
16
17   globals->get_commands()->addCommand("something", do_something);
18
19 Now, the command "something" is available to any mouse, joystick,
20 panel, or keyboard bindings.  If the bindings pass any arguments, they
21 will be children of the SGPropertyNode passed in:
22
23   void
24   do_something (const SGPropertyNode * arg)
25   {
26     something(arg->getStringValue("foo"), arg->getDoubleValue("bar"));
27   }
28
29 That's pretty-much it.  Apologies in advance for not making things any
30 more complicated.
31
32