blob: d5d030113fbd4f45171fa402d1a1ab344a3ce85d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#include <cerrno>
#include <cstdio>
#include "freetrackclient/fttypes.h"
#include "ftnoir_protocol_wine/wine-shm.h"
#define OPENTRACK_CROSS_ONLY
#include "../opentrack/plugin-api.hpp"
#define OPENTRACK_COMPAT_BUNDLED
#include "compat/compat.h"
void create_registry_key(void);
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)
{
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) {
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];
data->X = shm_posix->data[TX];
data->Y = shm_posix->data[TY];
data->Z = shm_posix->data[TZ];
data->DataID++;
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();
(void) Sleep(4);
}
}
|