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-23 21:31:16 +0200
commitfadd2f3475aed347d2a06a08cc9c2e7fe53fbba9 (patch)
tree22ffefd82e1ff810ec89a26340a3a2d37a4c1f7c /ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
parent9b3c04d1187ceeb83e7e1eead0714fd4578d07d7 (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);
+ }
}