summaryrefslogtreecommitdiffhomepage
path: root/proto-flightgear
diff options
context:
space:
mode:
Diffstat (limited to 'proto-flightgear')
-rw-r--r--proto-flightgear/CMakeLists.txt1
-rw-r--r--proto-flightgear/fg-protocol.qrc5
-rw-r--r--proto-flightgear/ftnoir_fgcontrols.ui208
-rw-r--r--proto-flightgear/ftnoir_protocol_fg.cpp33
-rw-r--r--proto-flightgear/ftnoir_protocol_fg.h76
-rw-r--r--proto-flightgear/ftnoir_protocol_fg_dialog.cpp58
-rw-r--r--proto-flightgear/images/flightgear.pngbin0 -> 979 bytes
-rw-r--r--proto-flightgear/lang/nl_NL.ts38
-rw-r--r--proto-flightgear/lang/ru_RU.ts38
-rw-r--r--proto-flightgear/lang/stub.ts38
10 files changed, 495 insertions, 0 deletions
diff --git a/proto-flightgear/CMakeLists.txt b/proto-flightgear/CMakeLists.txt
new file mode 100644
index 00000000..cdfe18a6
--- /dev/null
+++ b/proto-flightgear/CMakeLists.txt
@@ -0,0 +1 @@
+otr_module(proto-fgfs)
diff --git a/proto-flightgear/fg-protocol.qrc b/proto-flightgear/fg-protocol.qrc
new file mode 100644
index 00000000..1c685437
--- /dev/null
+++ b/proto-flightgear/fg-protocol.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/flightgear.png</file>
+ </qresource>
+</RCC>
diff --git a/proto-flightgear/ftnoir_fgcontrols.ui b/proto-flightgear/ftnoir_fgcontrols.ui
new file mode 100644
index 00000000..4c0a8314
--- /dev/null
+++ b/proto-flightgear/ftnoir_fgcontrols.ui
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UICFGControls</class>
+ <widget class="QWidget" name="UICFGControls">
+ <property name="windowModality">
+ <enum>Qt::NonModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>342</width>
+ <height>100</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>FlightGear protocol settings</string>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>2</number>
+ </property>
+ <item>
+ <widget class="QFrame" name="frame">
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>IP address</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinIPFirstNibble">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>60</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinIPSecondNibble">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>60</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinIPThirdNibble">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>60</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinIPFourthNibble">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>60</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QFrame" name="frame_2">
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <property name="topMargin">
+ <number>4</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>10</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Port</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinPortNumber">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>3</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>1000</number>
+ </property>
+ <property name="maximum">
+ <number>10000</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+ <slots>
+ <slot>startEngineClicked()</slot>
+ <slot>stopEngineClicked()</slot>
+ <slot>cameraSettingsClicked()</slot>
+ </slots>
+</ui>
diff --git a/proto-flightgear/ftnoir_protocol_fg.cpp b/proto-flightgear/ftnoir_protocol_fg.cpp
new file mode 100644
index 00000000..3e0f955c
--- /dev/null
+++ b/proto-flightgear/ftnoir_protocol_fg.cpp
@@ -0,0 +1,33 @@
+/* Homepage http://facetracknoir.sourceforge.net/home/default.htm *
+ * *
+ * ISC License (ISC) *
+ * *
+ * Copyright (c) 2015, Wim Vriend *
+ * *
+ * Permission to use, copy, modify, and/or distribute this software for any *
+ * purpose with or without fee is hereby granted, provided that the above *
+ * copyright notice and this permission notice appear in all copies. *
+ */
+#include "ftnoir_protocol_fg.h"
+#include "api/plugin-api.hpp"
+
+// For Todd and Arda Kutlu
+
+void flightgear::pose(const double* headpose) {
+ FlightData.x = -headpose[TX] * 1e-2;
+ FlightData.y = headpose[TY] * 1e-2;
+ FlightData.z = headpose[TZ] * 1e-2;
+ FlightData.p = headpose[Pitch];
+ FlightData.h = -headpose[Yaw];
+ FlightData.r = -headpose[Roll];
+ FlightData.status = 1;
+ QHostAddress destIP(quint32(s.ip1 << 24 | s.ip2 << 16 | s.ip3 << 8 | s.ip4));
+ (void) outSocket.writeDatagram(reinterpret_cast<const char*>(&FlightData), sizeof(FlightData), destIP, static_cast<quint16>(s.port));
+}
+
+bool flightgear::correct()
+{
+ return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
+}
+
+OPENTRACK_DECLARE_PROTOCOL(flightgear, FGControls, flightgearDll)
diff --git a/proto-flightgear/ftnoir_protocol_fg.h b/proto-flightgear/ftnoir_protocol_fg.h
new file mode 100644
index 00000000..48e5f1c1
--- /dev/null
+++ b/proto-flightgear/ftnoir_protocol_fg.h
@@ -0,0 +1,76 @@
+/* Homepage http://facetracknoir.sourceforge.net/home/default.htm *
+ * *
+ * ISC License (ISC) *
+ * *
+ * Copyright (c) 2015, Wim Vriend *
+ * *
+ * Permission to use, copy, modify, and/or distribute this software for any *
+ * purpose with or without fee is hereby granted, provided that the above *
+ * copyright notice and this permission notice appear in all copies. *
+ */
+#pragma once
+#include "ui_ftnoir_fgcontrols.h"
+#include <QThread>
+#include <QUdpSocket>
+#include <QMessageBox>
+#include "api/plugin-api.hpp"
+#include "options/options.hpp"
+using namespace options;
+
+// x,y,z position in meters, heading, pitch and roll in degrees
+#pragma pack(push, 1)
+struct flightgear_datagram {
+ double x, y, z, h, p, r;
+ int status;
+};
+#pragma pack(pop)
+
+struct settings : opts {
+ value<int> ip1, ip2, ip3, ip4;
+ value<int> port;
+ settings() :
+ opts("flightgear-proto"),
+ ip1(b, "ip1", 127),
+ ip2(b, "ip2", 0),
+ ip3(b, "ip3", 0),
+ ip4(b, "ip4", 1),
+ port(b, "port", 5542)
+ {}
+};
+
+class flightgear : public IProtocol
+{
+public:
+ bool correct();
+ void pose(const double *headpose);
+ QString game_name() {
+ return QCoreApplication::translate("flightgear", "FlightGear");
+ }
+private:
+ settings s;
+ flightgear_datagram FlightData;
+ QUdpSocket outSocket;
+};
+
+// Widget that has controls for FTNoIR protocol client-settings.
+class FGControls: public IProtocolDialog
+{
+ Q_OBJECT
+public:
+ FGControls();
+ void register_protocol(IProtocol *) {}
+ void unregister_protocol() {}
+private:
+ Ui::UICFGControls ui;
+ settings s;
+private slots:
+ void doOK();
+ void doCancel();
+};
+
+class flightgearDll : public Metadata
+{
+public:
+ QString name() { return QString(QCoreApplication::translate("flightgearDll", "FlightGear")); }
+ QIcon icon() { return QIcon(":/images/flightgear.png"); }
+};
diff --git a/proto-flightgear/ftnoir_protocol_fg_dialog.cpp b/proto-flightgear/ftnoir_protocol_fg_dialog.cpp
new file mode 100644
index 00000000..43a702f6
--- /dev/null
+++ b/proto-flightgear/ftnoir_protocol_fg_dialog.cpp
@@ -0,0 +1,58 @@
+/* Homepage http://facetracknoir.sourceforge.net/home/default.htm *
+ * *
+ * ISC License (ISC) *
+ * *
+ * Copyright (c) 2015, Wim Vriend *
+ * *
+ * Permission to use, copy, modify, and/or distribute this software for any *
+ * purpose with or without fee is hereby granted, provided that the above *
+ * copyright notice and this permission notice appear in all copies. *
+ */
+#include "ftnoir_protocol_fg.h"
+#include "api/plugin-api.hpp"
+#include "opentrack-library-path.h"
+
+#include <QString>
+#include <QUrl>
+#include <QDir>
+#include <QDesktopServices>
+
+//*******************************************************************************************************
+// FaceTrackNoIR Client Settings-dialog.
+//*******************************************************************************************************
+
+//
+// Constructor for server-settings-dialog
+//
+FGControls::FGControls()
+{
+ ui.setupUi( this );
+
+ tie_setting(s.ip1, ui.spinIPFirstNibble);
+ tie_setting(s.ip2, ui.spinIPSecondNibble);
+ tie_setting(s.ip3, ui.spinIPThirdNibble);
+ tie_setting(s.ip4, ui.spinIPFourthNibble);
+ tie_setting(s.port, ui.spinPortNumber);
+
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
+ connect(ui.buttonBox, &QDialogButtonBox::helpRequested,
+ ui.buttonBox, []()
+ {
+ static const QString contrib_dir = "file:///" + QDir::toNativeSeparators(QStringLiteral("%1/%2/%3").
+ arg(OPENTRACK_BASE_PATH, OPENTRACK_CONTRIB_PATH, "FlightGear"));
+ QDesktopServices::openUrl(contrib_dir);
+ });
+}
+
+void FGControls::doOK()
+{
+ s.b->save();
+ close();
+}
+
+void FGControls::doCancel()
+{
+ close();
+}
+
diff --git a/proto-flightgear/images/flightgear.png b/proto-flightgear/images/flightgear.png
new file mode 100644
index 00000000..2a546642
--- /dev/null
+++ b/proto-flightgear/images/flightgear.png
Binary files differ
diff --git a/proto-flightgear/lang/nl_NL.ts b/proto-flightgear/lang/nl_NL.ts
new file mode 100644
index 00000000..35ab5431
--- /dev/null
+++ b/proto-flightgear/lang/nl_NL.ts
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="nl_NL">
+<context>
+ <name>UICFGControls</name>
+ <message>
+ <location filename="../ftnoir_fgcontrols.ui" line="+17"/>
+ <source>FlightGear protocol settings</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+12"/>
+ <source>IP-address remote PC</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+71"/>
+ <source>Port-number</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>flightgear</name>
+ <message>
+ <location filename="../ftnoir_protocol_fg.h" line="+40"/>
+ <source>FlightGear</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>flightgearDll</name>
+ <message>
+ <location line="+27"/>
+ <source>FlightGear</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/proto-flightgear/lang/ru_RU.ts b/proto-flightgear/lang/ru_RU.ts
new file mode 100644
index 00000000..916f5e2d
--- /dev/null
+++ b/proto-flightgear/lang/ru_RU.ts
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="ru_RU">
+<context>
+ <name>UICFGControls</name>
+ <message>
+ <location filename="../ftnoir_fgcontrols.ui" line="+17"/>
+ <source>FlightGear protocol settings</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+12"/>
+ <source>IP-address remote PC</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+71"/>
+ <source>Port-number</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>flightgear</name>
+ <message>
+ <location filename="../ftnoir_protocol_fg.h" line="+40"/>
+ <source>FlightGear</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>flightgearDll</name>
+ <message>
+ <location line="+27"/>
+ <source>FlightGear</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/proto-flightgear/lang/stub.ts b/proto-flightgear/lang/stub.ts
new file mode 100644
index 00000000..e94d44f2
--- /dev/null
+++ b/proto-flightgear/lang/stub.ts
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1">
+<context>
+ <name>UICFGControls</name>
+ <message>
+ <location filename="../ftnoir_fgcontrols.ui" line="+17"/>
+ <source>FlightGear protocol settings</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+12"/>
+ <source>IP-address remote PC</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+71"/>
+ <source>Port-number</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>flightgear</name>
+ <message>
+ <location filename="../ftnoir_protocol_fg.h" line="+40"/>
+ <source>FlightGear</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>flightgearDll</name>
+ <message>
+ <location line="+27"/>
+ <source>FlightGear</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>