Skip to content

Commit

Permalink
Merge pull request #90 from hbeni/FGFS-Addon
Browse files Browse the repository at this point in the history
FlightGear Addon
  • Loading branch information
hbeni authored Mar 15, 2021
2 parents b727aa2 + 8752cc9 commit 801bae0
Show file tree
Hide file tree
Showing 8 changed files with 345 additions and 7 deletions.
9 changes: 6 additions & 3 deletions README-de_DE.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ Weitere Details stehen im Readme des RadioGUI.


### Flightgear spezifisch
- Kopiere die Flightgear Protokolldefinitionsdatei in deinen Flightgear Installationsordner unter `Protocol`.
- Starte Flightgear mit aktiviertem fgcom-mumble Protokoll (füge "`--generic=socket,out,10,127.0.0.1,16661,udp,fgcom-mumble`" im Startprogramm als zusätzlichen Parameter hinzu)
- Nachdem Flightgear gestartet wurde, kannst du die Funkgeräte wie gewohnt benutzen (Standard ist *Leertaste* für Sprechen auf COM1 und *Umschalt-Leetaste* für COM2).
- Füge den ordner `fgfs` aus dem entpackten client-release als Addon im Launcher hinzu.
- Aktiviere das [FGFS-addon](client/fgfs/Readme.md) in deinem Launcher.
- FlightGear sendet dann automatisch die notwendigen Daten an mumble (mit Standardparametern; diese können über das *Mehrspieler*-Menü geändert werden).

Die FGFS-Protokolldefinition unterstützt alte 25kHz- genauso wie neuere 8.3kHz Funkgeräte.
Nachdem Flightgear gestartet wurde, kannst du die Funkgeräte wie gewohnt benutzen (Standard ist *Leertaste* für Sprechen auf COM1 und *Umschalt-Leetaste* für COM2).


### ATC-Pie specific
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,11 @@ For details on how this can be done, look at RadioGUI's readme.


### Flightgear specific
- copy the `fgcom-mumble.xml` fightgear protocol file to your flightgears `Protocol` folder.
- start flightgear with enabled fgcom-mumble protocol (add "`--generic=socket,out,10,127.0.0.1,16661,udp,fgcom-mumble`" to your launcher)
- start using your radio stack (standard FGCom PTT is space for COM1 and shift-space for COM2)
Just add and activate the [FGFS-addon](client/fgfs/Readme.md) in your launcher.

The FGFS protocol file will handle old 25kHz as well as newer 8.3kHz radios.

After starting flightgear, you can use your radio stack like with FGCom (default is *space* to talk on COM1 and *shift+space* for COM2).
The addon can be configured via a new entry in the *Multiplayer* menu.

### ATC-Pie specific
Since ATC-Pie v1.7.1 FGCom-mumble is supported out of the box.
Expand Down
30 changes: 30 additions & 0 deletions client/fgfs/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FGCom-mumble FGFS Addon
=================================
This Addon is a convinient addon package to let FlightGear know about the FGCom-mumble protocol. It adds menu item and a dialog where you can conviniently adjust the parameters without the need to restart flightgear.

Instead of using this addon, you can also invoke the protocol manually:

- copy the `fgcom-mumble.xml` fightgear protocol file to your flightgears `Protocol` folder.
- start flightgear with enabled fgcom-mumble protocol (add "`--generic=socket,out,10,127.0.0.1,16661,udp,fgcom-mumble`" to your launcher)



Installation
------------
After unzipping the FGCom-mumble release package, you just need to add the `fgfs` folder to your launchers *Add-ons* module list.
The addon is activated automatically, so flightgear will try to connect to mumble with the default parameters.


Running the Addon
-----------------
When added to your launcher, the addon is automatically active.
No further steps are needed.

The FGFS protocol file will handle old 25kHz as well as newer 8.3kHz radios.
After starting flightgear, you can use your radio stack like with FGCom (default is *space* to talk on COM1 and *shift+space* for COM2).


Configuration
----------------------------
If you wish to adjust the parameters, you can access them via the new *Multiplayer* menu entry. This is usually not needed except you are running several mumble instances or mumble not on the same computer as FlightGear.
Changes to the parameters will reinitialize the addon automatically, making them effective.
4 changes: 4 additions & 0 deletions client/fgfs/addon-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<PropertyList>
<!-- init by addon-main.nas -->
</PropertyList>
111 changes: 111 additions & 0 deletions client/fgfs/addon-main.nas
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#
# Protocol FGCom-mumble addon main nasal hook
#
# based on the KML addon by Slawek Mikula
#
# @author Benedikt Hallinger, 2021

