diff options
Diffstat (limited to 'proto-fg')
| -rw-r--r-- | proto-fg/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | proto-fg/fg-protocol.qrc | 5 | ||||
| -rw-r--r-- | proto-fg/fgtypes.h | 27 | ||||
| -rw-r--r-- | proto-fg/ftnoir_fgcontrols.ui | 136 | ||||
| -rw-r--r-- | proto-fg/ftnoir_protocol_fg.cpp | 38 | ||||
| -rw-r--r-- | proto-fg/ftnoir_protocol_fg.h | 69 | ||||
| -rw-r--r-- | proto-fg/ftnoir_protocol_fg_dialog.cpp | 46 | ||||
| -rw-r--r-- | proto-fg/images/flightgear.png | bin | 0 -> 979 bytes | 
8 files changed, 322 insertions, 0 deletions
diff --git a/proto-fg/CMakeLists.txt b/proto-fg/CMakeLists.txt new file mode 100644 index 00000000..151b30ee --- /dev/null +++ b/proto-fg/CMakeLists.txt @@ -0,0 +1 @@ +opentrack_boilerplate(opentrack-proto-fgfs) diff --git a/proto-fg/fg-protocol.qrc b/proto-fg/fg-protocol.qrc new file mode 100644 index 00000000..1c685437 --- /dev/null +++ b/proto-fg/fg-protocol.qrc @@ -0,0 +1,5 @@ +<RCC> +    <qresource prefix="/"> +        <file>images/flightgear.png</file> +    </qresource> +</RCC> diff --git a/proto-fg/fgtypes.h b/proto-fg/fgtypes.h new file mode 100644 index 00000000..2e493f46 --- /dev/null +++ b/proto-fg/fgtypes.h @@ -0,0 +1,27 @@ +/******************************************************************************** +* FaceTrackNoIR         This program is a private project of the some enthusiastic      * +*                                       gamers from Holland, who don't like to pay much for                     * +*                                       head-tracking.                                                                                          * +*                                                                                                                                                               * +* Copyright (C) 2010    Wim Vriend (Developing)                                                                 * +*                                               Ron Hendriks (Researching and Testing)                                  * +*                                                                                                                                                               * +* Homepage                                                                                                                                              * +*                                                                                                                                                               * +* Type definitions for the FlightGear server.                                                                   * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FGTYPES_H +#define INCLUDED_FGTYPES_H + +// +// x,y,z position in metres, heading, pitch and roll in degrees... +// +#pragma pack(push, 2) +struct TFlightGearData { +    double x, y, z, h, p, r; +    int status; +}; +#pragma pack(pop) + +#endif//INCLUDED_FGTYPES_H diff --git a/proto-fg/ftnoir_fgcontrols.ui b/proto-fg/ftnoir_fgcontrols.ui new file mode 100644 index 00000000..bd5b95c7 --- /dev/null +++ b/proto-fg/ftnoir_fgcontrols.ui @@ -0,0 +1,136 @@ +<?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>415</width> +    <height>112</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="QGridLayout" name="gridLayout"> +   <item row="0" column="0"> +    <widget class="QLabel" name="label_4"> +     <property name="text"> +      <string>IP-address remote PC</string> +     </property> +    </widget> +   </item> +   <item row="0" column="1"> +    <widget class="QSpinBox" name="spinIPFirstNibble"> +     <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 row="0" column="2"> +    <widget class="QSpinBox" name="spinIPSecondNibble"> +     <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 row="0" column="3"> +    <widget class="QSpinBox" name="spinIPThirdNibble"> +     <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 row="0" column="4"> +    <widget class="QSpinBox" name="spinIPFourthNibble"> +     <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 row="1" column="0"> +    <widget class="QLabel" name="label_5"> +     <property name="text"> +      <string>Port-number</string> +     </property> +    </widget> +   </item> +   <item row="1" column="1"> +    <widget class="QSpinBox" name="spinPortNumber"> +     <property name="minimum"> +      <number>1000</number> +     </property> +     <property name="maximum"> +      <number>10000</number> +     </property> +    </widget> +   </item> +   <item row="2" column="2" colspan="3"> +    <widget class="QDialogButtonBox" name="buttonBox"> +     <property name="standardButtons"> +      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> +     </property> +    </widget> +   </item> +  </layout> + </widget> + <tabstops> +  <tabstop>spinIPFirstNibble</tabstop> +  <tabstop>spinIPSecondNibble</tabstop> +  <tabstop>spinIPThirdNibble</tabstop> +  <tabstop>spinIPFourthNibble</tabstop> +  <tabstop>spinPortNumber</tabstop> + </tabstops> + <connections/> + <slots> +  <slot>startEngineClicked()</slot> +  <slot>stopEngineClicked()</slot> +  <slot>cameraSettingsClicked()</slot> + </slots> +</ui> diff --git a/proto-fg/ftnoir_protocol_fg.cpp b/proto-fg/ftnoir_protocol_fg.cpp new file mode 100644 index 00000000..660a7352 --- /dev/null +++ b/proto-fg/ftnoir_protocol_fg.cpp @@ -0,0 +1,38 @@ +/* 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 "opentrack/plugin-api.hpp" + +// For Todd and Arda Kutlu + +void FTNoIR_Protocol::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(QString("%1.%2.%3.%4").arg( +                            QString::number(static_cast<int>(s.ip1)), +                            QString::number(static_cast<int>(s.ip2)), +                            QString::number(static_cast<int>(s.ip3)), +                            QString::number(static_cast<int>(s.ip4)))); +    int destPort = s.port; +    (void) outSocket.writeDatagram(reinterpret_cast<const char*>(&FlightData), sizeof(FlightData), destIP, static_cast<quint16>(destPort)); +} + +bool FTNoIR_Protocol::correct() +{    +    return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FGControls, FTNoIR_ProtocolDll) diff --git a/proto-fg/ftnoir_protocol_fg.h b/proto-fg/ftnoir_protocol_fg.h new file mode 100644 index 00000000..de528270 --- /dev/null +++ b/proto-fg/ftnoir_protocol_fg.h @@ -0,0 +1,69 @@ +/* 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 "fgtypes.h" +#include <QThread> +#include <QUdpSocket> +#include <QMessageBox> +#include "opentrack/plugin-api.hpp" +#include "opentrack/options.hpp" +using namespace options; + +struct settings : opts { +    value<int> ip1, ip2, ip3, ip4; +    value<int> port; +    settings() : +        opts("flightgear-proto"), +        ip1(b, "ip1", 192), +        ip2(b, "ip2", 168), +        ip3(b, "ip3", 0), +        ip4(b, "ip4", 2), +        port(b, "port", 5542) +    {} +}; + +class FTNoIR_Protocol : public IProtocol +{ +public: +    bool correct(); +    void pose(const double *headpose); +    QString game_name() { +        return "FlightGear"; +    } +private: +    settings s; +    TFlightGearData 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 FTNoIR_ProtocolDll : public Metadata +{ +public: +    QString name() { return QString("FlightGear"); } +    QIcon icon() { return QIcon(":/images/flightgear.png"); } +}; diff --git a/proto-fg/ftnoir_protocol_fg_dialog.cpp b/proto-fg/ftnoir_protocol_fg_dialog.cpp new file mode 100644 index 00000000..1d583115 --- /dev/null +++ b/proto-fg/ftnoir_protocol_fg_dialog.cpp @@ -0,0 +1,46 @@ +/* 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 <QObject> +#include <QFile> +#include "opentrack/plugin-api.hpp" + +//******************************************************************************************************* +// 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())); +} + +void FGControls::doOK() { +    s.b->save(); +	this->close(); +} + +void FGControls::doCancel() { +    s.b->reload(); +    this->close(); +} + diff --git a/proto-fg/images/flightgear.png b/proto-fg/images/flightgear.png Binary files differnew file mode 100644 index 00000000..2a546642 --- /dev/null +++ b/proto-fg/images/flightgear.png  | 
