Board index FlightGear Development New features

Control configuration GUI

Discussion and requests for new features. Please note that FlightGear developers are volunteers and may or may not be able to consider these requests.

Control configuration GUI

Postby Dragonmaster Lou » Mon Aug 29, 2011 5:51 pm

Probably not the highest priority feature on the list, but I think some sort of GUI, either built-in or external to FlightGear proper, to configure controls (joystick, yoke, pedals, etc.) would be very handy. It doesn't necessarily have to offer all the flexibility that hand-editing the XML files do, but something to at least let you specify which buttons do what on your controller would be nice.
Dragonmaster Lou
 
Posts: 29
Joined: Fri Jul 15, 2011 3:58 pm

Re: Control configuration GUI

Postby Hooray » Mon Aug 29, 2011 6:21 pm

Most of these bindings are stored in XML files, so called "PropertyList" XML files, the structure of which is documented here: http://gitorious.org/fg/fgdata/blobs/ma ... .xmlsyntax

Keyboard bindings are configured in keyboard.xml: http://gitorious.org/fg/fgdata/blobs/ma ... yboard.xml
Joysticks are configured using joysticks.xml: http://gitorious.org/fg/fgdata/blobs/ma ... sticks.xml
Mouse bindings are configured in mice.xml: http://gitorious.org/fg/fgdata/blobs/master/mice.xml

A list of input drivers (including joysticks) available in XML form can be found in $FG_ROOT/Input: http://gitorious.org/fg/fgdata/trees/master/Input

GUI configuration files for creating custom dialogs are also created using PropertyList-encoded XML files.
A number of examples can be found in $FG_ROOT/gui/dialogs: http://gitorious.org/fg/fgdata/trees/master/gui/dialogs

The supported syntax of XML dialog files is documented in $FG_ROOT/Docs/README.gui: http://gitorious.org/fg/fgdata/blobs/ma ... README.gui

The layout mechanism for arranging/aligning GUI widgets is documented in $FG_ROOT/Docs/README.layout: http://gitorious.org/fg/fgdata/blobs/ma ... DME.layout

XML dialog files may contain their own embedded Nasal scripts, Nasal is the FlightGear scripting language which is documented here: http://wiki.flightgear.org/Nasal

Numerous examples for writing Nasal code can be found in $FG_ROOT/Nasal: http://gitorious.org/fg/fgdata/trees/master/Nasal

Routines for reading, processing and writing XML files are available in $FG_ROOT/Nasal/io.nas: http://gitorious.org/fg/fgdata/blobs/ma ... sal/io.nas

In other words: You should be able to create your own "control configuration GUI" directly within FlightGear.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Control configuration GUI

Postby Dragonmaster Lou » Tue Aug 30, 2011 3:25 pm

Okay, in other words, just to summarize things, someone who figures out the Nasal and XML syntax well enough can write their own GUIs for configuring controls using FlightGear-native facilities and don't have to write C/C++ code to do so?

Hmm, might be a nice pet project for me to work on if I can find the time and perhaps I can submit it to FG's codebase if that's the case. While I do know C and C++ and am a programmer at my day job, hacking Nasal sounds much easier than diving head first into FG's core source code and adding this functionality.
Dragonmaster Lou
 
Posts: 29
Joined: Fri Jul 15, 2011 3:58 pm

Re: Control configuration GUI

Postby Hooray » Tue Aug 30, 2011 4:06 pm

Dragonmaster Lou wrote in Tue Aug 30, 2011 3:25 pm:Okay, in other words, just to summarize things, someone who figures out the Nasal


Nasal's syntax is VERY close to JavaScript, obviously the library functions are different and more specific to FlightGear.
http://www.plausible.org/nasal/sample.nas
http://www.plausible.org/nasal/lib.html

Dragonmaster Lou wrote in Tue Aug 30, 2011 3:25 pm:and XML syntax well enough can write their own GUIs for configuring controls using FlightGear-native facilities and don't have to write C/C++ code to do so?


Yes, that's exactly the case: The absolute majority of GUI dialogs in FlightGear are all made up of XML files following a FlightGear-specific format that is called "PropertyList", this is because all XML files using this structure can directly be processed by the FlightGear property tree.

Usually, Nasal files contain bindings (e.g. actions for buttons) to trigger some code - such as fgcommands (see $FG_ROOT/README.commands): http://gitorious.org/fg/fgdata/blobs/ma ... E.commands

Figuring out Nasal and/or XML should not that much of an issue, because you can view plenty of files from the base package that contain numerous examples. Especially, if you are programmer by profession.

Hmm, might be a nice pet project for me to work on if I can find the time and perhaps I can submit it to FG's codebase if that's the case. While I do know C and C++ and am a programmer at my day job, hacking Nasal sounds much easier than diving head first into FG's core source code and adding this functionality.


