blob: 4132062f4fc6aecf289cb1c3449ba3a9c58e83de (
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
|
#include <errno.h>
#include <stdio.h>
#include "ftnoir_protocol_wine/fttypes.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 (!shm_posix->stop) {
(void) Sleep(10);
lck_posix.lock();
if (shm_posix->stop) {
lck_posix.unlock();
break;
}
lck_wine.lock();
data->Yaw = shm_posix->rx;
data->Pitch = shm_posix->ry;
data->Roll = shm_posix->rz;
data->X = shm_posix->tx;
data->Y = shm_posix->ty;
data->Z = shm_posix->tz;
data->DataID = 1;
data->CamWidth = 250;
data->CamHeight = 100;
lck_wine.unlock();
lck_posix.unlock();
}
}
|