From aa066bdd4622d4f6824fee864f6be6806813f04d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 07:37:41 +0100 Subject: move to subdirectory-based build system Closes #224 --- protocol-ftn/CMakeLists.txt | 1 + protocol-ftn/ftnoir_ftncontrols.ui | 266 ++++++++++++++++++++++++++++ protocol-ftn/ftnoir_protocol_ftn.cpp | 34 ++++ protocol-ftn/ftnoir_protocol_ftn.h | 69 ++++++++ protocol-ftn/ftnoir_protocol_ftn_dialog.cpp | 42 +++++ 5 files changed, 412 insertions(+) create mode 100644 protocol-ftn/CMakeLists.txt create mode 100644 protocol-ftn/ftnoir_ftncontrols.ui create mode 100644 protocol-ftn/ftnoir_protocol_ftn.cpp create mode 100644 protocol-ftn/ftnoir_protocol_ftn.h create mode 100644 protocol-ftn/ftnoir_protocol_ftn_dialog.cpp (limited to 'protocol-ftn') diff --git a/protocol-ftn/CMakeLists.txt b/protocol-ftn/CMakeLists.txt new file mode 100644 index 00000000..a0b74d9c --- /dev/null +++ b/protocol-ftn/CMakeLists.txt @@ -0,0 +1 @@ +opentrack_boilerplate(opentrack-proto-udp) diff --git a/protocol-ftn/ftnoir_ftncontrols.ui b/protocol-ftn/ftnoir_ftncontrols.ui new file mode 100644 index 00000000..ca811e99 --- /dev/null +++ b/protocol-ftn/ftnoir_ftncontrols.ui @@ -0,0 +1,266 @@ + + + UICFTNControls + + + Qt::NonModal + + + + 0 + 0 + 411 + 169 + + + + UDP protocol settings + + + + :/images/facetracknoir.png:/images/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + IP-address remote PC + + + + + + + Port-number + + + + + + + 1000 + + + 10000 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Enter IP-address and port-number for the remote PC. + + + true + + + + + + + Remember: you may have to change firewall-settings too! + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + spinIPFirstNibble + spinIPSecondNibble + spinIPThirdNibble + spinIPFourthNibble + spinPortNumber + btnOK + btnCancel + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/protocol-ftn/ftnoir_protocol_ftn.cpp b/protocol-ftn/ftnoir_protocol_ftn.cpp new file mode 100644 index 00000000..db852f55 --- /dev/null +++ b/protocol-ftn/ftnoir_protocol_ftn.cpp @@ -0,0 +1,34 @@ +/* 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_ftn.h" +#include +#include "opentrack/plugin-api.hpp" + +FTNoIR_Protocol::FTNoIR_Protocol() +{ +} + +void FTNoIR_Protocol::pose(const double *headpose) { + int destPort = s.port; + QHostAddress destIP(QString("%1.%2.%3.%4").arg( + QString::number(static_cast(s.ip1)), + QString::number(static_cast(s.ip2)), + QString::number(static_cast(s.ip3)), + QString::number(static_cast(s.ip4)))); + outSocket.writeDatagram((const char *) headpose, sizeof( double[6] ), destIP, destPort); +} + +bool FTNoIR_Protocol::correct() +{ + return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FTNControls, FTNoIR_ProtocolDll) diff --git a/protocol-ftn/ftnoir_protocol_ftn.h b/protocol-ftn/ftnoir_protocol_ftn.h new file mode 100644 index 00000000..7fe6c225 --- /dev/null +++ b/protocol-ftn/ftnoir_protocol_ftn.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_ftncontrols.h" +#include +#include +#include +#include +#include "opentrack/plugin-api.hpp" +#include "opentrack/options.hpp" +using namespace options; + +struct settings : opts { + value ip1, ip2, ip3, ip4, port; + settings() : + opts("udp-proto"), + ip1(b, "ip1", 192), + ip2(b, "ip2", 168), + ip3(b, "ip3", 0), + ip4(b, "ip4", 2), + port(b, "port", 4242) + {} +}; + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + bool correct(); + void pose(const double *headpose); + QString game_name() { + return "UDP Tracker"; + } +private: + QUdpSocket outSocket; + settings s; +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FTNControls: public IProtocolDialog +{ + Q_OBJECT +public: + FTNControls(); + void register_protocol(IProtocol *) {} + void unregister_protocol() {} +private: + Ui::UICFTNControls ui; + settings s; +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_ProtocolDll : public Metadata +{ +public: + QString name() { return QString("UDP receiver"); } + QIcon icon() { return QIcon(":/images/facetracknoir.png"); } +}; diff --git a/protocol-ftn/ftnoir_protocol_ftn_dialog.cpp b/protocol-ftn/ftnoir_protocol_ftn_dialog.cpp new file mode 100644 index 00000000..77a1508a --- /dev/null +++ b/protocol-ftn/ftnoir_protocol_ftn_dialog.cpp @@ -0,0 +1,42 @@ +/* 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_ftn.h" +#include "opentrack/plugin-api.hpp" + +FTNControls::FTNControls() +{ + 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.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); +} + +// +// OK clicked on server-dialog +// +void FTNControls::doOK() { + s.b->save(); + this->close(); +} + +// +// Cancel clicked on server-dialog +// +void FTNControls::doCancel() { + s.b->reload(); + this->close(); +} -- cgit v1.2.3