diff options
Diffstat (limited to 'proto-udp')
-rw-r--r-- | proto-udp/ftnoir_protocol_ftn.cpp | 11 | ||||
-rw-r--r-- | proto-udp/ftnoir_protocol_ftn.h | 19 |
2 files changed, 17 insertions, 13 deletions
diff --git a/proto-udp/ftnoir_protocol_ftn.cpp b/proto-udp/ftnoir_protocol_ftn.cpp index 4d57140f..000a0a79 100644 --- a/proto-udp/ftnoir_protocol_ftn.cpp +++ b/proto-udp/ftnoir_protocol_ftn.cpp @@ -18,16 +18,21 @@ udp::udp() QObject::connect(s.b.get(), &bundle_::changed, this, &udp::set_dest_address, - Qt::QueuedConnection); + Qt::DirectConnection); } -void udp::pose(const double *headpose) { +void udp::pose(const double *headpose) +{ + QMutexLocker l(&lock); + outSocket.writeDatagram((const char *) headpose, sizeof(double[6]), dest_ip, dest_port); } void udp::set_dest_address() { - dest_port = s.port; + QMutexLocker l(&lock); + + dest_port = (unsigned short)s.port; dest_ip = QHostAddress((s.ip1.to<unsigned>() & 0xff) << 24 | (s.ip2.to<unsigned>() & 0xff) << 16 | (s.ip3.to<unsigned>() & 0xff) << 8 | diff --git a/proto-udp/ftnoir_protocol_ftn.h b/proto-udp/ftnoir_protocol_ftn.h index dc6e3a6f..53387a6c 100644 --- a/proto-udp/ftnoir_protocol_ftn.h +++ b/proto-udp/ftnoir_protocol_ftn.h @@ -11,10 +11,10 @@ #pragma once #include "ui_ftnoir_ftncontrols.h" -#include <QUdpSocket> #include "api/plugin-api.hpp" #include "options/options.hpp" using namespace options; +#include <QUdpSocket> struct settings : opts { value<int> ip1, ip2, ip3, ip4, port; @@ -35,15 +35,14 @@ class udp : public QObject, public IProtocol public: udp(); module_status initialize() override; - void pose(const double *headpose); - QString game_name() - { - return tr("UDP over network"); - } + void pose(const double *headpose) override; + QString game_name() override { return tr("UDP over network"); } private: QUdpSocket outSocket; settings s; + mutable QMutex lock; + QHostAddress dest_ip { 127u << 24 | 1u }; unsigned short dest_port = 65535; @@ -58,8 +57,8 @@ class FTNControls: public IProtocolDialog public: FTNControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} + void register_protocol(IProtocol *) override {} + void unregister_protocol() override {} private: Ui::UICFTNControls ui; settings s; @@ -72,6 +71,6 @@ class udp_sender_dll : public Metadata { Q_OBJECT - QString name() { return tr("UDP over network"); } - QIcon icon() { return QIcon(":/images/opentrack.png"); } + QString name() override { return tr("UDP over network"); } + QIcon icon() override { return QIcon(":/images/opentrack.png"); } }; |