In fact, using the XML-configurable GUI system is now generally considered the preferred route, simply because the majority of GUI dialogs are kept in $FG_ROOT/GUI/dialogs

You can invoke Nasal scripts from these dialog files, and you can trigger fgcommands.
Nasal has a relatively rich library of functions that are supported by default, in addition you can FlightGear specific extension functions and FlightGear-specific helper modules from $FG_ROOT/Nasal - such as code from gui.nas or io.nas

To get started easily you could look around for a GUI dialog that is using the widgets that you need, you can then locate the file in $FG_ROOT/gui/dialogs and open it in a plain text editor. You could also use a validating XML editor instead if you want to make sure that your XML is valid.

You could save a copy of the file under a different file name, such as "config-gui.xml" and add a new entry to $FG_ROOT/gui/menubar.xml to add a new menubar entry for showing your dialog.

You could then -step by step- modify your dialog so that it can be used for configuring the controls and saving everything to a new XML file.

If you already know C++, it should be easy for you to understand the Nasal part - and XML is just a markup language.

Not all features of the underlying GUI library are currently exposed, but it is relatively easy to add support for new widgets.

The C++ source that turns the PropertyList GUI dialog files into PUI/PLIB dialogs is located in $FG_SRC/GUI/dialog.cxx: http://gitorious.org/fg/flightgear/blob ... dialog.cxx

The PLIB PUI library is documented here: http://plib.sourceforge.net/pui/index.html

So if you should find the need to add new widgets or features to the GUI bindings, it would not be too difficult to do - as you'll surely see.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Control configuration GUI

Postby Kabuki » Tue Aug 30, 2011 5:24 pm

:evil: XML SUCKS :evil:

XML's only redeeming feature is the ability to include Nasal scripts inline.
This is a family-friendly saloon. No talk stink.
Kabuki
 
Posts: 584
Joined: Sat Oct 24, 2009 12:21 am
Location: Usually on the ground, always in the sky, except when underwater.
Callsign: Kabuki
Version: 3.0.0
OS: Windows 7

Re: Control configuration GUI

Postby Hooray » Tue Aug 30, 2011 7:28 pm

If you don't like using XML for creating the dialog, you can also directly use a Nasal script to specify the dialog - after all the structure needs to end up in the property tree anyhow, there are various helpers available in $FG_ROOT/Nasal/gui.nas

So it would be possible to specify the dialog as a nested Nasal hash and turn it into a property tree structure.

The function showWeightDialog() in $FG_ROOT/Nasal/gui.nas is one example that illustrates how to go about creating a somewhat more complex dialog dynamically from a Nasal script.

There are other examples such as gui.showHelpDialog() available.

Just keep in mind that the symbols mentioned in $FG_ROOT/Docs/README.gui are still important - but instead of using them in tags, you'd directly use them to populate the property tree from Nasal.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Control configuration GUI

Postby Kabuki » Tue Aug 30, 2011 8:58 pm

Hooray wrote in Tue Aug 30, 2011 7:28 pm:If you don't like using XML for creating the dialog, you can also directly use a Nasal script to specify the dialog


Yes, that's XMLs greatest feature in action -- the ability to inline Nasal scripts. I'm looking at some examples of <expression> elements in some
files, and it's boggling how complicated the syntax a simple "if..then" construct can be in XML. But you're right, pretty much all of that can
be done in Nasal, by using a <script> element.

Thanks for the examples you gave. Code is truth.
This is a family-friendly saloon. No talk stink.
Kabuki
 
Posts: 584
Joined: Sat Oct 24, 2009 12:21 am
Location: Usually on the ground, always in the sky, except when underwater.
Callsign: Kabuki
Version: 3.0.0
OS: Windows 7

Re: Control configuration GUI

Postby Dragonmaster Lou » Tue Aug 30, 2011 9:55 pm

I'm comfortable enough with XML that I can do a lot of the stuff there and just interleave Nasal as necessary, once I get the hang of it. Thanks for the info!
Dragonmaster Lou
 
Posts: 29
Joined: Fri Jul 15, 2011 3:58 pm

Re: Control configuration GUI

Postby Kabuki » Sat Sep 03, 2011 7:48 pm

Dragonmaster Lou wrote in Tue Aug 30, 2011 9:55 pm:I'm comfortable enough with XML that I can do a lot of the stuff there and just interleave Nasal as necessary, once I get the hang of it. Thanks for the info!


Great! How can I change the <legend> of a button in a gui dialog? I'd like it to be conditional on some value. E.g. pseudo-code...

if x then legend = "Hello"
else legend = "Goodbye"
This is a family-friendly saloon. No talk stink.
Kabuki
 
Posts: 584
Joined: Sat Oct 24, 2009 12:21 am
Location: Usually on the ground, always in the sky, except when underwater.
Callsign: Kabuki
Version: 3.0.0
OS: Windows 7


Return to New features

Who is online

Users browsing this forum: No registered users and 6 guests