diff options
Diffstat (limited to 'proto-fsuipc')
-rw-r--r-- | proto-fsuipc/CMakeLists.txt | 5 | ||||
-rw-r--r-- | proto-fsuipc/ftnoir_fsuipccontrols.ui | 104 | ||||
-rw-r--r-- | proto-fsuipc/ftnoir_protocol_fsuipc.cpp | 76 | ||||
-rw-r--r-- | proto-fsuipc/ftnoir_protocol_fsuipc.h | 39 | ||||
-rw-r--r-- | proto-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp | 13 | ||||
-rw-r--r-- | proto-fsuipc/lang/nl_NL.ts | 22 | ||||
-rw-r--r-- | proto-fsuipc/lang/ru_RU.ts | 22 | ||||
-rw-r--r-- | proto-fsuipc/lang/stub.ts | 22 | ||||
-rw-r--r-- | proto-fsuipc/lang/zh_CN.ts | 24 |
9 files changed, 114 insertions, 213 deletions
diff --git a/proto-fsuipc/CMakeLists.txt b/proto-fsuipc/CMakeLists.txt index 3ba2c90c..9b7bd77e 100644 --- a/proto-fsuipc/CMakeLists.txt +++ b/proto-fsuipc/CMakeLists.txt @@ -1,12 +1,11 @@ -if(WIN32) +if(WIN32 AND NOT opentrack-64bit AND opentrack-intel) set(SDK_FSUIPC "" CACHE PATH "FSUIPC for older MS FSX path") if(SDK_FSUIPC) otr_module(proto-fsuipc) target_link_libraries(opentrack-proto-fsuipc ${SDK_FSUIPC}/FSUIPC_User.lib) target_include_directories(opentrack-proto-fsuipc SYSTEM PUBLIC ${SDK_FSUIPC}) if(MSVC) - set_property(TARGET opentrack-proto-fsuipc APPEND_STRING PROPERTY - LINK_FLAGS "/NODEFAULTLIB:LIBC.lib ") + target_link_options(${self} PRIVATE -NODEFAULTLIB:LIBC.lib) endif() endif() endif() 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 @@ <rect> <x>0</x> <y>0</y> - <width>512</width> - <height>100</height> + <width>248</width> + <height>34</height> </rect> </property> <property name="windowTitle"> - <string>FSUIPC settings FaceTrackNoIR</string> + <string>FSUIPC</string> </property> <property name="windowIcon"> <iconset> @@ -26,99 +26,11 @@ <property name="autoFillBackground"> <bool>false</bool> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="1"> - <widget class="QPushButton" name="btnCancel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="txtLocationOfDLL"> - <property name="minimumSize"> - <size> - <width>230</width> - <height>0</height> - </size> - </property> - <property name="toolTip"> - <string>Location of FSUIPC.dll</string> - </property> - <property name="frameShape"> - <enum>QFrame::Box</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Sunken</enum> - </property> - <property name="lineWidth"> - <number>1</number> - </property> - <property name="text"> - <string>Location of FSUIPC.dll</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>The DLL should be located in the Modules/ directory of MS FS 2004</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QPushButton" name="btnOK"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>OK</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QPushButton" name="btnFindDLL"> - <property name="maximumSize"> - <size> - <width>35</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>...</string> + <layout class="QVBoxLayout" name="verticalLayout"> + <item alignment="Qt::AlignTop"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Ok</set> </property> </widget> </item> diff --git a/proto-fsuipc/ftnoir_protocol_fsuipc.cpp b/proto-fsuipc/ftnoir_protocol_fsuipc.cpp index 64a14f5f..b7c39ab1 100644 --- a/proto-fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/proto-fsuipc/ftnoir_protocol_fsuipc.cpp @@ -13,24 +13,15 @@ #include <cmath> -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(); - FSUIPCLib.unload(); } template<typename t> -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 +39,44 @@ int fsuipc::scale2AnalogLimits(t x, t min_x, t max_x) return (int) y; } +#if 0 template<typename t> -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, const double*) +{ 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 +87,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,23 +108,29 @@ 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); - if (FSUIPCLib.load() != true) - return error(_("Can't load fsuipc at '%1'").arg(s.LocationOfDLL)); + if (!FSUIPCLib.load()) + 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 c0560efe..99701d15 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,30 +37,37 @@ 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 IProtocol +class fsuipc : public TR, public IProtocol { + Q_OBJECT + public: fsuipc(); ~fsuipc() override; module_status initialize() override; - void pose(const double* headpose); - QString game_name() { return otr_tr("Microsoft Flight Simulator X"); } + void pose(const double* headpose, const double*) 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<typename t> - 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 @@ -67,22 +75,27 @@ class FSUIPCControls: public IProtocolDialog Q_OBJECT public: FSUIPCControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} + void register_protocol(IProtocol *) override {} + 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 { -public: - QString name() { return otr_tr("FSUIPC -- Microsoft FS2002/FS2004"); } - QIcon icon() { return QIcon(":/images/fs9.png"); } + Q_OBJECT + + QString name() override { return tr("FSUIPC -- Microsoft FS2002/FS2004"); } + QIcon icon() override { return QIcon(":/images/fs9.png"); } }; 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 932f407d..4a7578e9 100644 --- a/proto-fsuipc/lang/nl_NL.ts +++ b/proto-fsuipc/lang/nl_NL.ts @@ -15,27 +15,25 @@ <context> <name>UICFSUIPCControls</name> <message> - <source>FSUIPC settings FaceTrackNoIR</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Cancel</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Location of FSUIPC.dll</source> + <source>FSUIPC</source> <translation type="unfinished"></translation> </message> +</context> +<context> + <name>fsuipc</name> <message> - <source>The DLL should be located in the Modules/ directory of MS FS 2004</source> + <source>Microsoft Flight Simulator X</source> <translation type="unfinished"></translation> </message> <message> - <source>OK</source> + <source>Can't load fsuipc at '%1'</source> <translation type="unfinished"></translation> </message> +</context> +<context> + <name>fsuipcDll</name> <message> - <source>...</source> + <source>FSUIPC -- Microsoft FS2002/FS2004</source> <translation type="unfinished"></translation> </message> </context> diff --git a/proto-fsuipc/lang/ru_RU.ts b/proto-fsuipc/lang/ru_RU.ts index 77d8c0b3..dd26dd22 100644 --- a/proto-fsuipc/lang/ru_RU.ts +++ b/proto-fsuipc/lang/ru_RU.ts @@ -15,27 +15,25 @@ <context> <name>UICFSUIPCControls</name> <message> - <source>FSUIPC settings FaceTrackNoIR</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Cancel</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Location of FSUIPC.dll</source> + <source>FSUIPC</source> <translation type="unfinished"></translation> </message> +</context> +<context> + <name>fsuipc</name> <message> - <source>The DLL should be located in the Modules/ directory of MS FS 2004</source> + <source>Microsoft Flight Simulator X</source> <translation type="unfinished"></translation> </message> <message> - <source>OK</source> + <source>Can't load fsuipc at '%1'</source> <translation type="unfinished"></translation> </message> +</context> +<context> + <name>fsuipcDll</name> <message> - <source>...</source> + <source>FSUIPC -- Microsoft FS2002/FS2004</source> <translation type="unfinished"></translation> </message> </context> diff --git a/proto-fsuipc/lang/stub.ts b/proto-fsuipc/lang/stub.ts index 05fbe216..031e1916 100644 --- a/proto-fsuipc/lang/stub.ts +++ b/proto-fsuipc/lang/stub.ts @@ -15,27 +15,25 @@ <context> <name>UICFSUIPCControls</name> <message> - <source>FSUIPC settings FaceTrackNoIR</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Cancel</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Location of FSUIPC.dll</source> + <source>FSUIPC</source> <translation type="unfinished"></translation> </message> +</context> +<context> + <name>fsuipc</name> <message> - <source>The DLL should be located in the Modules/ directory of MS FS 2004</source> + <source>Microsoft Flight Simulator X</source> <translation type="unfinished"></translation> </message> <message> - <source>OK</source> + <source>Can't load fsuipc at '%1'</source> <translation type="unfinished"></translation> </message> +</context> +<context> + <name>fsuipcDll</name> <message> - <source>...</source> + <source>FSUIPC -- Microsoft FS2002/FS2004</source> <translation type="unfinished"></translation> </message> </context> diff --git a/proto-fsuipc/lang/zh_CN.ts b/proto-fsuipc/lang/zh_CN.ts index 05fbe216..8df82996 100644 --- a/proto-fsuipc/lang/zh_CN.ts +++ b/proto-fsuipc/lang/zh_CN.ts @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> -<TS version="2.1"> +<TS version="2.1" language="zh_CN"> <context> <name>FSUIPCControls</name> <message> @@ -15,27 +15,25 @@ <context> <name>UICFSUIPCControls</name> <message> - <source>FSUIPC settings FaceTrackNoIR</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Cancel</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Location of FSUIPC.dll</source> + <source>FSUIPC</source> <translation type="unfinished"></translation> </message> +</context> +<context> + <name>fsuipc</name> <message> - <source>The DLL should be located in the Modules/ directory of MS FS 2004</source> + <source>Microsoft Flight Simulator X</source> <translation type="unfinished"></translation> </message> <message> - <source>OK</source> + <source>Can't load fsuipc at '%1'</source> <translation type="unfinished"></translation> </message> +</context> +<context> + <name>fsuipcDll</name> <message> - <source>...</source> + <source>FSUIPC -- Microsoft FS2002/FS2004</source> <translation type="unfinished"></translation> </message> </context> |