var main = func( addon ) {
var root = addon.basePath;
var myAddonId = addon.id;
var mySettingsRootPath = "/addons/by-id/" ~ myAddonId;
var protocolInitialized = 0;

# init props with defaults
var enabledNode = props.globals.getNode(mySettingsRootPath ~ "/enabled", 1);
enabledNode.setAttribute("userarchive", "y");
if (enabledNode.getValue() == nil) {
enabledNode.setBoolValue("1");
}
var refreshNode = props.globals.getNode(mySettingsRootPath ~ "/refresh-rate", 1);
refreshNode.setAttribute("userarchive", "y");
if (refreshNode.getValue() == nil) {
refreshNode.setIntValue("10");
}
var hostNode = props.globals.getNode(mySettingsRootPath ~ "/host", 1);
hostNode.setAttribute("userarchive", "y");
if (hostNode.getValue() == nil) {
hostNode.setValue("localhost");
}
var portNode = props.globals.getNode(mySettingsRootPath ~ "/port", 1);
portNode.setAttribute("userarchive", "y");
if (portNode.getValue() == nil) {
portNode.setIntValue("16661");
}

# Init GUI menu entry
var menuTgt = "/sim/menubar/default/menu[7]"; # 7=multiplayer
var menudata = {
label : "FGCom-mumble",
name : "fgcom-mumble",
binding : { command : "dialog-show", "dialog-name" : "fgcom-mumble-settings" }
};
props.globals.getNode(menuTgt).addChild("item").setValues(menudata);
fgcommand("gui-redraw");

var initProtocol = func() {
if (protocolInitialized == 0) {
print("Addon FGCom-mumble initializing");
var enabled = getprop(mySettingsRootPath ~ "/enabled");
var refresh = getprop(mySettingsRootPath ~ "/refresh-rate");
var host = getprop(mySettingsRootPath ~ "/host");
var port = getprop(mySettingsRootPath ~ "/port");

if (enabled == 1) {
var protocolstring = "generic,socket,out," ~ refresh ~ "," ~ host ~ "," ~ port ~",udp,fgcom-mumble";
print("Addon FGCom-mumble activating protocol '"~protocolstring~"'");
fgcommand("add-io-channel", props.Node.new({
"config": protocolstring,
"name":"fgcom-mumble"
}));
protocolInitialized = 1;
}
}
}

var shutdownProtocol = func() {
if (protocolInitialized == 1) {
print("Addon FGCom-mumble shutdown protocol...");
fgcommand("remove-io-channel",
props.Node.new({
"name" : "fgcom-mumble"
})
);
protocolInitialized = 0;
}
}

var reinitProtocol = func() {
print("Addon FGCom-mumble re-initializing");
shutdownProtocol();
initProtocol();
}

var init = _setlistener(mySettingsRootPath ~ "/enabled", func() {
if (getprop(mySettingsRootPath ~ "/enabled") == 1) {
initProtocol();
} else {
shutdownProtocol();
}
});

var init_fdm = setlistener("/sim/signals/fdm-initialized", func() {
removelistener(init_fdm); # only call once
if (getprop(mySettingsRootPath ~ "/enabled") == 1) {
initProtocol();
}
});

var reinit_listener = _setlistener("/sim/signals/reinit", func {
removelistener(reinit_listener); # only call once
if (getprop(mySettingsRootPath ~ "/enabled") == 1) {
initProtocol();
}
});



var reinit_hzChange = setlistener(mySettingsRootPath ~ "/refresh-rate", reinitProtocol, 0, 0);
var reinit_hostChange = setlistener(mySettingsRootPath ~ "/host", reinitProtocol, 0, 0);
var reinit_portChange = setlistener(mySettingsRootPath ~ "/port", reinitProtocol, 0, 0);
}
10 changes: 10 additions & 0 deletions client/fgfs/addon-menubar-items.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<PropertyList>
<meta>
<file-type type="string">FlightGear add-on menu bar items</file-type>
<format-version type="int">1</format-version>
</meta>

<!-- GUI menu adjusted in addon-main.nas -->

</PropertyList>
61 changes: 61 additions & 0 deletions client/fgfs/addon-metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>

