summaryrefslogtreecommitdiffhomepage
path: root/proto-simconnect
diff options
context:
space:
mode:
Diffstat (limited to 'proto-simconnect')
-rw-r--r--proto-simconnect/ftnoir-protocol-sc.rc8
-rw-r--r--proto-simconnect/ftnoir_protocol_sc.cpp148
-rw-r--r--proto-simconnect/ftnoir_protocol_sc.h42
-rw-r--r--proto-simconnect/ftnoir_protocol_sc_dialog.cpp10
-rw-r--r--proto-simconnect/ftnoir_sccontrols.ui10
-rw-r--r--proto-simconnect/lang/nl_NL.ts20
-rw-r--r--proto-simconnect/lang/ru_RU.ts20
-rw-r--r--proto-simconnect/lang/stub.ts20
-rw-r--r--proto-simconnect/lang/zh_CN.ts20
9 files changed, 161 insertions, 137 deletions
diff --git a/proto-simconnect/ftnoir-protocol-sc.rc b/proto-simconnect/ftnoir-protocol-sc.rc
index f1a7b531..0d501812 100644
--- a/proto-simconnect/ftnoir-protocol-sc.rc
+++ b/proto-simconnect/ftnoir-protocol-sc.rc
@@ -1,7 +1,7 @@
#define RT_MANIFEST 24
-142 RT_MANIFEST fsx_rtm.manifest
-143 RT_MANIFEST fsx_sp1.manifest
-144 RT_MANIFEST fsx_sp2.manifest
-145 RT_MANIFEST fsx_p3d_sp2_xpack.manifest
+142 RT_MANIFEST fsx_p3d_sp2_xpack.manifest
+143 RT_MANIFEST fsx_rtm.manifest
+144 RT_MANIFEST fsx_sp1.manifest
+145 RT_MANIFEST fsx_sp2.manifest
146 RT_MANIFEST fsx_steam_orig.manifest
147 RT_MANIFEST fsx_steam_last.manifest
diff --git a/proto-simconnect/ftnoir_protocol_sc.cpp b/proto-simconnect/ftnoir_protocol_sc.cpp
index 580dc257..ddab4614 100644
--- a/proto-simconnect/ftnoir_protocol_sc.cpp
+++ b/proto-simconnect/ftnoir_protocol_sc.cpp
@@ -34,9 +34,9 @@ void simconnect::run()
{
HRESULT hr;
- if (SUCCEEDED(hr = simconnect_open(&hSimConnect, "opentrack", nullptr, 0, event, 0)))
+ if (SUCCEEDED(hr = simconnect_open(&handle, "opentrack", nullptr, 0, event, 0)))
{
- if (!SUCCEEDED(hr = simconnect_subscribetosystemevent(hSimConnect, 0, "Frame")))
+ if (!SUCCEEDED(hr = simconnect_subscribetosystemevent(handle, 0, "Frame")))
{
qDebug() << "simconnect: can't subscribe to frame event:" << hr;
}
@@ -54,7 +54,7 @@ void simconnect::run()
{
tm.start();
- if (!SUCCEEDED(hr = simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast<void*>(this))))
+ if (!SUCCEEDED(hr = simconnect_calldispatch(handle, processNextSimconnectEvent, reinterpret_cast<void*>(this))))
{
qDebug() << "simconnect: calldispatch failed:" << hr;
break;
@@ -74,7 +74,7 @@ void simconnect::run()
}
}
- (void) simconnect_close(hSimConnect);
+ (void) simconnect_close(handle);
}
else
qDebug() << "simconnect: can't open handle:" << hr;
@@ -101,96 +101,101 @@ void simconnect::pose( const double *headpose )
virtSCPosZ = float(-headpose[TZ]/100);
}
-#ifdef __GNUC__
-# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
-#endif
-
class ActivationContext
{
public:
- explicit ActivationContext(int resid)
- {
- ACTCTXA actx = {};
- actx.cbSize = sizeof(actx);
- actx.lpResourceName = MAKEINTRESOURCEA(resid);
- actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID;
- static const QString prefix = OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH;
- QString path = prefix + "lib" "opentrack-proto-simconnect.dll";
- QByteArray name = QFile::encodeName(path);
- actx.lpSource = name.constData();
- hactctx = CreateActCtxA(&actx);
- if (hactctx != INVALID_HANDLE_VALUE)
- {
- if (!ActivateActCtx(hactctx, &actctx_cookie))
- {
- qDebug() << "simconnect: can't set win32 activation context" << GetLastError();
- ReleaseActCtx(hactctx);
- hactctx = INVALID_HANDLE_VALUE;
- }
- else
- ok = true;
- } else {
- qDebug() << "simconnect: can't create win32 activation context" << GetLastError();
- }
- }
- ~ActivationContext() {
- if (hactctx != INVALID_HANDLE_VALUE)
- {
- DeactivateActCtx(0, actctx_cookie);
- ReleaseActCtx(hactctx);
- }
- }
+ explicit ActivationContext(int resid);
+ ~ActivationContext();
+
bool is_ok() const { return ok; }
private:
- ULONG_PTR actctx_cookie = 0;
- HANDLE hactctx = INVALID_HANDLE_VALUE;
+ ULONG_PTR cookie = 0;
+ HANDLE handle = INVALID_HANDLE_VALUE;
bool ok = false;
};
+ActivationContext::ActivationContext(int resid)
+{
+ ACTCTXA actx = {};
+ actx.cbSize = sizeof(actx);
+ actx.lpResourceName = MAKEINTRESOURCEA(resid);
+ actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID;
+ static const QString prefix = OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH;
+ QString path = prefix + OPENTRACK_LIBRARY_PREFIX "opentrack-proto-simconnect." OPENTRACK_LIBRARY_EXTENSION;
+ QByteArray name = QFile::encodeName(path);
+ actx.lpSource = name.constData();
+ handle = CreateActCtxA(&actx);
+ if (handle != INVALID_HANDLE_VALUE)
+ {
+ if (!ActivateActCtx(handle, &cookie))
+ {
+ qDebug() << "simconnect: can't set win32 activation context" << GetLastError();
+ ReleaseActCtx(handle);
+ handle = INVALID_HANDLE_VALUE;
+ }
+ else
+ ok = true;
+ } else {
+ qDebug() << "simconnect: can't create win32 activation context" << GetLastError();
+ }
+}
+
+ActivationContext::~ActivationContext()
+{
+ if (handle != INVALID_HANDLE_VALUE)
+ {
+ DeactivateActCtx(0, cookie);
+ ReleaseActCtx(handle);
+ }
+}
+
module_status simconnect::initialize()
{
- if (!SCClientLib.isLoaded())
+ if (!library.isLoaded())
{
ActivationContext ctx(142 + s.sxs_manifest);
if (ctx.is_ok())
{
- SCClientLib.setFileName("SimConnect.dll");
- SCClientLib.setLoadHints(QLibrary::PreventUnloadHint | QLibrary::ResolveAllSymbolsHint);
- if (!SCClientLib.load())
- return error(tr("dll load failed -- %1").arg(SCClientLib.errorString()));
+ library.setFileName("SimConnect.dll");
+ library.setLoadHints(QLibrary::PreventUnloadHint | QLibrary::ResolveAllSymbolsHint);
+ if (!library.load())
+ return error(tr("dll load failed: %1").arg(library.errorString()));
}
else
- return error(tr("can't load SDK -- check selected simconnect version"));
+ // XXX TODO add instructions for fsx and p3d -sh 20190128
+ return error(tr("install FSX SDK"));
}
- simconnect_open = (importSimConnect_Open) SCClientLib.resolve("SimConnect_Open");
- if (!simconnect_open)
- return error("Open function not found in DLL!");
- simconnect_set6DOF = (importSimConnect_CameraSetRelative6DOF) SCClientLib.resolve("SimConnect_CameraSetRelative6DOF");
- if (!simconnect_set6DOF)
- return error("CameraSetRelative6DOF function not found in DLL!");
- simconnect_close = (importSimConnect_Close) SCClientLib.resolve("SimConnect_Close");
- if (!simconnect_close)
- return error("Close function not found in DLL!");
+ using ptr = void(*)();
- simconnect_calldispatch = (importSimConnect_CallDispatch) SCClientLib.resolve("SimConnect_CallDispatch");
- if (!simconnect_calldispatch)
- return error("CallDispatch function not found in DLL!");
+ struct {
+ const char* name;
+ ptr& place;
+ } list[] = {
+ { "SimConnect_Open", (ptr&)simconnect_open },
+ { "SimConnect_CameraSetRelative6DOF", (ptr&)simconnect_set6DOF },
+ { "SimConnect_Close", (ptr&)simconnect_close },
+ { "SimConnect_CallDispatch", (ptr&)simconnect_calldispatch },
+ { "SimConnect_SubscribeToSystemEvent", (ptr&)simconnect_subscribetosystemevent },
+ };
- simconnect_subscribetosystemevent = (importSimConnect_SubscribeToSystemEvent) SCClientLib.resolve("SimConnect_SubscribeToSystemEvent");
- if (!simconnect_subscribetosystemevent)
- return error("SubscribeToSystemEvent function not found in DLL!");
+ for (auto& x : list)
+ {
+ x.place = (ptr)library.resolve(x.name);
+ if (!x.place)
+ return error(tr("can't import %1: %2").arg(x.name, library.errorString()));
+ }
start();
- return status_ok();
+ return {};
}
-void simconnect::handle()
+void simconnect::handler()
{
- (void) simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY);
+ (void) simconnect_set6DOF(handle, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY);
}
void CALLBACK simconnect::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD, void *self_)
@@ -203,16 +208,21 @@ void CALLBACK simconnect::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWO
break;
case SIMCONNECT_RECV_ID_EXCEPTION:
qDebug() << "simconnect: got exception";
- //self.reconnect = true;
+ self.reconnect = true;
break;
case SIMCONNECT_RECV_ID_QUIT:
qDebug() << "simconnect: got quit event";
self.reconnect = true;
break;
case SIMCONNECT_RECV_ID_EVENT_FRAME:
- self.handle();
+ self.handler();
break;
}
}
-OPENTRACK_DECLARE_PROTOCOL(simconnect, SCControls, simconnectDll)
+QString simconnect::game_name()
+{
+ return tr("FS2004/FSX");
+}
+
+OPENTRACK_DECLARE_PROTOCOL(simconnect, simconnect_ui, simconnect_metadata)
diff --git a/proto-simconnect/ftnoir_protocol_sc.h b/proto-simconnect/ftnoir_protocol_sc.h
index 03f27917..aec43e57 100644
--- a/proto-simconnect/ftnoir_protocol_sc.h
+++ b/proto-simconnect/ftnoir_protocol_sc.h
@@ -42,26 +42,24 @@ public:
~simconnect() override;
module_status initialize() override;
void pose(const double* headpose) override;
- void handle();
- QString game_name() override
- {
- return tr("FS2004/FSX");
- }
+ QString game_name() override;
+ void run() override;
+
private:
+ void handler();
+
enum {
SIMCONNECT_RECV_ID_EXCEPTION = 2,
SIMCONNECT_RECV_ID_QUIT = 3,
SIMCONNECT_RECV_ID_EVENT_FRAME = 7,
};
- #pragma pack(push, 1)
struct SIMCONNECT_RECV
{
DWORD dwSize;
DWORD dwVersion;
DWORD dwID;
};
- #pragma pack(pop)
typedef void (CALLBACK *DispatchProc)(SIMCONNECT_RECV*, DWORD, void*);
@@ -71,8 +69,6 @@ private:
typedef HRESULT (WINAPI *importSimConnect_CallDispatch)(HANDLE hSimConnect, DispatchProc pfcnDispatch, void * pContext);
typedef HRESULT (WINAPI *importSimConnect_SubscribeToSystemEvent)(HANDLE hSimConnect, DWORD EventID, const char * SystemEventName);
- void run() override;
-
std::atomic<float> virtSCPosX {0};
std::atomic<float> virtSCPosY {0};
std::atomic<float> virtSCPosZ {0};
@@ -80,35 +76,37 @@ private:
std::atomic<float> virtSCRotY {0};
std::atomic<float> virtSCRotZ {0};
- importSimConnect_Open simconnect_open;
- importSimConnect_Close simconnect_close;
- importSimConnect_CameraSetRelative6DOF simconnect_set6DOF;
- importSimConnect_CallDispatch simconnect_calldispatch;
- importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent;
+ importSimConnect_Open simconnect_open = nullptr;
+ importSimConnect_Close simconnect_close = nullptr;
+ importSimConnect_CameraSetRelative6DOF simconnect_set6DOF = nullptr;
+ importSimConnect_CallDispatch simconnect_calldispatch = nullptr;
+ importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent = nullptr;
- HANDLE hSimConnect = nullptr;
+ HANDLE handle = nullptr;
std::atomic<bool> reconnect = false;
static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext);
settings s;
- QLibrary SCClientLib;
+ QLibrary library;
};
-class SCControls: public IProtocolDialog
+class simconnect_ui: public IProtocolDialog
{
Q_OBJECT
+
+ Ui::UICSCControls ui;
+ settings s;
+
public:
- SCControls();
+ simconnect_ui();
void register_protocol(IProtocol *) override {}
void unregister_protocol() override {}
-private:
- Ui::UICSCControls ui;
- settings s;
+
private slots:
void doOK();
void doCancel();
};
-class simconnectDll : public Metadata
+class simconnect_metadata : public Metadata
{
Q_OBJECT
diff --git a/proto-simconnect/ftnoir_protocol_sc_dialog.cpp b/proto-simconnect/ftnoir_protocol_sc_dialog.cpp
index a14c6b44..c329e75d 100644
--- a/proto-simconnect/ftnoir_protocol_sc_dialog.cpp
+++ b/proto-simconnect/ftnoir_protocol_sc_dialog.cpp
@@ -12,23 +12,23 @@
#include <QDebug>
#include "api/plugin-api.hpp"
-SCControls::SCControls()
+simconnect_ui::simconnect_ui()
{
- ui.setupUi( this );
+ ui.setupUi(this);
- // Connect Qt signals to member-functions
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
tie_setting(s.sxs_manifest, ui.comboBox);
}
-void SCControls::doOK() {
+void simconnect_ui::doOK()
+{
s.b->save();
close();
}
-void SCControls::doCancel()
+void simconnect_ui::doCancel()
{
close();
}
diff --git a/proto-simconnect/ftnoir_sccontrols.ui b/proto-simconnect/ftnoir_sccontrols.ui
index 6439550f..c272d5da 100644
--- a/proto-simconnect/ftnoir_sccontrols.ui
+++ b/proto-simconnect/ftnoir_sccontrols.ui
@@ -53,22 +53,22 @@
</property>
<item>
<property name="text">
- <string>RTM</string>
+ <string>Prepar3d / SP2 XPACK</string>
</property>
</item>
<item>
<property name="text">
- <string>SP1</string>
+ <string>RTM</string>
</property>
</item>
<item>
<property name="text">
- <string>SP2 -- Acceleration</string>
+ <string>SP1</string>
</property>
</item>
<item>
<property name="text">
- <string>Prepar3d SP2 XPACK</string>
+ <string>SP2 -- Acceleration</string>
</property>
</item>
<item>
@@ -78,7 +78,7 @@
</item>
<item>
<property name="text">
- <string>Steam FSX (new)</string>
+ <string>Steam FSX (newer)</string>
</property>
</item>
</widget>
diff --git a/proto-simconnect/lang/nl_NL.ts b/proto-simconnect/lang/nl_NL.ts
index 56e2b22c..8841c3ae 100644
--- a/proto-simconnect/lang/nl_NL.ts
+++ b/proto-simconnect/lang/nl_NL.ts
@@ -24,39 +24,43 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Prepar3d SP2 XPACK</source>
+ <source>Steam FSX (older)</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Steam FSX (older)</source>
+ <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>
<message>
- <source>Steam FSX (new)</source>
+ <source>Prepar3d / SP2 XPACK</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>
+ <source>Steam FSX (newer)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>simconnect</name>
<message>
- <source>dll load failed -- %1</source>
+ <source>FS2004/FSX</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>can&apos;t load SDK -- check selected simconnect version</source>
+ <source>dll load failed: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>FS2004/FSX</source>
+ <source>install FSX SDK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>can&apos;t import %1: %2</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
- <name>simconnectDll</name>
+ <name>simconnect_metadata</name>
<message>
<source>Microsoft FSX SimConnect</source>
<translation type="unfinished"></translation>
diff --git a/proto-simconnect/lang/ru_RU.ts b/proto-simconnect/lang/ru_RU.ts
index f5bc8428..9a9c7c46 100644
--- a/proto-simconnect/lang/ru_RU.ts
+++ b/proto-simconnect/lang/ru_RU.ts
@@ -24,39 +24,43 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Prepar3d SP2 XPACK</source>
+ <source>Steam FSX (older)</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Steam FSX (older)</source>
+ <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>
<message>
- <source>Steam FSX (new)</source>
+ <source>Prepar3d / SP2 XPACK</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>
+ <source>Steam FSX (newer)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>simconnect</name>
<message>
- <source>dll load failed -- %1</source>
+ <source>FS2004/FSX</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>can&apos;t load SDK -- check selected simconnect version</source>
+ <source>dll load failed: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>FS2004/FSX</source>
+ <source>install FSX SDK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>can&apos;t import %1: %2</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
- <name>simconnectDll</name>
+ <name>simconnect_metadata</name>
<message>
<source>Microsoft FSX SimConnect</source>
<translation type="unfinished"></translation>
diff --git a/proto-simconnect/lang/stub.ts b/proto-simconnect/lang/stub.ts
index 5dd8d4d6..a221cf39 100644
--- a/proto-simconnect/lang/stub.ts
+++ b/proto-simconnect/lang/stub.ts
@@ -24,39 +24,43 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Prepar3d SP2 XPACK</source>
+ <source>Steam FSX (older)</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Steam FSX (older)</source>
+ <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>
<message>
- <source>Steam FSX (new)</source>
+ <source>Prepar3d / SP2 XPACK</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>
+ <source>Steam FSX (newer)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>simconnect</name>
<message>
- <source>dll load failed -- %1</source>
+ <source>FS2004/FSX</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>can&apos;t load SDK -- check selected simconnect version</source>
+ <source>dll load failed: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>FS2004/FSX</source>
+ <source>install FSX SDK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>can&apos;t import %1: %2</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
- <name>simconnectDll</name>
+ <name>simconnect_metadata</name>
<message>
<source>Microsoft FSX SimConnect</source>
<translation type="unfinished"></translation>
diff --git a/proto-simconnect/lang/zh_CN.ts b/proto-simconnect/lang/zh_CN.ts
index 5dd8d4d6..a221cf39 100644
--- a/proto-simconnect/lang/zh_CN.ts
+++ b/proto-simconnect/lang/zh_CN.ts
@@ -24,39 +24,43 @@
<translation type="unfinished"></translation>
</message>
<message>
- <source>Prepar3d SP2 XPACK</source>
+ <source>Steam FSX (older)</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Steam FSX (older)</source>
+ <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>
<message>
- <source>Steam FSX (new)</source>
+ <source>Prepar3d / SP2 XPACK</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>
+ <source>Steam FSX (newer)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>simconnect</name>
<message>
- <source>dll load failed -- %1</source>
+ <source>FS2004/FSX</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>can&apos;t load SDK -- check selected simconnect version</source>
+ <source>dll load failed: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>FS2004/FSX</source>
+ <source>install FSX SDK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>can&apos;t import %1: %2</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
- <name>simconnectDll</name>
+ <name>simconnect_metadata</name>
<message>
<source>Microsoft FSX SimConnect</source>
<translation type="unfinished"></translation>