summaryrefslogtreecommitdiffhomepage
path: root/proto-simconnect
diff options
context:
space:
mode:
Diffstat (limited to 'proto-simconnect')
-rw-r--r--proto-simconnect/ftnoir_protocol_sc.cpp32
-rw-r--r--proto-simconnect/ftnoir_protocol_sc.h2
-rw-r--r--proto-simconnect/lang/de_DE.ts69
-rw-r--r--proto-simconnect/lang/zh_CN.ts2
4 files changed, 81 insertions, 24 deletions
diff --git a/proto-simconnect/ftnoir_protocol_sc.cpp b/proto-simconnect/ftnoir_protocol_sc.cpp
index 226a427b..ca76e0ce 100644
--- a/proto-simconnect/ftnoir_protocol_sc.cpp
+++ b/proto-simconnect/ftnoir_protocol_sc.cpp
@@ -43,20 +43,15 @@ void simconnect::run()
qDebug() << "fsx: connect failed, retry in" << sleep_time << "seconds...";
else
{
- Timer tm;
-
- if (!SUCCEEDED(hr = simconnect_subscribe(handle, 0, "Frame")))
+ if (!SUCCEEDED(hr = simconnect_subscribe(handle, 0, "1sec")))
qDebug() << "fsx: can't subscribe to frame event:" << (void*)hr;
else
{
while (!isInterruptionRequested())
{
- constexpr int max_idle_seconds = 2;
-
- if (WaitForSingleObject(event, 0) == WAIT_OBJECT_0)
- tm.start();
+ constexpr int max_idle_ms = 2000;
- if ((int)tm.elapsed_seconds() > max_idle_seconds)
+ if (WaitForSingleObject(event, max_idle_ms) != WAIT_OBJECT_0)
{
qDebug() << "fsx: timeout reached, reconnecting";
break;
@@ -73,7 +68,9 @@ void simconnect::run()
}
}
+ QMutexLocker l(&mtx);
(void)simconnect_close(handle);
+ handle = nullptr;
}
for (unsigned k = 0; k < sleep_time * 25; k++)
@@ -91,8 +88,6 @@ void simconnect::run()
void simconnect::pose(const double* pose, const double*)
{
- QMutexLocker l(&mtx);
-
data[Pitch] = (float)-pose[Pitch];
data[Yaw] = (float)pose[Yaw];
data[Roll] = (float)pose[Roll];
@@ -101,6 +96,12 @@ void simconnect::pose(const double* pose, const double*)
data[TX] = (float)-pose[TX] * to_meters;
data[TY] = (float)pose[TY] * to_meters;
data[TZ] = (float)-pose[TZ] * to_meters;
+
+ QMutexLocker l(&mtx);
+ if (handle)
+ (void)simconnect_set6DOF(handle,
+ data[TX], data[TY], data[TZ],
+ data[Pitch], data[Roll], data[Yaw]);
}
module_status simconnect::initialize()
@@ -148,14 +149,6 @@ module_status simconnect::initialize()
return {};
}
-void simconnect::handler()
-{
- QMutexLocker l(&mtx);
- (void)simconnect_set6DOF(handle,
- data[TX], data[TY], data[TZ],
- data[Pitch], data[Roll], data[Yaw]);
-}
-
void simconnect::event_handler(SIMCONNECT_RECV* pData, DWORD, void* self_)
{
simconnect& self = *reinterpret_cast<simconnect*>(self_);
@@ -172,9 +165,6 @@ void simconnect::event_handler(SIMCONNECT_RECV* pData, DWORD, void* self_)
qDebug() << "fsx: got quit event";
self.reconnect = true;
break;
- case SIMCONNECT_RECV_ID_EVENT_FRAME:
- self.handler();
- break;
}
}
diff --git a/proto-simconnect/ftnoir_protocol_sc.h b/proto-simconnect/ftnoir_protocol_sc.h
index 28b9b1d8..df3a538d 100644
--- a/proto-simconnect/ftnoir_protocol_sc.h
+++ b/proto-simconnect/ftnoir_protocol_sc.h
@@ -47,8 +47,6 @@ public:
void run() override;
private:
- void handler();
-
enum {
SIMCONNECT_RECV_ID_EXCEPTION = 2,
SIMCONNECT_RECV_ID_QUIT = 3,
diff --git a/proto-simconnect/lang/de_DE.ts b/proto-simconnect/lang/de_DE.ts
new file mode 100644
index 00000000..3d6a4157
--- /dev/null
+++ b/proto-simconnect/lang/de_DE.ts
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="de_DE">
+<context>
+ <name>UICSCControls</name>
+ <message>
+ <source>Protocol settings</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>FSX version</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Prepar3d / SP2 XPACK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>RTM</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>SP1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>SP2 -- Acceleration</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Steam FSX (older)</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Steam FSX (newer)</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>You need to install SimConnect SDK for your FSX version. For the Steam version, choose SP1 in the above combo box.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>simconnect</name>
+ <message>
+ <source>dll load failed: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Install FSX/Prepar3D SimConnect SDK.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>can&apos;t import %1: %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>FSX / Prepar3D</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>simconnect_metadata</name>
+ <message>
+ <source>Microsoft FSX SimConnect</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/proto-simconnect/lang/zh_CN.ts b/proto-simconnect/lang/zh_CN.ts
index 50d0fa8a..86e487f2 100644
--- a/proto-simconnect/lang/zh_CN.ts
+++ b/proto-simconnect/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>UICSCControls</name>
<message>