diff options
Diffstat (limited to 'ftnoir_protocol_sc')
-rw-r--r-- | ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index c0e2fc02..5f70b093 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -41,19 +41,27 @@ FTNoIR_Protocol::~FTNoIR_Protocol() void FTNoIR_Protocol::run() { - (void) timeBeginPeriod(1); + 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, 0, 0))) + if (SUCCEEDED(simconnect_open(&hSimConnect, "opentrack", NULL, 0, event, 0))) { simconnect_subscribetosystemevent(hSimConnect, 0, "Frame"); while (!should_stop) { - if (FAILED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast<void*>(this)))) - break; - Sleep(16); + if (WaitForSingleObject(event, 10) == WAIT_OBJECT_0) + { + if (FAILED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast<void*>(this)))) + break; + } } (void) simconnect_close(hSimConnect); @@ -63,7 +71,7 @@ void FTNoIR_Protocol::run() Sleep(100); } - (void) timeEndPeriod(1); + CloseHandle(event); } void FTNoIR_Protocol::pose( const double *headpose ) { @@ -169,8 +177,6 @@ bool FTNoIR_Protocol::correct() return false; } - qDebug() << "FTNoIR_Protocol::correct() says: SimConnect functions resolved in DLL!"; - start(); return true; |