From 0bc78d53028f5ac68b9ab454347b8ad453988c08 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 7 Apr 2017 21:36:10 +0200 Subject: rename several protocols from abbreviated names --- proto-flightgear/CMakeLists.txt | 1 + proto-flightgear/fg-protocol.qrc | 5 + proto-flightgear/ftnoir_fgcontrols.ui | 208 +++++++++++++++++++++++++ proto-flightgear/ftnoir_protocol_fg.cpp | 33 ++++ proto-flightgear/ftnoir_protocol_fg.h | 76 +++++++++ proto-flightgear/ftnoir_protocol_fg_dialog.cpp | 58 +++++++ proto-flightgear/images/flightgear.png | Bin 0 -> 979 bytes proto-flightgear/lang/nl_NL.ts | 38 +++++ proto-flightgear/lang/ru_RU.ts | 38 +++++ proto-flightgear/lang/stub.ts | 38 +++++ 10 files changed, 495 insertions(+) create mode 100644 proto-flightgear/CMakeLists.txt create mode 100644 proto-flightgear/fg-protocol.qrc create mode 100644 proto-flightgear/ftnoir_fgcontrols.ui create mode 100644 proto-flightgear/ftnoir_protocol_fg.cpp create mode 100644 proto-flightgear/ftnoir_protocol_fg.h create mode 100644 proto-flightgear/ftnoir_protocol_fg_dialog.cpp create mode 100644 proto-flightgear/images/flightgear.png create mode 100644 proto-flightgear/lang/nl_NL.ts create mode 100644 proto-flightgear/lang/ru_RU.ts create mode 100644 proto-flightgear/lang/stub.ts (limited to 'proto-flightgear') 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 @@ + + + images/flightgear.png + + 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 @@ + + + UICFGControls + + + Qt::NonModal + + + + 0 + 0 + 342 + 100 + + + + FlightGear protocol settings + + + Qt::LeftToRight + + + false + + + + 0 + + + 2 + + + + + QFrame::Raised + + + + 0 + + + + + + 0 + 0 + + + + IP address + + + + + + + + 0 + 0 + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 0 + 0 + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 0 + 0 + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 0 + 0 + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + + + QFrame::Raised + + + + 4 + + + + + + 10 + 0 + + + + Port + + + + + + + + 3 + 0 + + + + 1000 + + + 10000 + + + + + + + + + + + 0 + 0 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + 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(&FlightData), sizeof(FlightData), destIP, static_cast(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 +#include +#include +#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 ip1, ip2, ip3, ip4; + value 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 +#include +#include +#include + +//******************************************************************************************************* +// 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 Binary files /dev/null and b/proto-flightgear/images/flightgear.png 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 @@ + + + + + UICFGControls + + + FlightGear protocol settings + + + + + IP-address remote PC + + + + + Port-number + + + + + flightgear + + + FlightGear + + + + + flightgearDll + + + FlightGear + + + + 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 @@ + + + + + UICFGControls + + + FlightGear protocol settings + + + + + IP-address remote PC + + + + + Port-number + + + + + flightgear + + + FlightGear + + + + + flightgearDll + + + FlightGear + + + + 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 @@ + + + + + UICFGControls + + + FlightGear protocol settings + + + + + IP-address remote PC + + + + + Port-number + + + + + flightgear + + + FlightGear + + + + + flightgearDll + + + FlightGear + + + + -- cgit v1.2.3