summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ftnoir_protocol_sc/ftnoir_protocol_sc.cpp12
-rw-r--r--ftnoir_protocol_sc/ftnoir_protocol_sc.h2
2 files changed, 10 insertions, 4 deletions
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
index 41fcf1b0..8e35248e 100644
--- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
+++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
@@ -31,7 +31,7 @@
static QLibrary SCClientLib;
-FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr)
+FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr), should_start(false)
{
start();
}
@@ -40,13 +40,13 @@ FTNoIR_Protocol::~FTNoIR_Protocol()
{
should_stop = true;
wait();
-
- if (hSimConnect)
- (void) simconnect_close(hSimConnect);
}
void FTNoIR_Protocol::run()
{
+ if (!should_start)
+ return;
+
if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) {
simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame");
@@ -62,6 +62,8 @@ void FTNoIR_Protocol::run()
(void) (simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast<void*>(this)));
Sleep(3);
}
+
+ (void) simconnect_close(hSimConnect);
}
void FTNoIR_Protocol::pose( const double *headpose ) {
@@ -182,6 +184,8 @@ bool FTNoIR_Protocol::correct()
}
qDebug() << "FTNoIR_Protocol::correct() says: SimConnect functions resolved in DLL!";
+
+ should_start = true;
return true;
}
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h
index b65bac85..3ced16e5 100644
--- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h
+++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h
@@ -126,6 +126,8 @@ private:
HANDLE hSimConnect; // Handle to SimConnect
static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext);
settings s;
+
+ bool should_start;
};
class SCControls: public IProtocolDialog