From 70048a925a7e34e1307c7ca501671f0bd75ec817 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Dec 2018 03:19:56 +0100 Subject: proto/fsuipc: don't look for unrelated .dll This .dll seems to be unrelated. Unless it performs some side effects in the background, there seems to be no reason whatsoever to look for it. This is completely untested. --- proto-fsuipc/ftnoir_fsuipccontrols.ui | 104 ++----------------------- proto-fsuipc/ftnoir_protocol_fsuipc.cpp | 73 +++++++---------- proto-fsuipc/ftnoir_protocol_fsuipc.h | 20 +++-- proto-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp | 13 +++- proto-fsuipc/lang/nl_NL.ts | 22 +----- proto-fsuipc/lang/ru_RU.ts | 22 +----- proto-fsuipc/lang/stub.ts | 22 +----- proto-fsuipc/lang/zh_CN.ts | 22 +----- 8 files changed, 64 insertions(+), 234 deletions(-) diff --git a/proto-fsuipc/ftnoir_fsuipccontrols.ui b/proto-fsuipc/ftnoir_fsuipccontrols.ui index 4c85c91c..5a28aad2 100644 --- a/proto-fsuipc/ftnoir_fsuipccontrols.ui +++ b/proto-fsuipc/ftnoir_fsuipccontrols.ui @@ -9,12 +9,12 @@ 0 0 - 512 - 100 + 248 + 34 - FSUIPC settings FaceTrackNoIR + FSUIPC @@ -26,99 +26,11 @@ false - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - 230 - 0 - - - - Location of FSUIPC.dll - - - QFrame::Box - - - QFrame::Sunken - - - 1 - - - Location of FSUIPC.dll - - - - - - - The DLL should be located in the Modules/ directory of MS FS 2004 - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 35 - 16777215 - - - - ... + + + + + QDialogButtonBox::Ok diff --git a/proto-fsuipc/ftnoir_protocol_fsuipc.cpp b/proto-fsuipc/ftnoir_protocol_fsuipc.cpp index 7ba466a8..678262fa 100644 --- a/proto-fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/proto-fsuipc/ftnoir_protocol_fsuipc.cpp @@ -13,24 +13,18 @@ #include -fsuipc::fsuipc() -{ - prevPosX = 0.0f; - prevPosY = 0.0f; - prevPosZ = 0.0f; - prevRotX = 0.0f; - prevRotY = 0.0f; - prevRotZ = 0.0f; -} +fsuipc::fsuipc() = default; fsuipc::~fsuipc() { FSUIPC_Close(); +#if 0 FSUIPCLib.unload(); +#endif } template -int fsuipc::scale2AnalogLimits(t x, t min_x, t max_x) +int fsuipc::scale(t x, t min_x, t max_x) { t local_x = x; @@ -48,58 +42,44 @@ int fsuipc::scale2AnalogLimits(t x, t min_x, t max_x) return (int) y; } +#if 0 template -static inline bool check_float_fresh(t x, t y) +static bool check_float_fresh(t x, t y) { constexpr t eps = t(1e-4); return std::fabs(x - y) >= eps; } +#endif -void fsuipc::pose(const double *headpose ) { +void fsuipc::pose(const double *headpose) +{ DWORD result; - TFSState pitch; - TFSState yaw; - TFSState roll; WORD FSZoom; - double virtPosX; - double virtPosY; - double virtPosZ; - - double virtRotX; - double virtRotY; - double virtRotZ; - - // qDebug() << "FSUIPCServer::run() says: started!"; - - virtRotX = -headpose[Pitch]; // degrees - virtRotY = headpose[Yaw]; - virtRotZ = headpose[Roll]; - - virtPosX = 0.0f; // cm, X and Y are not working for FS2002/2004! - virtPosY = 0.0f; - virtPosZ = headpose[TZ]; + // cm, X and Y are not working for FS2002/2004! + double pos_z = headpose[TZ]; + state pitch, yaw, roll; // NOLINT(cppcoreguidelines-pro-type-member-init) - // - // Init. the FSUIPC offsets (derived from Free-track...) - // + // offsets derived from freetrack pitch.Control = 66503; + pitch.Value = scale(-headpose[Pitch], -180., 180.); // degrees + yaw.Control = 66504; + yaw.Value = scale(headpose[Yaw], -180., 180.); + roll.Control = 66505; + roll.Value = scale(headpose[Roll], -180., 180.); - // +#if 0 // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. - // if (check_float_fresh(prevRotX, virtRotX) || check_float_fresh(prevRotY, virtRotY) || check_float_fresh(prevRotZ, virtRotZ) || check_float_fresh(prevPosX, virtPosX) || check_float_fresh(prevPosY, virtPosY) || check_float_fresh(prevPosZ, virtPosZ)) +#endif { - // - // Open the connection - // FSUIPC_Open(SIM_ANY, &result); // @@ -110,16 +90,11 @@ void fsuipc::pose(const double *headpose ) { { // Write the 4! DOF-data to FS. Only rotations and zoom are possible. - pitch.Value = scale2AnalogLimits(virtRotX, -180., 180.); FSUIPC_Write(0x3110, 8, &pitch, &result); - - yaw.Value = scale2AnalogLimits(virtRotY, -180., 180.); FSUIPC_Write(0x3110, 8, &yaw, &result); - - roll.Value = scale2AnalogLimits(virtRotZ, -180., 180.); FSUIPC_Write(0x3110, 8, &roll, &result); - FSZoom = WORD(virtPosZ + 64); + FSZoom = WORD(pos_z + 64); FSUIPC_Write(0x832E, 2, &FSZoom, &result); // @@ -136,16 +111,19 @@ void fsuipc::pose(const double *headpose ) { } } +#if 0 prevPosX = virtPosX; prevPosY = virtPosY; prevPosZ = virtPosZ; prevRotX = virtRotX; prevRotY = virtRotY; prevRotZ = virtRotZ; +#endif } module_status fsuipc::initialize() { +#if 0 FSUIPCLib.setFileName( s.LocationOfDLL ); FSUIPCLib.setLoadHints(QLibrary::PreventUnloadHint); @@ -153,6 +131,9 @@ module_status fsuipc::initialize() return error(tr("Can't load fsuipc at '%1'").arg(s.LocationOfDLL)); else return status_ok(); +#else + return {}; +#endif } OPENTRACK_DECLARE_PROTOCOL(fsuipc, FSUIPCControls, fsuipcDll) diff --git a/proto-fsuipc/ftnoir_protocol_fsuipc.h b/proto-fsuipc/ftnoir_protocol_fsuipc.h index 93e73e7f..62238032 100644 --- a/proto-fsuipc/ftnoir_protocol_fsuipc.h +++ b/proto-fsuipc/ftnoir_protocol_fsuipc.h @@ -27,6 +27,7 @@ #include "options/options.hpp" using namespace options; +#if 0 #define FSUIPC_FILENAME "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll" struct settings : opts { @@ -36,13 +37,14 @@ struct settings : opts { LocationOfDLL(b, "dll-location", FSUIPC_FILENAME) {} }; +#endif #pragma pack(push,1) // All fields in structure must be unaligned -typedef struct +struct state { int Control; // Control identifier int Value; // Value of DOF -} TFSState; +}; #pragma pack(pop) class fsuipc : public TR, public IProtocol @@ -56,12 +58,16 @@ public: void pose(const double* headpose) override; QString game_name() override { return tr("Microsoft Flight Simulator X"); } private: +#if 0 QLibrary FSUIPCLib; - double prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; + + double prevPosX = 0, prevPosY = 0, prevPosZ = 0, + prevRotX = 0, prevRotY = 0, prevRotZ = 0; settings s; +#endif template - static int scale2AnalogLimits(t x, t min_x, t max_x ); + static int scale(t x, t min_x, t max_x); }; class FSUIPCControls: public IProtocolDialog @@ -73,11 +79,15 @@ public: void unregister_protocol() override {} private: Ui::UICFSUIPCControls ui; +#if 0 settings s; +#endif private slots: - void doOK(); void doCancel(); +#if 0 + void doOK(); void getLocationOfDLL(); +#endif }; class fsuipcDll : public Metadata diff --git a/proto-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/proto-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index 07507cfb..122c9383 100644 --- a/proto-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/proto-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -14,23 +14,30 @@ FSUIPCControls::FSUIPCControls() { ui.setupUi( this ); +#if 0 connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); - tie_setting(s.LocationOfDLL, ui.txtLocationOfDLL); +#else + connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &FSUIPCControls::doCancel); +#endif } -void FSUIPCControls::doOK() { +#if 0 +void FSUIPCControls::doOK() +{ s.b->save(); close(); } +#endif void FSUIPCControls::doCancel() { close(); } +#if 0 void FSUIPCControls::getLocationOfDLL() { QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), @@ -40,4 +47,4 @@ void FSUIPCControls::getLocationOfDLL() s.LocationOfDLL = fileName; } } - +#endif diff --git a/proto-fsuipc/lang/nl_NL.ts b/proto-fsuipc/lang/nl_NL.ts index dd7d7942..4a7578e9 100644 --- a/proto-fsuipc/lang/nl_NL.ts +++ b/proto-fsuipc/lang/nl_NL.ts @@ -15,27 +15,7 @@ UICFSUIPCControls - FSUIPC settings FaceTrackNoIR - - - - Cancel - - - - Location of FSUIPC.dll - - - - The DLL should be located in the Modules/ directory of MS FS 2004 - - - - OK - - - - ... + FSUIPC diff --git a/proto-fsuipc/lang/ru_RU.ts b/proto-fsuipc/lang/ru_RU.ts index 29f52f79..dd26dd22 100644 --- a/proto-fsuipc/lang/ru_RU.ts +++ b/proto-fsuipc/lang/ru_RU.ts @@ -15,27 +15,7 @@ UICFSUIPCControls - FSUIPC settings FaceTrackNoIR - - - - Cancel - - - - Location of FSUIPC.dll - - - - The DLL should be located in the Modules/ directory of MS FS 2004 - - - - OK - - - - ... + FSUIPC diff --git a/proto-fsuipc/lang/stub.ts b/proto-fsuipc/lang/stub.ts index 16662c44..031e1916 100644 --- a/proto-fsuipc/lang/stub.ts +++ b/proto-fsuipc/lang/stub.ts @@ -15,27 +15,7 @@ UICFSUIPCControls - FSUIPC settings FaceTrackNoIR - - - - Cancel - - - - Location of FSUIPC.dll - - - - The DLL should be located in the Modules/ directory of MS FS 2004 - - - - OK - - - - ... + FSUIPC diff --git a/proto-fsuipc/lang/zh_CN.ts b/proto-fsuipc/lang/zh_CN.ts index 16662c44..031e1916 100644 --- a/proto-fsuipc/lang/zh_CN.ts +++ b/proto-fsuipc/lang/zh_CN.ts @@ -15,27 +15,7 @@ UICFSUIPCControls - FSUIPC settings FaceTrackNoIR - - - - Cancel - - - - Location of FSUIPC.dll - - - - The DLL should be located in the Modules/ directory of MS FS 2004 - - - - OK - - - - ... + FSUIPC -- cgit v1.2.3