diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2013-04-02 18:41:01 +0200 | 
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-04-02 18:41:01 +0200 | 
| commit | 8303597a865400a363ae574ccde819302495f498 (patch) | |
| tree | c83b383b3ec818f610cc6137f2b72ee7b4173b09 /ftnoir_protocol_sc | |
| parent | 8adf6b1650af6027f28db12ca2b4de92a3fac11d (diff) | |
Just put everything new in. Conflict resolution will be later
Diffstat (limited to 'ftnoir_protocol_sc')
| -rw-r--r-- | ftnoir_protocol_sc/ftnoir-protocol-sc.rc | 2 | ||||
| -rw-r--r-- | ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 92 | ||||
| -rw-r--r-- | ftnoir_protocol_sc/ftnoir_protocol_sc.h | 20 | ||||
| -rw-r--r-- | ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 7 | ||||
| -rw-r--r-- | ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp | 3 | ||||
| -rw-r--r-- | ftnoir_protocol_sc/ftnoir_sccontrols.ui | 2 | ||||
| -rw-r--r-- | ftnoir_protocol_sc/images/fsx.ico | bin | 0 -> 87910 bytes | 
7 files changed, 51 insertions, 75 deletions
diff --git a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc new file mode 100644 index 00000000..3838d941 --- /dev/null +++ b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc @@ -0,0 +1,2 @@ +#include "winuser.h" +2 RT_MANIFEST scserver.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 index 7ca38e64..c01096bf 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -33,6 +33,7 @@  					is called from run() of Tracker.cpp
  */
  #include "ftnoir_protocol_sc.h"
 +#include "facetracknoir/global-settings.h"
  importSimConnect_CameraSetRelative6DOF FTNoIR_Protocol::simconnect_set6DOF;
  HANDLE FTNoIR_Protocol::hSimConnect = 0;			// Handle to SimConnect
 @@ -59,7 +60,6 @@ FTNoIR_Protocol::FTNoIR_Protocol()  	ProgramName = "Microsoft FSX";
  	blnSimConnectActive = false;
  	hSimConnect = 0;
 -	hMainWindow = 0;
  }
  /** destructor **/
 @@ -76,17 +76,6 @@ FTNoIR_Protocol::~FTNoIR_Protocol()  //	SCClientLib.unload(); Generates crash when tracker is ended...
  }
 -/** helper to Auto-destruct **/
 -void FTNoIR_Protocol::Release()
 -{
 -    delete this;
 -}
 -
 -void FTNoIR_Protocol::Initialize()
 -{
 -	return;
 -}
 -
  //
  // Load the current Settings from the currently 'active' INI-file.
  //
 @@ -101,7 +90,7 @@ void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData  PDWORD_PTR MsgResult = 0;
 -	virtSCRotX = -1.0f * headpose->pitch;					// degrees
 +    virtSCRotX = -1.0f * headpose->pitch;					// degrees
  	virtSCRotY = -1.0f * headpose->yaw;
  	virtSCRotZ = headpose->roll;
 @@ -113,25 +102,22 @@ PDWORD_PTR MsgResult = 0;  	// It's only useful to send data, if the connection was made.
  	//
  	if (!blnSimConnectActive) {
 -		if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) {
 -			qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: SimConnect active!";
 +        if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) {
 +            qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: SimConnect active!";
 -			//set up the events we want to listen for
 -			HRESULT hr;
 +            //set up the events we want to listen for
 +            HRESULT hr;
 -			simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); 
 +            simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame");
 -			hr = simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, "");
 -			hr = simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false);
 -			hr = simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST);
 -			////hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "VK_COMMA", EVENT_INIT);
 -			////hr = SimConnect_SetInputGroupState(hSimConnect, INPUT0, SIMCONNECT_STATE_ON);
 +            hr = simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, "");
 +            hr = simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false);
 +            hr = simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST);
 +            ////hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "VK_COMMA", EVENT_INIT);
 +            ////hr = SimConnect_SetInputGroupState(hSimConnect, INPUT0, SIMCONNECT_STATE_ON);
 -			blnSimConnectActive = true;
 -			if (hMainWindow != NULL) {
 -				SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult);
 -			}
 -		}
 +            blnSimConnectActive = true;
 +        }
  	}
  	else {
  		//
 @@ -165,33 +151,29 @@ PDWORD_PTR MsgResult = 0;  //
  // Returns 'true' if all seems OK.
  //
 -bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle )
 +bool FTNoIR_Protocol::checkServerInstallationOK()
  {   
  	QString aFileName;														// File Path and Name
  	// Code to activate the context for the SimConnect DLL
 -	ACTCTX act = { 0 };
 +    ACTCTX act = { 0 };
  	HANDLE hctx;
  	ULONG_PTR ulCookie;
 -	hMainWindow = handle;
 -
  	qDebug() << "SCCheckClientDLL says: Starting Function";
  	try {
 -
 +#if 0
  		act.cbSize = sizeof(act);
  		act.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID;
 +        char full_path[2048];
 +        strcpy(full_path, QCoreApplication::applicationDirPath().toLatin1().constData());
 +        strcat(full_path, "\\libftnoir-proto-simconnect.dll");
 -		QString manifest(QCoreApplication::applicationDirPath());
 -//		manifest += "\\FaceTrackNoIR.exe";
 -		manifest += "\\FTNoIR_Protocol_SC.dll";
 -		const wchar_t * encodedName = reinterpret_cast<const wchar_t *>(manifest.utf16());
 -		
 -		act.lpSource = encodedName;
 -		act.lpResourceName = MAKEINTRESOURCE(101);
 +        act.lpSource = full_path;
 +        act.lpResourceName = MAKEINTRESOURCEA(101);
 -		hctx = CreateActCtx (&act);
 +        hctx = CreateActCtxA (&act);
  		if (hctx != INVALID_HANDLE_VALUE) { 
  			if (!ActivateActCtx(hctx, &ulCookie)) { 
 @@ -203,32 +185,26 @@ bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle )  			qDebug() << "SCCheckClientDLL says: Error INVALID_HANDLE: " << GetLastError();
  			return false;
  		}
 -
  		//
  		// Just try to load the DLL. Let Windows handle the PATH's and such trivialities...
  		//
 -		aFileName = SC_CLIENT_FILENAME;
 -						
 -		//
 -		// Load the DLL.
 -		//
 -		SCClientLib.setFileName(aFileName);
 -		if (SCClientLib.load() != true) {
 -			qDebug() << "SCCheckClientDLL says: Error loading SimConnect DLL";
 -			return false;
 -		}
 -
  		//
  		// Deactivate the context again: the function-references should stay in-tact...
  		//
  		DeactivateActCtx(0, ulCookie);
  		ReleaseActCtx(hctx);
 -
 +#endif
  	} catch(...) {
  		qDebug() << "SCCheckClientDLL says: Error loading SimConnect DLL";
  		return false;
  	}
 +    SCClientLib.setFileName(SC_CLIENT_FILENAME);
 +    if (SCClientLib.load() != true) {
 +        qDebug() << "SCCheckClientDLL says: Error loading SimConnect DLL";
 +        return false;
 +    }
 +
  	//
  	// Get the functions from the DLL.
  	//
 @@ -374,7 +350,7 @@ void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData  //
  void FTNoIR_Protocol::getNameFromGame( char *dest )
  {   
 -	sprintf_s(dest, 99, "Microsoft FSX");
 +    sprintf(dest, "Microsoft FSX");
  	return;
  }
 @@ -385,9 +361,9 @@ void FTNoIR_Protocol::getNameFromGame( char *dest )  //   GetProtocol     - Undecorated name, which can be easily used with GetProcAddress
  //                Win32 API function.
  //   _GetProtocol@0  - Common name decoration for __stdcall functions in C language.
 -#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0")
 +//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0")
 -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol()
 +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT void* CALLING_CONVENTION GetConstructor()
  {
 -	return new FTNoIR_Protocol;
 +    return (IProtocol*) new FTNoIR_Protocol;
  }
 diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index 42eca457..57919193 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -29,6 +29,7 @@  #pragma once
  #ifndef INCLUDED_SCSERVER_H
  #define INCLUDED_SCSERVER_H
 +#include "facetracknoir/global-settings.h"
  //
  // Prevent the SimConnect manifest from being merged in the application-manifest
 @@ -59,8 +60,7 @@ typedef HRESULT (WINAPI *importSimConnect_MapClientEventToSimEvent)(HANDLE hSimC  typedef HRESULT (WINAPI *importSimConnect_AddClientEventToNotificationGroup)(HANDLE hSimConnect, SIMCONNECT_NOTIFICATION_GROUP_ID GroupID, SIMCONNECT_CLIENT_EVENT_ID EventID, BOOL bMaskable);
  typedef HRESULT (WINAPI *importSimConnect_SetNotificationGroupPriority)(HANDLE hSimConnect, SIMCONNECT_NOTIFICATION_GROUP_ID GroupID, DWORD uPriority);
 -static const char* SC_CLIENT_FILENAME = "SimConnect.dll";
 -static const char* FT_PROGRAMID = "FT_ProgramID";				// For message to FaceTrackNoIR main-window.
 +#define SC_CLIENT_FILENAME "SimConnect.dll"
  enum GROUP_ID
  {
 @@ -83,11 +83,8 @@ class FTNoIR_Protocol : public IProtocol  public:
  	FTNoIR_Protocol();
  	~FTNoIR_Protocol();
 -
 -	void Release();
 -    void Initialize();
 -
 -	bool checkServerInstallationOK( HANDLE handle );
 +    void Initialize() {}
 +    bool checkServerInstallationOK();
  	void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose );
  	void getNameFromGame( char *dest );					// Take care dest can handle up to 100 chars...
 @@ -112,10 +109,9 @@ private:  	static float prevSCRotY;
  	static float prevSCRotZ;
 -	bool blnSimConnectActive;
 -	HANDLE hMainWindow;												// Save the handle to FaceTrackNoIR main-window
 +    bool blnSimConnectActive;
 -	importSimConnect_Open simconnect_open;							// SimConnect function(s) in DLL
 +    importSimConnect_Open simconnect_open;							// SimConnect function(s) in DLL
  	importSimConnect_Close simconnect_close;
  	static importSimConnect_CameraSetRelative6DOF simconnect_set6DOF;
  	importSimConnect_CallDispatch simconnect_calldispatch;
 @@ -166,7 +162,7 @@ private slots:  //*******************************************************************************************************
  // FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol
  //*******************************************************************************************************
 -class FTNoIR_ProtocolDll : public IProtocolDll
 +class FTNoIR_ProtocolDll : public Metadata
  {
  public:
  	FTNoIR_ProtocolDll();
 @@ -176,7 +172,7 @@ public:  	void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); };
  	void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); };
 -	void getIcon(QIcon *icon) { *icon = QIcon(":/images/FSX.ico"); };
 +    void getIcon(QIcon *icon) { *icon = QIcon(":/images/fsx.png"); };
  };
  #endif//INCLUDED_SCSERVER_H
 diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp index 9047fa61..32abf64a 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp @@ -30,8 +30,9 @@  						The ProtocolDll class solves this.
  						The functions to get the name(s) and icon were removed from the two other classes.
  */
 -#include "ftnoir_protocol_SC.h"
 +#include "ftnoir_protocol_sc.h"
  #include <QDebug>
 +#include "facetracknoir/global-settings.h"
  //*******************************************************************************************************
  // FaceTrackNoIR Client Settings-dialog.
 @@ -151,7 +152,7 @@ void SCControls::save() {  //   _GetProtocolDialog@0  - Common name decoration for __stdcall functions in C language.
  #pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0")
 -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( )
 +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT void* CALLING_CONVENTION GetDialog( )
  {
 -	return new SCControls;
 +    return (IProtocolDialog*) new SCControls;
  }
 diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp index f67f95db..3d59ef48 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp @@ -32,6 +32,7 @@  */
  #include "ftnoir_protocol_SC.h"
  #include <QDebug>
 +#include "facetracknoir/global-settings.h"
  FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() {
  }
 @@ -50,7 +51,7 @@ FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll()  //   _GetProtocolDll@0  - Common name decoration for __stdcall functions in C language.
  #pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0")
 -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll()
 +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
  {
  	return new FTNoIR_ProtocolDll;
  }
 diff --git a/ftnoir_protocol_sc/ftnoir_sccontrols.ui b/ftnoir_protocol_sc/ftnoir_sccontrols.ui index 3e7a5062..a0cbf393 100644 --- a/ftnoir_protocol_sc/ftnoir_sccontrols.ui +++ b/ftnoir_protocol_sc/ftnoir_sccontrols.ui @@ -15,7 +15,7 @@    </property>
    <property name="windowIcon">
     <iconset>
 -    <normaloff>images/FaceTrackNoIR.ico</normaloff>images/FaceTrackNoIR.ico</iconset>
 +    <normaloff>images/FaceTrackNoIR.png</normaloff>images/FaceTrackNoIR.png</iconset>
    </property>
    <property name="layoutDirection">
     <enum>Qt::LeftToRight</enum>
 diff --git a/ftnoir_protocol_sc/images/fsx.ico b/ftnoir_protocol_sc/images/fsx.ico Binary files differnew file mode 100644 index 00000000..1c71d409 --- /dev/null +++ b/ftnoir_protocol_sc/images/fsx.ico  | 
