From 4f05cb2af239ca8471b77c9f1d1c32e8c4cd3abc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Mar 2013 21:48:28 +0100 Subject: Remove .bat files, actually finish rename this time --- freetrackclient/FreeTrackClient/postbuild.bat | 15 -- .../freetrackclient/freetrackclient.cpp | 294 +++++++++++++++++++++ freetrackclient/freetrackclient/freetrackclient.rc | 103 ++++++++ freetrackclient/freetrackclient/postbuild.bat | 15 -- .../freetrackclient/xxx_freetrackclient.cpp | 294 --------------------- .../freetrackclient/xxx_freetrackclient.rc | 103 -------- freetrackclient/ftclient.cpp | 119 +++++++++ freetrackclient/ftclient.h | 30 +++ freetrackclient/xxx_ftclient.cpp | 119 --------- freetrackclient/xxx_ftclient.h | 30 --- 10 files changed, 546 insertions(+), 576 deletions(-) delete mode 100644 freetrackclient/FreeTrackClient/postbuild.bat create mode 100644 freetrackclient/freetrackclient/freetrackclient.cpp create mode 100644 freetrackclient/freetrackclient/freetrackclient.rc delete mode 100644 freetrackclient/freetrackclient/postbuild.bat delete mode 100644 freetrackclient/freetrackclient/xxx_freetrackclient.cpp delete mode 100644 freetrackclient/freetrackclient/xxx_freetrackclient.rc create mode 100644 freetrackclient/ftclient.cpp create mode 100644 freetrackclient/ftclient.h delete mode 100644 freetrackclient/xxx_ftclient.cpp delete mode 100644 freetrackclient/xxx_ftclient.h (limited to 'freetrackclient') diff --git a/freetrackclient/FreeTrackClient/postbuild.bat b/freetrackclient/FreeTrackClient/postbuild.bat deleted file mode 100644 index 87c192d1..00000000 --- a/freetrackclient/FreeTrackClient/postbuild.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off -rem Copies required DLL files into output folder. - -setlocal -set COPY=xcopy /D /S /C /I /H /R /Y -set FILTER=find /v "File(s) copied" - -echo parameters %1 en %2 - -set API_BIN=%1 -set FTN_BIN=%2 - -%COPY% %API_BIN%\*.dll %FTN_BIN%\ | %FILTER% -exit /b 0 - diff --git a/freetrackclient/freetrackclient/freetrackclient.cpp b/freetrackclient/freetrackclient/freetrackclient.cpp new file mode 100644 index 00000000..ac6148e8 --- /dev/null +++ b/freetrackclient/freetrackclient/freetrackclient.cpp @@ -0,0 +1,294 @@ +/******************************************************************************** +* FreeTrackClientDll Implements the FreeTrack 2.0 interface for FT-enabled * +* games. * +* It uses the FreeTrack protocol (memory mapping) to * +* receive data from FaceTrackNoIR (or FreeTrack, or ...). * +* * +* Copyright (C) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Testing and Research) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + + 20130208 - WVR: The old DLL from FreeTrack seems to crash ArmA2. And we need 64-bit support. + +*/ + +#ifdef WIN64 +#pragma comment(linker, "/export:FTGetData") +#pragma comment(linker, "/export:FTReportName") +#pragma comment(linker, "/export:FTGetDllVersion") +#pragma comment(linker, "/export:FTProvider") +#endif + +#ifdef WIN64 +# define FT_DECLSPEC __declspec(dllexport) +#else +# define FT_DECLSPEC +#endif + +#define FT_EXPORT(t) extern "C" t FT_DECLSPEC __stdcall +#define NP_AXIS_MAX 16383 + +#include +#include +#include +#include +#include +#include + +#include "..\..\FTNOIR_PROTOCOL_FT\FTTypes.h" + +// +// Functions to create/open the file-mapping +// and to destroy it again. +// +bool FTCreateMapping(); +void FTDestroyMapping(); +float scale2AnalogLimits( float x, float min_x, float max_x ); +float getDegreesFromRads ( float rads ); + +#if 1 +static FILE *debug_stream = fopen("c:\\FreeTrackClient.log", "a"); +#define dbg_report(...) if (debug_stream) { fprintf(debug_stream, __VA_ARGS__); fflush(debug_stream); } +#else +#define dbg_report(...) +#endif + +// +// Handles to 'handle' the memory mapping +// +static HANDLE hFTMemMap = 0; +static FTMemMap *pMemData = 0; +static HANDLE hFTMutex = 0; +static char* dllVersion = "1.0.0.0"; +static char* dllProvider = "FreeTrack"; + +static unsigned short gameid = 0; + +// +// DllMain gets called, when the DLL is (un)loaded or a process attaches. +// +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + switch (fdwReason) { + case DLL_PROCESS_ATTACH: +#ifdef WIN64 + dbg_report("\n= WIN64 =========================================================================================\n"); +#else + dbg_report("\n= WIN32 =========================================================================================\n"); +#endif + dbg_report("DllMain: (0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); + dbg_report("DllMain: Attach request\n"); + DisableThreadLibraryCalls(hinstDLL); + break; + + case DLL_PROCESS_DETACH: + dbg_report("DllMain: Detach\n"); + dbg_report("DllMain: (0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); + dbg_report("==========================================================================================\n"); + break; + } + return TRUE; +} + +/****************************************************************** + * FTGetData (FreeTrackClient.1) + */ +#pragma comment(linker, "/export:FTGetData@4=FTGetData") +FT_EXPORT(bool) FTGetData(PFreetrackData data) +{ + static int frame = 0; + static int prevDataID = 0; + static int dlyTrackingOff = 0; + static int tracking = 0; + +// dbg_report("NP_GetData called."); + if (FTCreateMapping() == false) return false; + + if (hFTMutex && WaitForSingleObject(hFTMutex, 5) == WAIT_OBJECT_0) { + if (pMemData) { + + // + // When FaceTrackNoIR does not update frames (any more), don't update the data. + // + if (prevDataID != pMemData->data.DataID) { + memcpy(data, &pMemData->data, sizeof(TFreeTrackData)); + dlyTrackingOff = 0; + } + else { + dlyTrackingOff++; + if (dlyTrackingOff > 20) { + dlyTrackingOff = 100; + tracking = false; + } + } + prevDataID = pMemData->data.DataID; + + // + // Limit the range of DataID + // + if (pMemData->data.DataID > 1000) { + pMemData->data.DataID = 0; + } + data->DataID = pMemData->data.DataID; + + // + // Send the ID to FaceTrackNoIR, so it can display the game-name. + // This could be a FreeTrack-specific ID + // + sprintf_s(pMemData->GameID, 19, "%d", gameid ); + + } + ReleaseMutex(hFTMutex); + } + return true; +} + +/****************************************************************** + * FTReportName (FreeTrackClient.2) + */ +#pragma comment(linker, "/export:FTReportName@4=FTReportName") +// +// For some mysterious reason, the previously existing function FTReportID has been changed to FTReportName, but with an integer as argument. +// The Delphi-code from the FreeTrack repo suggest a char * as argument, so it cost me an afternoon to figure it out (and keep ArmA2 from crashing). +// Thanks guys! +// +FT_EXPORT(void) FTReportName( int name ) +{ + dbg_report("FTReportName request (ID = %d).\n", name); + gameid = name; // They might have really passed the name here... but they didn't! + return; +} + +/****************************************************************** + * FTGetDllVersion (FreeTrackClient.3) + */ +#pragma comment(linker, "/export:FTGetDllVersion@0=FTGetDllVersion") +extern "C" __declspec( dllexport ) char* FTGetDllVersion(void) +{ + dbg_report("FTGetDllVersion request.\n"); + + return dllVersion; +} + +/****************************************************************** + * FTProvider (FreeTrackClient.4) + */ +#pragma comment(linker, "/export:FTProvider@0=FTProvider") +extern "C" __declspec( dllexport ) char* FTProvider(void) +{ + dbg_report("FTProvider request.\n"); + + return dllProvider; +} + +// +// Create a memory-mapping to the Freetrack data. +// It contains the tracking data, a handle to the main-window and the program-name of the Game! +// +// +bool FTCreateMapping() +{ + bool bMappingExists = false; + PDWORD_PTR MsgResult = 0; + + // + // Memory-mapping already exists! + // + if ( pMemData != NULL ) { + return true; + } + + dbg_report("FTCreateMapping request (pMemData == NULL).\n"); + + // + // A FileMapping is used to create 'shared memory' between the FTClient and the FTServer. + // + // Try to create a FileMapping to the Shared Memory. This is done to check if it's already there (what + // may mean the face-tracker program is already running). + // + // If one already exists: close it and open the file-mapping to the existing one. + // + hFTMemMap = CreateFileMappingA( INVALID_HANDLE_VALUE , 00 , PAGE_READWRITE , 0 , + sizeof( FTMemMap ), + (LPCSTR) FT_MM_DATA ); + + if ( ( hFTMemMap != 0 ) && ( GetLastError() == ERROR_ALREADY_EXISTS ) ) { + dbg_report("FTCreateMapping: Mapping already exists.\n"); + bMappingExists = true; // So the server was (probably) already started! + CloseHandle( hFTMemMap ); + hFTMemMap = 0; + } + + // + // Create a new FileMapping, Read/Write access + // + hFTMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) FT_MM_DATA ); + if ( ( hFTMemMap != 0 ) ) { + dbg_report("FTCreateMapping: Mapping opened.\n"); + pMemData = (FTMemMap *) MapViewOfFile(hFTMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof( FTMemMap ) ); + hFTMutex = CreateMutexA(NULL, false, FREETRACK_MUTEX); + } + else { + return false; + } + return true; +} + +// +// Destory the FileMapping to the shared memory +// +void FTDestroyMapping() +{ + if ( pMemData != NULL ) { + UnmapViewOfFile ( pMemData ); + } + + CloseHandle( hFTMutex ); + CloseHandle( hFTMemMap ); + pMemData = 0; + hFTMemMap = 0; +} + +// +// 4 convenience +// +float getDegreesFromRads ( float rads ) { + return (rads * 57.295781f); +} + +// +// Scale the measured value to the TIR values +// +float scale2AnalogLimits( float x, float min_x, float max_x ) { +double y; +double local_x; + + local_x = x; + if (local_x > max_x) { + local_x = max_x; + } + if (local_x < min_x) { + local_x = min_x; + } + y = ( NP_AXIS_MAX * local_x ) / max_x; + + return (float) y; +} diff --git a/freetrackclient/freetrackclient/freetrackclient.rc b/freetrackclient/freetrackclient/freetrackclient.rc new file mode 100644 index 00000000..046eef1b --- /dev/null +++ b/freetrackclient/freetrackclient/freetrackclient.rc @@ -0,0 +1,103 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Dutch (Netherlands) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLD) +#ifdef _WIN32 +LANGUAGE LANG_DUTCH, SUBLANG_DUTCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "041304b0" + BEGIN + VALUE "Comments", "FreeTrack interface for FaceTrackNoIR." + VALUE "CompanyName", "FaceTrackNoIR Team" + VALUE "FileDescription", "64-bit interface for FreeTrack-enables games." + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "FreeTrackClient" + VALUE "LegalCopyright", "Copyright (C) 2013, FaceTrackNoIR Team" + VALUE "OriginalFilename", "FreeTrackClient64.dll" + VALUE "ProductName", "Interface DLL for FreeTrack 2.0" + VALUE "ProductVersion", "1, 0, 0, 1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x413, 1200 + END +END + +#endif // Dutch (Netherlands) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/freetrackclient/freetrackclient/postbuild.bat b/freetrackclient/freetrackclient/postbuild.bat deleted file mode 100644 index 185fc705..00000000 --- a/freetrackclient/freetrackclient/postbuild.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off -rem Copies required DLL files into output folder. - -setlocal -set COPY=xcopy /D /S /C /I /H /R /Y -set FILTER=find /v "File(s) copied" - -echo parameters %1 en %2 - -set API_BIN=%1 -set FTN_BIN=%2 - -%COPY% %API_BIN%\*.dll %FTN_BIN%\ | %FILTER% -exit /b 0 - diff --git a/freetrackclient/freetrackclient/xxx_freetrackclient.cpp b/freetrackclient/freetrackclient/xxx_freetrackclient.cpp deleted file mode 100644 index ac6148e8..00000000 --- a/freetrackclient/freetrackclient/xxx_freetrackclient.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************** -* FreeTrackClientDll Implements the FreeTrack 2.0 interface for FT-enabled * -* games. * -* It uses the FreeTrack protocol (memory mapping) to * -* receive data from FaceTrackNoIR (or FreeTrack, or ...). * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Testing and Research) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - - 20130208 - WVR: The old DLL from FreeTrack seems to crash ArmA2. And we need 64-bit support. - -*/ - -#ifdef WIN64 -#pragma comment(linker, "/export:FTGetData") -#pragma comment(linker, "/export:FTReportName") -#pragma comment(linker, "/export:FTGetDllVersion") -#pragma comment(linker, "/export:FTProvider") -#endif - -#ifdef WIN64 -# define FT_DECLSPEC __declspec(dllexport) -#else -# define FT_DECLSPEC -#endif - -#define FT_EXPORT(t) extern "C" t FT_DECLSPEC __stdcall -#define NP_AXIS_MAX 16383 - -#include -#include -#include -#include -#include -#include - -#include "..\..\FTNOIR_PROTOCOL_FT\FTTypes.h" - -// -// Functions to create/open the file-mapping -// and to destroy it again. -// -bool FTCreateMapping(); -void FTDestroyMapping(); -float scale2AnalogLimits( float x, float min_x, float max_x ); -float getDegreesFromRads ( float rads ); - -#if 1 -static FILE *debug_stream = fopen("c:\\FreeTrackClient.log", "a"); -#define dbg_report(...) if (debug_stream) { fprintf(debug_stream, __VA_ARGS__); fflush(debug_stream); } -#else -#define dbg_report(...) -#endif - -// -// Handles to 'handle' the memory mapping -// -static HANDLE hFTMemMap = 0; -static FTMemMap *pMemData = 0; -static HANDLE hFTMutex = 0; -static char* dllVersion = "1.0.0.0"; -static char* dllProvider = "FreeTrack"; - -static unsigned short gameid = 0; - -// -// DllMain gets called, when the DLL is (un)loaded or a process attaches. -// -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - switch (fdwReason) { - case DLL_PROCESS_ATTACH: -#ifdef WIN64 - dbg_report("\n= WIN64 =========================================================================================\n"); -#else - dbg_report("\n= WIN32 =========================================================================================\n"); -#endif - dbg_report("DllMain: (0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); - dbg_report("DllMain: Attach request\n"); - DisableThreadLibraryCalls(hinstDLL); - break; - - case DLL_PROCESS_DETACH: - dbg_report("DllMain: Detach\n"); - dbg_report("DllMain: (0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); - dbg_report("==========================================================================================\n"); - break; - } - return TRUE; -} - -/****************************************************************** - * FTGetData (FreeTrackClient.1) - */ -#pragma comment(linker, "/export:FTGetData@4=FTGetData") -FT_EXPORT(bool) FTGetData(PFreetrackData data) -{ - static int frame = 0; - static int prevDataID = 0; - static int dlyTrackingOff = 0; - static int tracking = 0; - -// dbg_report("NP_GetData called."); - if (FTCreateMapping() == false) return false; - - if (hFTMutex && WaitForSingleObject(hFTMutex, 5) == WAIT_OBJECT_0) { - if (pMemData) { - - // - // When FaceTrackNoIR does not update frames (any more), don't update the data. - // - if (prevDataID != pMemData->data.DataID) { - memcpy(data, &pMemData->data, sizeof(TFreeTrackData)); - dlyTrackingOff = 0; - } - else { - dlyTrackingOff++; - if (dlyTrackingOff > 20) { - dlyTrackingOff = 100; - tracking = false; - } - } - prevDataID = pMemData->data.DataID; - - // - // Limit the range of DataID - // - if (pMemData->data.DataID > 1000) { - pMemData->data.DataID = 0; - } - data->DataID = pMemData->data.DataID; - - // - // Send the ID to FaceTrackNoIR, so it can display the game-name. - // This could be a FreeTrack-specific ID - // - sprintf_s(pMemData->GameID, 19, "%d", gameid ); - - } - ReleaseMutex(hFTMutex); - } - return true; -} - -/****************************************************************** - * FTReportName (FreeTrackClient.2) - */ -#pragma comment(linker, "/export:FTReportName@4=FTReportName") -// -// For some mysterious reason, the previously existing function FTReportID has been changed to FTReportName, but with an integer as argument. -// The Delphi-code from the FreeTrack repo suggest a char * as argument, so it cost me an afternoon to figure it out (and keep ArmA2 from crashing). -// Thanks guys! -// -FT_EXPORT(void) FTReportName( int name ) -{ - dbg_report("FTReportName request (ID = %d).\n", name); - gameid = name; // They might have really passed the name here... but they didn't! - return; -} - -/****************************************************************** - * FTGetDllVersion (FreeTrackClient.3) - */ -#pragma comment(linker, "/export:FTGetDllVersion@0=FTGetDllVersion") -extern "C" __declspec( dllexport ) char* FTGetDllVersion(void) -{ - dbg_report("FTGetDllVersion request.\n"); - - return dllVersion; -} - -/****************************************************************** - * FTProvider (FreeTrackClient.4) - */ -#pragma comment(linker, "/export:FTProvider@0=FTProvider") -extern "C" __declspec( dllexport ) char* FTProvider(void) -{ - dbg_report("FTProvider request.\n"); - - return dllProvider; -} - -// -// Create a memory-mapping to the Freetrack data. -// It contains the tracking data, a handle to the main-window and the program-name of the Game! -// -// -bool FTCreateMapping() -{ - bool bMappingExists = false; - PDWORD_PTR MsgResult = 0; - - // - // Memory-mapping already exists! - // - if ( pMemData != NULL ) { - return true; - } - - dbg_report("FTCreateMapping request (pMemData == NULL).\n"); - - // - // A FileMapping is used to create 'shared memory' between the FTClient and the FTServer. - // - // Try to create a FileMapping to the Shared Memory. This is done to check if it's already there (what - // may mean the face-tracker program is already running). - // - // If one already exists: close it and open the file-mapping to the existing one. - // - hFTMemMap = CreateFileMappingA( INVALID_HANDLE_VALUE , 00 , PAGE_READWRITE , 0 , - sizeof( FTMemMap ), - (LPCSTR) FT_MM_DATA ); - - if ( ( hFTMemMap != 0 ) && ( GetLastError() == ERROR_ALREADY_EXISTS ) ) { - dbg_report("FTCreateMapping: Mapping already exists.\n"); - bMappingExists = true; // So the server was (probably) already started! - CloseHandle( hFTMemMap ); - hFTMemMap = 0; - } - - // - // Create a new FileMapping, Read/Write access - // - hFTMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) FT_MM_DATA ); - if ( ( hFTMemMap != 0 ) ) { - dbg_report("FTCreateMapping: Mapping opened.\n"); - pMemData = (FTMemMap *) MapViewOfFile(hFTMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof( FTMemMap ) ); - hFTMutex = CreateMutexA(NULL, false, FREETRACK_MUTEX); - } - else { - return false; - } - return true; -} - -// -// Destory the FileMapping to the shared memory -// -void FTDestroyMapping() -{ - if ( pMemData != NULL ) { - UnmapViewOfFile ( pMemData ); - } - - CloseHandle( hFTMutex ); - CloseHandle( hFTMemMap ); - pMemData = 0; - hFTMemMap = 0; -} - -// -// 4 convenience -// -float getDegreesFromRads ( float rads ) { - return (rads * 57.295781f); -} - -// -// Scale the measured value to the TIR values -// -float scale2AnalogLimits( float x, float min_x, float max_x ) { -double y; -double local_x; - - local_x = x; - if (local_x > max_x) { - local_x = max_x; - } - if (local_x < min_x) { - local_x = min_x; - } - y = ( NP_AXIS_MAX * local_x ) / max_x; - - return (float) y; -} diff --git a/freetrackclient/freetrackclient/xxx_freetrackclient.rc b/freetrackclient/freetrackclient/xxx_freetrackclient.rc deleted file mode 100644 index 046eef1b..00000000 --- a/freetrackclient/freetrackclient/xxx_freetrackclient.rc +++ /dev/null @@ -1,103 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Dutch (Netherlands) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLD) -#ifdef _WIN32 -LANGUAGE LANG_DUTCH, SUBLANG_DUTCH -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "041304b0" - BEGIN - VALUE "Comments", "FreeTrack interface for FaceTrackNoIR." - VALUE "CompanyName", "FaceTrackNoIR Team" - VALUE "FileDescription", "64-bit interface for FreeTrack-enables games." - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "FreeTrackClient" - VALUE "LegalCopyright", "Copyright (C) 2013, FaceTrackNoIR Team" - VALUE "OriginalFilename", "FreeTrackClient64.dll" - VALUE "ProductName", "Interface DLL for FreeTrack 2.0" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x413, 1200 - END -END - -#endif // Dutch (Netherlands) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/freetrackclient/ftclient.cpp b/freetrackclient/ftclient.cpp new file mode 100644 index 00000000..d48a2c28 --- /dev/null +++ b/freetrackclient/ftclient.cpp @@ -0,0 +1,119 @@ +/** @file + @brief +*/ +#include "FTClient.h" + + + + + static double/*?*/ const FT_PROGRAMID = "FT_ProgramID"; + + + HANDLE hFTMemMap; + PFreetrackData FTData; + unsigned long lastDataID; + PHandle FTHandle; + PAnsiChar FTProgramName; + HANDLE FTMutex; + + +bool FTGetData(PFreetrackData data) +{ bool result; + result = false; + if( !! FTData ) { + if( FTData->DataID != lastDataID ) { + Move( FTData/*?*/^ , data/*?*/^ , SizeOf( TFreetrackData ) ); + lastDataID = FTData->DataID; + result = true; + } + } else + OpenMapping; +return result; +} + + +void FTReportName(PAnsiChar name) +{ + unsigned long MsgResult; + + if( OpenMapping && ( WaitForSingleObject( FTMutex , 100 ) == WAIT_OBJECT_0 ) ) { + Move( name/*?*/^ , FTProgramName/*?*/^ , 100 ); + SendMessageTimeout( FTHandle/*?*/^ , RegisterWindowMessage( FT_PROGRAMID ) , 0 , 0 , 0 , 2000 , MsgResult ); + ReleaseMutex( FTMutex ); + } +} + + +char* FTGetDllVersion() +{ char* result; + unsigned long VerInfoSize; + Pointer VerInfo; + unsigned long VerValueSize; + PVSFixedFileInfo VerValue; + unsigned long Dummy; + std::string verString; + char* dllName[100]; + + result = ""; + GetModuleFilename( HInstance , &dllName , 100 ); + VerInfoSize = GetFileVersionInfoSize( &dllName , Dummy ); + if( !( VerInfoSize == 0 ) ) { + GetMem( VerInfo , VerInfoSize ); + GetFileVersionInfo( &dllName , 0 , VerInfoSize , VerInfo ); + VerQueryValue( VerInfo , "\\" , Pointer( VerValue ) , VerValueSize ); + /*?*//* WITH VerValue/*?*/^ */ + { + verString = IntToStr( dwFileVersionMS >> 16 ); + verString = verString + "." + IntToStr( dwFileVersionMS && 0xFFFF ); + verString = verString + "." + IntToStr( dwFileVersionLS >> 16 ); + verString = verString + "." + IntToStr( dwFileVersionLS && 0xFFFF ); + result = char*( verString ); + } + FreeMem( VerInfo , VerInfoSize ); + } +return result; +} + + +char* FTProvider() +{ char* result; + result = FREETRACK;return result; +} + + + + + +bool OpenMapping() +{ bool result; + if( hFTMemMap != 0 ) + result = true;else { + hFTMemMap = OpenFileMapping( FILE_MAP_ALL_ACCESS , false , FT_MM_DATA ); + if( ( hFTMemMap != 0 ) ) { + FTData = MapViewOfFile( hFTMemMap , FILE_MAP_ALL_ACCESS , 0 , 0 , SizeOf( TFreetrackData ) + SizeOf( HANDLE ) + 100 ); + FTHandle = Pointer( unsigned long( FTData ) + SizeOf( TFreetrackData ) ); + FTProgramName = Pointer( unsigned long( FTHandle ) + SizeOf( HANDLE ) ); + FTMutex = OpenMutex( MUTEX_ALL_ACCESS , false , FREETRACK_MUTEX ); + } + result = !! FTData; + } +return result; +} + + +void DestroyMapping() +{ + if( FTData != 00 ) { + UnMapViewofFile( FTData ); + FTData = 00; + } + + CloseHandle( FTMutex ); + CloseHandle( hFTMemMap ); + hFTMemMap = 0; +} + + + + +//END diff --git a/freetrackclient/ftclient.h b/freetrackclient/ftclient.h new file mode 100644 index 00000000..406e1237 --- /dev/null +++ b/freetrackclient/ftclient.h @@ -0,0 +1,30 @@ +/** @file + @brief +*/ +#pragma once +#ifndef INCLUDED_FTCLIENT_H +#define INCLUDED_FTCLIENT_H + + + + + + +#include "Windows.h" +#include "SysUtils.h" +#include "FTTypes.h" + +/*__stdcall*/ bool FTGetData(PFreetrackData data); +/*__stdcall*/ void FTReportName(PAnsiChar name); +/*__stdcall*/ char* FTGetDllVersion(); +/*__stdcall*/ char* FTProvider(); + + +bool OpenMapping(); +void DestroyMapping(); + + + + +#endif//INCLUDED_FTCLIENT_H +//END diff --git a/freetrackclient/xxx_ftclient.cpp b/freetrackclient/xxx_ftclient.cpp deleted file mode 100644 index d48a2c28..00000000 --- a/freetrackclient/xxx_ftclient.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/** @file - @brief -*/ -#include "FTClient.h" - - - - - static double/*?*/ const FT_PROGRAMID = "FT_ProgramID"; - - - HANDLE hFTMemMap; - PFreetrackData FTData; - unsigned long lastDataID; - PHandle FTHandle; - PAnsiChar FTProgramName; - HANDLE FTMutex; - - -bool FTGetData(PFreetrackData data) -{ bool result; - result = false; - if( !! FTData ) { - if( FTData->DataID != lastDataID ) { - Move( FTData/*?*/^ , data/*?*/^ , SizeOf( TFreetrackData ) ); - lastDataID = FTData->DataID; - result = true; - } - } else - OpenMapping; -return result; -} - - -void FTReportName(PAnsiChar name) -{ - unsigned long MsgResult; - - if( OpenMapping && ( WaitForSingleObject( FTMutex , 100 ) == WAIT_OBJECT_0 ) ) { - Move( name/*?*/^ , FTProgramName/*?*/^ , 100 ); - SendMessageTimeout( FTHandle/*?*/^ , RegisterWindowMessage( FT_PROGRAMID ) , 0 , 0 , 0 , 2000 , MsgResult ); - ReleaseMutex( FTMutex ); - } -} - - -char* FTGetDllVersion() -{ char* result; - unsigned long VerInfoSize; - Pointer VerInfo; - unsigned long VerValueSize; - PVSFixedFileInfo VerValue; - unsigned long Dummy; - std::string verString; - char* dllName[100]; - - result = ""; - GetModuleFilename( HInstance , &dllName , 100 ); - VerInfoSize = GetFileVersionInfoSize( &dllName , Dummy ); - if( !( VerInfoSize == 0 ) ) { - GetMem( VerInfo , VerInfoSize ); - GetFileVersionInfo( &dllName , 0 , VerInfoSize , VerInfo ); - VerQueryValue( VerInfo , "\\" , Pointer( VerValue ) , VerValueSize ); - /*?*//* WITH VerValue/*?*/^ */ - { - verString = IntToStr( dwFileVersionMS >> 16 ); - verString = verString + "." + IntToStr( dwFileVersionMS && 0xFFFF ); - verString = verString + "." + IntToStr( dwFileVersionLS >> 16 ); - verString = verString + "." + IntToStr( dwFileVersionLS && 0xFFFF ); - result = char*( verString ); - } - FreeMem( VerInfo , VerInfoSize ); - } -return result; -} - - -char* FTProvider() -{ char* result; - result = FREETRACK;return result; -} - - - - - -bool OpenMapping() -{ bool result; - if( hFTMemMap != 0 ) - result = true;else { - hFTMemMap = OpenFileMapping( FILE_MAP_ALL_ACCESS , false , FT_MM_DATA ); - if( ( hFTMemMap != 0 ) ) { - FTData = MapViewOfFile( hFTMemMap , FILE_MAP_ALL_ACCESS , 0 , 0 , SizeOf( TFreetrackData ) + SizeOf( HANDLE ) + 100 ); - FTHandle = Pointer( unsigned long( FTData ) + SizeOf( TFreetrackData ) ); - FTProgramName = Pointer( unsigned long( FTHandle ) + SizeOf( HANDLE ) ); - FTMutex = OpenMutex( MUTEX_ALL_ACCESS , false , FREETRACK_MUTEX ); - } - result = !! FTData; - } -return result; -} - - -void DestroyMapping() -{ - if( FTData != 00 ) { - UnMapViewofFile( FTData ); - FTData = 00; - } - - CloseHandle( FTMutex ); - CloseHandle( hFTMemMap ); - hFTMemMap = 0; -} - - - - -//END diff --git a/freetrackclient/xxx_ftclient.h b/freetrackclient/xxx_ftclient.h deleted file mode 100644 index 406e1237..00000000 --- a/freetrackclient/xxx_ftclient.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - @brief -*/ -#pragma once -#ifndef INCLUDED_FTCLIENT_H -#define INCLUDED_FTCLIENT_H - - - - - - -#include "Windows.h" -#include "SysUtils.h" -#include "FTTypes.h" - -/*__stdcall*/ bool FTGetData(PFreetrackData data); -/*__stdcall*/ void FTReportName(PAnsiChar name); -/*__stdcall*/ char* FTGetDllVersion(); -/*__stdcall*/ char* FTProvider(); - - -bool OpenMapping(); -void DestroyMapping(); - - - - -#endif//INCLUDED_FTCLIENT_H -//END -- cgit v1.2.3