From 2bcab030f7640387e015f232df6254e1806aa586 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jul 2015 19:05:29 +0200 Subject: simconnect: allow operating after restarting fsx --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 1735305c..eb8d1a79 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -44,22 +44,24 @@ void FTNoIR_Protocol::run() { Affinity thr; - if (!SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) - return; + while (!should_stop) + { + if (SUCCEEDED(simconnect_open(&hSimConnect, "opentrack", NULL, 0, 0, 0))) + { + simconnect_subscribetosystemevent(hSimConnect, 0, "Frame"); - simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); + while (!should_stop) + { + if (FAILED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast(this)))) + break; + Sleep(1); + } - //simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, ""); - //simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false); - //simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE); + (void) simconnect_close(hSimConnect); + } - while (!should_stop) - { - (void) (simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast(this))); - Sleep(1); + Sleep(100); } - - (void) simconnect_close(hSimConnect); } void FTNoIR_Protocol::pose( const double *headpose ) { -- cgit v1.2.3