summaryrefslogtreecommitdiffhomepage
path: root/proto-fsuipc/ftnoir_protocol_fsuipc.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-28 03:19:56 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-01-16 07:48:18 +0100
commit70048a925a7e34e1307c7ca501671f0bd75ec817 (patch)
treeab611d9e5023b50cc64a8a8a2ff64200b1729702 /proto-fsuipc/ftnoir_protocol_fsuipc.cpp
parent74b401e24b9b3c9333f6e435860e1bc1f44a3b6f (diff)
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.
Diffstat (limited to 'proto-fsuipc/ftnoir_protocol_fsuipc.cpp')
-rw-r--r--proto-fsuipc/ftnoir_protocol_fsuipc.cpp73
1 files changed, 27 insertions, 46 deletions
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 <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();
+#if 0
FSUIPCLib.unload();
+#endif
}
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 +42,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)
+{
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)