summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-09-22 15:25:19 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-09-24 19:33:34 +0200
commit6310488fda7a85b0f330e4ca6c7781873fe5b582 (patch)
treeff72c7be5d65469aa80015ff3b6202482dbee7be /ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
parentb236bf6a23172a5008d0e715c913e44fb69d5e31 (diff)
fix Wine bitrot rather than only saying so
name mangling has issues so partial revert
Diffstat (limited to 'ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx')
-rw-r--r--ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx75
1 files changed, 50 insertions, 25 deletions
diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
index fe5a95f9..40f36f8d 100644
--- a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
+++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
@@ -10,33 +10,57 @@
#include "compat/compat.h"
void create_registry_key(void);
-ptr<BasePortableLockedShm> make_shm_posix();
-ptr<BasePortableLockedShm> make_shm_win32();
+
+class ShmPosix {
+public:
+ ShmPosix(const char *shmName, const char *mutexName, int mapSize);
+ ~ShmPosix();
+ void lock();
+ void unlock();
+ bool success();
+ inline void* ptr() { return mem; }
+private:
+ void* mem;
+ int fd, size;
+};
+
+class ShmWine {
+public:
+ ShmWine(const char *shmName, const char *mutexName, int mapSize);
+ ~ShmWine();
+ void lock();
+ void unlock();
+ bool success();
+ inline void* ptr() { return mem; }
+private:
+ void* mem;
+ void *hMutex, *hMapFile;
+};
+#include <windows.h>
int main(void)
{
- 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();
+ ShmPosix lck_posix(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM));
+ ShmWine lck_wine("FT_SharedMem", "FT_Mutext", sizeof(FTHeap));
+ 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(4);
- lck_posix->lock();
- if (shm_posix->stop) {
- lck_posix->unlock();
- break;
- }
- lck_wine->lock();
+ while (1) {
+ 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];
@@ -50,7 +74,8 @@ 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();
+ (void) Sleep(4);
+ }
}