From 16c527ee66123ed29ca2d6c0c6baae6e113eda40 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Fri, 1 Feb 2013 12:38:35 +0000 Subject: Updated to FreeTrack 2.0 git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@258 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp | 29 +++++++++++++---------- FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h | 4 ++++ 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'FTNoIR_Protocol_FSUIPC') diff --git a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp index 09911866..5a4663a1 100644 --- a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp +++ b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp @@ -3,7 +3,7 @@ * gamers from Holland, who don't like to pay much for * * head-tracking. * * * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Copyright (C) 2010-2013 Wim Vriend (Developing) * * Ron Hendriks (Researching and Testing) * * * * Homepage * @@ -38,6 +38,9 @@ FTNoIR_Protocol::FTNoIR_Protocol() loadSettings(); ProgramName = "Microsoft FS2004"; + blnConnectionActive = false; + hMainWindow = NULL; + prevPosX = 0.0f; prevPosY = 0.0f; prevPosZ = 0.0f; @@ -118,6 +121,8 @@ float virtRotX; float virtRotY; float virtRotZ; +PDWORD_PTR MsgResult = 0; + // qDebug() << "FSUIPCServer::run() says: started!"; virtRotX = -1.0f * headpose->pitch; // degrees @@ -173,6 +178,14 @@ float virtRotZ; if (result == FSUIPC_ERR_SENDMSG) { FSUIPC_Close(); //timeout (1 second) so assume FS closed } + + if (!blnConnectionActive) { + blnConnectionActive = true; + if (hMainWindow != NULL) { + SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult); + } + } + } } @@ -191,17 +204,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) { qDebug() << "checkServerInstallationOK says: Starting Function"; - // - // Load the DLL. - // - //FSUIPCLib.setFileName( LocationOfDLL ); - //if (FSUIPCLib.load() != true) { - // qDebug() << "checkServerInstallationOK says: Error loading FSUIPC DLL"; - // return false; - //} - //else { - // qDebug() << "checkServerInstallationOK says: FSUIPC DLL loaded."; - //} + hMainWindow = handle; return true; } @@ -211,7 +214,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) // void FTNoIR_Protocol::getNameFromGame( char *dest ) { - sprintf_s(dest, 99, "FS2002/2004"); + sprintf_s(dest, 99, "Microsoft FS2002/2004"); return; } diff --git a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h index ec99035b..8503f6e7 100644 --- a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h +++ b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h @@ -43,6 +43,7 @@ #include static const char* FSUIPC_FILENAME = "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll"; +static const char* FT_PROGRAMID = "FT_ProgramID"; // For message to FaceTrackNoIR main-window. // // Define the structures necessary for the FSUIPC_Write calls @@ -75,6 +76,9 @@ private: QString LocationOfDLL; float prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; + bool blnConnectionActive; + HANDLE hMainWindow; // Save the handle to FaceTrackNoIR main-window + static int scale2AnalogLimits( float x, float min_x, float max_x ); void loadSettings(); }; -- cgit v1.2.3