diff options
Diffstat (limited to 'ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx')
-rw-r--r-- | ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx new file mode 100644 index 00000000..9d8914bd --- /dev/null +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx @@ -0,0 +1,68 @@ +#include <errno.h> +#include <stdio.h> +#include "ftnoir_protocol_ft/fttypes.h" +#include "ftnoir_protocol_wine/wine-shm.h" +#include "ftnoir_tracker_base/ftnoir_tracker_types.h" +class ShmPosix { +public: + ShmPosix(const char *shmName, const char *mutexName, int mapSize); + ~ShmPosix(); + void lock(); + void unlock(); + void* mem; +private: + int fd, size; +}; + +class ShmWine { +public: + ShmWine(const char *shmName, const char *mutexName, int mapSize); + ~ShmWine(); + void lock(); + void unlock(); + void* mem; +private: + void *hMutex, *hMapFile; +}; +#include <windows.h> + +int main(void) +{ + ShmPosix lck_posix(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)); + ShmWine lck_wine("FT_SharedMem", "FT_Mutext", sizeof(FTMemMap)); + if(lck_posix.mem == (void*)-1) { + printf("Can't open posix map: %d\n", errno); + return 1; + } + if(lck_wine.mem == NULL) { + printf("Can't open Wine map\n"); + return 1; + } + WineSHM* shm_posix = (WineSHM*) lck_posix.mem; + FTMemMap* shm_wine = (FTMemMap*) lck_wine.mem; + TFreeTrackData* data = &shm_wine->data; + while (1) { + (void) Sleep(10); + lck_posix.lock(); + if (shm_posix->stop) { + lck_posix.unlock(); + break; + } + lck_wine.lock(); + data->Yaw = shm_posix->data[RX]; + data->Pitch = shm_posix->data[RY]; + data->Roll = shm_posix->data[RZ]; + data->X = shm_posix->data[TX]; + data->Y = shm_posix->data[TY]; + data->Z = shm_posix->data[TZ]; + data->DataID = 1; + data->CamWidth = 250; + data->CamHeight = 100; + shm_wine->GameID2 = shm_posix->gameid2; + shm_posix->gameid = shm_wine->GameID; + for (int i = 0; i < 8; i++) + shm_wine->table[i] = shm_posix->table[i]; + lck_wine.unlock(); + lck_posix.unlock(); + } +} |