<PropertyList>
<meta>
<file-type type="string">FlightGear add-on metadata</file-type>
<format-version type="int">1</format-version>
</meta>

<addon>
<identifier type="string">org.hallinger.flightgear.FGCom-mumble</identifier>
<name type="string">FGCom-mumble</name>
<version type="string">0.11.0</version>

<authors>
<author>
<name type="string">Benedikt Hallinger</name>
<email type="string">[email protected]</email>
<url type="string">https://wiki.flightgear.org/FGCom-mumble</url>
</author>
</authors>

<maintainers>
<maintainer>
<name type="string">Benedikt Hallinger</name>
<email type="string">[email protected]</email>
<url type="string"></url>
</maintainer>
</maintainers>

<short-description type="string">addon to send data to mumbles FGCom-mumble plugin</short-description>
<long-description type="string">Let FlightGear send it's data to the FGCom-mumble plugin data port</long-description>

<localized>
<de>
<short-description type="string">sendet Daten an das FGCom-mumble plugin in Mumble</short-description>
<long-description type="string">Lässt FlightGear die notwendigen Daten an das FGCom-mumble plugin senden</long-description>
</de>
</localized>

<license>
<designation type="string">GNU GPL version 3 or later</designation>
<!--<file type="string">LICENSE</file>-->
<url type="string">https://www.gnu.org/licenses/gpl-3.0</url>
</license>

<min-FG-version type="string">2018.3.0</min-FG-version>
<max-FG-version type="string">none</max-FG-version>

<urls>
<download type="string">https://github.com/hbeni/fgcom-mumble/releases</download>
<support type="string">https://github.com/hbeni/fgcom-mumble/issues</support>
<code-repository type="string">https://github.com/hbeni/fgcom-mumble/</code-repository>
</urls>

<tags>
<tag type="string">mumble</tag>
<tag type="string">atc</tag>
</tags>

</addon>
</PropertyList>
120 changes: 120 additions & 0 deletions client/fgfs/gui/dialogs/fgcom-mumble-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0"?>

<PropertyList>
<name>fgcom-mumble-settings</name>
<layout>vbox</layout>
<width>600</width>
<group>
<layout>hbox</layout>

<button>
<legend> </legend>
<pref-width>16</pref-width>
<pref-height>16</pref-height>
<binding>
<command>dialog-close</command>
</binding>
</button>

<empty><stretch>1</stretch></empty>

<text>
<label>FGCom-mumble settings</label>
</text>

<empty><stretch>1</stretch></empty>

<button>
<legend> </legend>
<key>Esc</key>
<pref-width>16</pref-width>
<pref-height>16</pref-height>
<binding>
<command>dialog-close</command>
</binding>
</button>

</group>

<hrule/>

<checkbox>
<halign>left</halign>
<label>Enable sending data</label>
<property>/addons/by-id/org.hallinger.flightgear.FGCom-mumble/enabled</property>
</checkbox>

<group>
<layout>hbox</layout>

<text>
<halign>left</halign>
<label>Refresh rate (Hz):</label>
</text>

<input>
<name>refresh-rate</name>
<height>25</height>
<halign>left</halign>
<property>/addons/by-id/org.hallinger.flightgear.FGCom-mumble/refresh-rate</property>
</input>
</group>

<group>
<layout>hbox</layout>

<text>
<label>Host</label>
<halign>left</halign>
</text>

<input>
<height>25</height>
<halign>left</halign>
<property>/addons/by-id/org.hallinger.flightgear.FGCom-mumble/host</property>
</input>
</group>

<group>
<layout>hbox</layout>

<text>
<label>Port</label>
<halign>left</halign>
</text>

<input>
<height>25</height>
<halign>left</halign>
<property>/addons/by-id/org.hallinger.flightgear.FGCom-mumble/port</property>
</input>
</group>

<hrule/>

<group>
<layout>hbox</layout>
<empty><stretch>1</stretch></empty>
<button>
<legend>OK</legend>
<pref-width>90</pref-width>
<pref-height>30</pref-height>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>dialog-close</command>
</binding>
</button>

<button>
<legend>Cancel</legend>
<pref-width>90</pref-width>
<pref-height>30</pref-height>
<binding>
<command>dialog-close</command>
</binding>
</button>
<empty><stretch>1</stretch></empty>
</group>
</PropertyList>

0 comments on commit 801bae0

Please sign in to comment.