diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-09-22 15:25:19 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-09-22 15:25:19 +0200 |
commit | 69236c0317a30bf100ec4f3d0f8e58fdc565a34b (patch) | |
tree | 0e754b9454982efb0b3b9ac40ed769543d87f159 /ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx | |
parent | d3d17ad9b662aca4327b7b63ba1824eb14d7874b (diff) |
fix Wine proto bitrot
Diffstat (limited to 'ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx')
-rw-r--r-- | ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx | 84 |
1 files changed, 33 insertions, 51 deletions
diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx index 6e512b6e..fe5a95f9 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx @@ -1,60 +1,42 @@ -#include <errno.h> -#include <stdio.h> +#include <cerrno> +#include <cstdio> #include "ftnoir_protocol_ft/fttypes.h" #include "ftnoir_protocol_wine/wine-shm.h" -#include "ftnoir_tracker_base/ftnoir_tracker_types.h" -void create_registry_key(void); +#define OPENTRACK_CROSS_ONLY +#include "facetracknoir/plugin-api.hpp" -class ShmPosix { -public: - ShmPosix(const char *shmName, const char *mutexName, int mapSize); - ~ShmPosix(); - void lock(); - void unlock(); - bool success(); - void* mem; -private: - int fd, size; -}; +#define OPENTRACK_COMPAT_BUNDLED +#include "compat/compat.h" -class ShmWine { -public: - ShmWine(const char *shmName, const char *mutexName, int mapSize); - ~ShmWine(); - void lock(); - void unlock(); - bool success(); - void* mem; -private: - void *hMutex, *hMapFile; -}; -#include <windows.h> +void create_registry_key(void); +ptr<BasePortableLockedShm> make_shm_posix(); +ptr<BasePortableLockedShm> make_shm_win32(); 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.success()) { - printf("Can't open posix map: %d\n", errno); - return 1; - } - if(!lck_wine.success()) { - 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; + ptr<BasePortableLockedShm> lck_posix = make_shm_posix(); + ptr<BasePortableLockedShm> lck_wine = make_shm_win32(); + if(!lck_posix->success()) { + printf("Can't open posix map: %d\n", errno); + return 1; + } + if(!lck_wine->success()) { + printf("Can't open Wine map\n"); + return 1; + } + WineSHM* shm_posix = (WineSHM*) lck_posix->ptr(); + FTHeap* shm_wine = (FTHeap*) lck_wine->ptr(); + FTData* data = &shm_wine->data; create_registry_key(); - while (1) { - (void) Sleep(10); - lck_posix.lock(); - if (shm_posix->stop) { - lck_posix.unlock(); - break; - } - lck_wine.lock(); + while (1) { + (void) Sleep(4); + lck_posix->lock(); + if (shm_posix->stop) { + lck_posix->unlock(); + break; + } + lck_wine->lock(); data->Yaw = shm_posix->data[Yaw]; data->Pitch = shm_posix->data[Pitch]; data->Roll = shm_posix->data[Roll]; @@ -68,7 +50,7 @@ int main(void) 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(); - } + lck_wine->unlock(); + lck_posix->unlock(); + } } |