From aa066bdd4622d4f6824fee864f6be6806813f04d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 07:37:41 +0100 Subject: move to subdirectory-based build system Closes #224 --- ftnoir_protocol_sc/ftnoir-protocol-sc.rc | 4 - ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 189 ---------------------- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 108 ------------- ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 35 ---- ftnoir_protocol_sc/ftnoir_sccontrols.ui | 72 --------- ftnoir_protocol_sc/images/fsx.png | Bin 813 -> 0 bytes ftnoir_protocol_sc/images/fsx1.png | Bin 1920 -> 0 bytes ftnoir_protocol_sc/sc-protocol.qrc | 5 - ftnoir_protocol_sc/scserver.manifest | 13 -- ftnoir_protocol_sc/scserver_acceleration.manifest | 13 -- ftnoir_protocol_sc/scserver_sp2.manifest | 13 -- 11 files changed, 452 deletions(-) delete mode 100644 ftnoir_protocol_sc/ftnoir-protocol-sc.rc delete mode 100644 ftnoir_protocol_sc/ftnoir_protocol_sc.cpp delete mode 100644 ftnoir_protocol_sc/ftnoir_protocol_sc.h delete mode 100644 ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp delete mode 100644 ftnoir_protocol_sc/ftnoir_sccontrols.ui delete mode 100644 ftnoir_protocol_sc/images/fsx.png delete mode 100644 ftnoir_protocol_sc/images/fsx1.png delete mode 100644 ftnoir_protocol_sc/sc-protocol.qrc delete mode 100644 ftnoir_protocol_sc/scserver.manifest delete mode 100644 ftnoir_protocol_sc/scserver_acceleration.manifest delete mode 100644 ftnoir_protocol_sc/scserver_sp2.manifest (limited to 'ftnoir_protocol_sc') diff --git a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc deleted file mode 100644 index c89eb9a7..00000000 --- a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc +++ /dev/null @@ -1,4 +0,0 @@ -#include -142 RT_MANIFEST scserver.manifest -143 RT_MANIFEST scserver_sp2.manifest -144 RT_MANIFEST scserver_acceleration.manifest \ No newline at end of file diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp deleted file mode 100644 index 0c6cb486..00000000 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend - * Copyright (c) 2014, Stanislaw Halik - * * - * Permission to use, copy, modify, and/or distribute this software for any * - * purpose with or without fee is hereby granted, provided that the above * - * copyright notice and this permission notice appear in all copies. * - */ -#include "ftnoir_protocol_sc.h" -#include "opentrack/plugin-api.hpp" - -FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr) -{ -} - -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - should_stop = true; - wait(); -} - -void FTNoIR_Protocol::run() -{ - HANDLE event = CreateEvent(NULL, FALSE, FALSE, nullptr); - - if (event == nullptr) - { - qDebug() << "simconnect: event create" << GetLastError(); - return; - } - - while (!should_stop) - { - if (SUCCEEDED(simconnect_open(&hSimConnect, "opentrack", NULL, 0, event, 0))) - { - simconnect_subscribetosystemevent(hSimConnect, 0, "Frame"); - - while (!should_stop) - { - if (WaitForSingleObject(event, 10) == WAIT_OBJECT_0) - { - if (FAILED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast(this)))) - break; - } - } - - (void) simconnect_close(hSimConnect); - } - - if (!should_stop) - Sleep(100); - } - - CloseHandle(event); -} - -void FTNoIR_Protocol::pose( const double *headpose ) { - virtSCRotX = -headpose[Pitch]; // degrees - virtSCRotY = headpose[Yaw]; - virtSCRotZ = headpose[Roll]; - - virtSCPosX = headpose[TX]/100.f; // cm to meters - virtSCPosY = headpose[TY]/100.f; - virtSCPosZ = -headpose[TZ]/100.f; -} - -#ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#endif - -class ActivationContext { -public: - ActivationContext(const int resid) : ok(false) { - hactctx = INVALID_HANDLE_VALUE; - actctx_cookie = 0; - ACTCTXA actx = {0}; - actx.cbSize = sizeof(ACTCTXA); - actx.lpResourceName = MAKEINTRESOURCEA(resid); - actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; -#ifdef _MSC_VER -# define PREFIX "" -#else -# define PREFIX "lib" -#endif - QString path = QCoreApplication::applicationDirPath() + "/" PREFIX "opentrack-proto-simconnect.dll"; - QByteArray name = QFile::encodeName(path); - actx.lpSource = name.constData(); - hactctx = CreateActCtxA(&actx); - actctx_cookie = 0; - if (hactctx != INVALID_HANDLE_VALUE) { - if (!ActivateActCtx(hactctx, &actctx_cookie)) { - qDebug() << "SC: can't set win32 activation context" << GetLastError(); - ReleaseActCtx(hactctx); - hactctx = INVALID_HANDLE_VALUE; - } - else - ok = true; - } else { - qDebug() << "SC: can't create win32 activation context" << GetLastError(); - } - } - ~ActivationContext() { - if (hactctx != INVALID_HANDLE_VALUE) - { - DeactivateActCtx(0, actctx_cookie); - ReleaseActCtx(hactctx); - } - } - bool is_ok() { return ok; } -private: - ULONG_PTR actctx_cookie; - HANDLE hactctx; - bool ok; -}; - -bool FTNoIR_Protocol::correct() -{ - if (!SCClientLib.isLoaded()) - { - ActivationContext ctx(142 + static_cast(s.sxs_manifest)); - - if (ctx.is_ok()) - { - SCClientLib.setFileName("SimConnect.dll"); - if (!SCClientLib.load()) { - qDebug() << "SC load" << SCClientLib.errorString(); - return false; - } - } - else - return false; - } - - simconnect_open = (importSimConnect_Open) SCClientLib.resolve("SimConnect_Open"); - if (simconnect_open == NULL) { - qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_Open function not found in DLL!"; - return false; - } - simconnect_set6DOF = (importSimConnect_CameraSetRelative6DOF) SCClientLib.resolve("SimConnect_CameraSetRelative6DOF"); - if (simconnect_set6DOF == NULL) { - qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_CameraSetRelative6DOF function not found in DLL!"; - return false; - } - simconnect_close = (importSimConnect_Close) SCClientLib.resolve("SimConnect_Close"); - if (simconnect_close == NULL) { - qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_Close function not found in DLL!"; - return false; - } - - simconnect_calldispatch = (importSimConnect_CallDispatch) SCClientLib.resolve("SimConnect_CallDispatch"); - if (simconnect_calldispatch == NULL) { - qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_CallDispatch function not found in DLL!"; - return false; - } - - simconnect_subscribetosystemevent = (importSimConnect_SubscribeToSystemEvent) SCClientLib.resolve("SimConnect_SubscribeToSystemEvent"); - if (simconnect_subscribetosystemevent == NULL) { - qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_SubscribeToSystemEvent function not found in DLL!"; - return false; - } - - start(); - - return true; -} - -void FTNoIR_Protocol::handle() -{ - (void) simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY); -} - -void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD, void *self_) -{ - FTNoIR_Protocol& self = *reinterpret_cast(self_); - - switch(pData->dwID) - { - default: - break; - case SIMCONNECT_RECV_ID_EVENT_FRAME: - self.handle(); - break; - } -} - -OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, SCControls, FTNoIR_ProtocolDll) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h deleted file mode 100644 index 671a3500..00000000 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ /dev/null @@ -1,108 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * Copyright (c) 2014, Stanislaw Halik * - * * - * Permission to use, copy, modify, and/or distribute this software for any * - * purpose with or without fee is hereby granted, provided that the above * - * copyright notice and this permission notice appear in all copies. * - */ -#pragma once -#include "opentrack/plugin-api.hpp" - -#include "ui_ftnoir_sccontrols.h" -#include -#include -#include -#include -#include -#include -#include -#include "opentrack/options.hpp" -using namespace options; -#include - -struct settings : opts { - value sxs_manifest; - settings() : - opts("proto-simconnect"), - sxs_manifest(b, "sxs-manifest-version", 0) - {} -}; - -class FTNoIR_Protocol : public IProtocol, private QThread -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol() override; - bool correct(); - void pose(const double* headpose); - void handle(); - QString game_name() { - return "FS2004/FSX"; - } -private: - enum { 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*); - - typedef HRESULT (WINAPI *importSimConnect_Open)(HANDLE * phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex); - typedef HRESULT (WINAPI *importSimConnect_Close)(HANDLE hSimConnect); - typedef HRESULT (WINAPI *importSimConnect_CameraSetRelative6DOF)(HANDLE hSimConnect, float fDeltaX, float fDeltaY, float fDeltaZ, float fPitchDeg, float fBankDeg, float fHeadingDeg); - 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; - volatile bool should_stop; - - volatile float virtSCPosX; - volatile float virtSCPosY; - volatile float virtSCPosZ; - volatile float virtSCRotX; - volatile float virtSCRotY; - volatile float virtSCRotZ; - - importSimConnect_Open simconnect_open; - importSimConnect_Close simconnect_close; - importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; - importSimConnect_CallDispatch simconnect_calldispatch; - importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent; - - HANDLE hSimConnect; - static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); - settings s; - QLibrary SCClientLib; -}; - -class SCControls: public IProtocolDialog -{ - Q_OBJECT -public: - SCControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} -private: - Ui::UICSCControls ui; - settings s; -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_ProtocolDll : public Metadata -{ -public: - QString name() { return QString("Microsoft FSX SimConnect"); } - QIcon icon() { return QIcon(":/images/fsx.png"); } -}; diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp deleted file mode 100644 index 7c2ecfd4..00000000 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * Permission to use, copy, modify, and/or distribute this software for any * - * purpose with or without fee is hereby granted, provided that the above * - * copyright notice and this permission notice appear in all copies. * - */ -#include "ftnoir_protocol_sc.h" -#include -#include "opentrack/plugin-api.hpp" - -SCControls::SCControls() -{ - 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() { - s.b->save(); - this->close(); -} - -void SCControls::doCancel() { - s.b->reload(); - close(); -} - diff --git a/ftnoir_protocol_sc/ftnoir_sccontrols.ui b/ftnoir_protocol_sc/ftnoir_sccontrols.ui deleted file mode 100644 index 5b2fd291..00000000 --- a/ftnoir_protocol_sc/ftnoir_sccontrols.ui +++ /dev/null @@ -1,72 +0,0 @@ - - - UICSCControls - - - Qt::NonModal - - - - 0 - 0 - 290 - 79 - - - - SimConnect settings FaceTrackNoIR - - - - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png - - - Qt::LeftToRight - - - false - - - - - - FSX version - - - - - - - - SP1 - - - - - SP2 - - - - - Acceleration - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/ftnoir_protocol_sc/images/fsx.png b/ftnoir_protocol_sc/images/fsx.png deleted file mode 100644 index 16b072a1..00000000 Binary files a/ftnoir_protocol_sc/images/fsx.png and /dev/null differ diff --git a/ftnoir_protocol_sc/images/fsx1.png b/ftnoir_protocol_sc/images/fsx1.png deleted file mode 100644 index a1f0f188..00000000 Binary files a/ftnoir_protocol_sc/images/fsx1.png and /dev/null differ diff --git a/ftnoir_protocol_sc/sc-protocol.qrc b/ftnoir_protocol_sc/sc-protocol.qrc deleted file mode 100644 index 127d5180..00000000 --- a/ftnoir_protocol_sc/sc-protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/fsx.png - - diff --git a/ftnoir_protocol_sc/scserver.manifest b/ftnoir_protocol_sc/scserver.manifest deleted file mode 100644 index d342cfda..00000000 --- a/ftnoir_protocol_sc/scserver.manifest +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/ftnoir_protocol_sc/scserver_acceleration.manifest b/ftnoir_protocol_sc/scserver_acceleration.manifest deleted file mode 100644 index 06459587..00000000 --- a/ftnoir_protocol_sc/scserver_acceleration.manifest +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/ftnoir_protocol_sc/scserver_sp2.manifest b/ftnoir_protocol_sc/scserver_sp2.manifest deleted file mode 100644 index 3020d16c..00000000 --- a/ftnoir_protocol_sc/scserver_sp2.manifest +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - -- cgit v1.2.3