diff options
-rwxr-xr-x | bin/NPClient.dll | bin | 18944 -> 15872 bytes | |||
-rwxr-xr-x | bin/NPClient64.dll | bin | 20480 -> 19968 bytes | |||
-rw-r--r-- | csv/csv.cpp | 3 | ||||
-rw-r--r-- | freetrackclient/fttypes.h | 52 | ||||
-rw-r--r-- | ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 78 | ||||
-rw-r--r-- | ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx | 30 |
6 files changed, 83 insertions, 80 deletions
diff --git a/bin/NPClient.dll b/bin/NPClient.dll Binary files differindex 47172c22..bf971c03 100755 --- a/bin/NPClient.dll +++ b/bin/NPClient.dll diff --git a/bin/NPClient64.dll b/bin/NPClient64.dll Binary files differindex f7b30a90..fd3164e5 100755 --- a/bin/NPClient64.dll +++ b/bin/NPClient64.dll diff --git a/csv/csv.cpp b/csv/csv.cpp index 71db8ecb..e55b429c 100644 --- a/csv/csv.cpp +++ b/csv/csv.cpp @@ -97,7 +97,8 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) QString gameID = QString::number(id); /* zero table first, in case unknown game is connecting */ - memset(table, 0, 8); + for (int i = 0; i < 8; i++) + table[i] = 0; QStringList gameLine; qDebug() << "getGameData, ID = " << gameID; diff --git a/freetrackclient/fttypes.h b/freetrackclient/fttypes.h index ad974110..8611017a 100644 --- a/freetrackclient/fttypes.h +++ b/freetrackclient/fttypes.h @@ -31,39 +31,39 @@ typedef __int32 int32_t; /* only 6 headpose floats and the data id are filled -sh */ typedef struct __FTData { - int DataID; - int CamWidth; - int CamHeight; + volatile int DataID; + volatile int CamWidth; + volatile int CamHeight; /* virtual pose */ - float Yaw; /* positive yaw to the left */ - float Pitch; /* positive pitch up */ - float Roll; /* positive roll to the left */ - float X; - float Y; - float Z; + volatile float Yaw; /* positive yaw to the left */ + volatile float Pitch; /* positive pitch up */ + volatile float Roll; /* positive roll to the left */ + volatile float X; + volatile float Y; + volatile float Z; /* raw pose with no smoothing, sensitivity, response curve etc. */ - float RawYaw; - float RawPitch; - float RawRoll; - float RawX; - float RawY; - float RawZ; + volatile float RawYaw; + volatile float RawPitch; + volatile float RawRoll; + volatile float RawX; + volatile float RawY; + volatile float RawZ; /* raw points, sorted by Y, origin top left corner */ - float X1; - float Y1; - float X2; - float Y2; - float X3; - float Y3; - float X4; - float Y4; + volatile float X1; + volatile float Y1; + volatile float X2; + volatile float Y2; + volatile float X3; + volatile float Y3; + volatile float X4; + volatile float Y4; } FTData; /* we add some shit at the end for other legacy proto, sadly */ typedef struct __FTHeap { FTData data; - int32_t GameID; - unsigned char table[8]; - int32_t GameID2; + volatile int32_t GameID; + volatile unsigned char table[8]; + volatile int32_t GameID2; } FTHeap; diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 312cf127..56ae061f 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -54,44 +54,51 @@ void FTNoIR_Protocol::pose(const double* headpose) { float tx = headpose[TX] * 10.f; float ty = headpose[TY] * 10.f; float tz = headpose[TZ] * 10.f; - - shm.lock(); - - pMemData->data.RawX = 0; - pMemData->data.RawY = 0; - pMemData->data.RawZ = 0; - pMemData->data.RawPitch = 0; - pMemData->data.RawYaw = 0; - pMemData->data.RawRoll = 0; - - pMemData->data.X = tx; - pMemData->data.Y = ty; - pMemData->data.Z = tz; - pMemData->data.Yaw = yaw; - pMemData->data.Pitch = pitch; - pMemData->data.Roll = roll; - - pMemData->data.X1 = pMemData->data.DataID; - pMemData->data.X2 = 0; - pMemData->data.X3 = 0; - pMemData->data.X4 = 0; - pMemData->data.Y1 = 0; - pMemData->data.Y2 = 0; - pMemData->data.Y3 = 0; - pMemData->data.Y4 = 0; - - if (intGameID != pMemData->GameID) + + FTHeap* ft = pMemData; + FTData* data = &ft->data; + + data->RawX = 0; + data->RawY = 0; + data->RawZ = 0; + data->RawPitch = 0; + data->RawYaw = 0; + data->RawRoll = 0; + + data->X = tx; + data->Y = ty; + data->Z = tz; + data->Yaw = yaw; + data->Pitch = pitch; + data->Roll = roll; + + data->X1 = data->DataID; + data->X2 = 0; + data->X3 = 0; + data->X4 = 0; + data->Y1 = 0; + data->Y2 = 0; + data->Y3 = 0; + data->Y4 = 0; + + int32_t id = ft->GameID; + + if (intGameID != id) { QString gamename; - CSV::getGameData(pMemData->GameID, pMemData->table, gamename); - pMemData->GameID2 = pMemData->GameID; - intGameID = pMemData->GameID; + { + unsigned char table[8]; + for (int i = 0; i < 8; i++) table[i] = pMemData->table[i]; + CSV::getGameData(id, table, gamename); + for (int i = 0; i < 8; i++) pMemData->table[i] = table[i]; + } + ft->GameID2 = id; + intGameID = id; QMutexLocker foo(&this->game_name_mutex); connected_game = gamename; } - - pMemData->data.DataID += 1; - shm.unlock(); + + data->DataID += 1; } void FTNoIR_Protocol::start_tirviews() { @@ -165,9 +172,10 @@ bool FTNoIR_Protocol::correct() pMemData->data.CamWidth = 100; pMemData->data.CamHeight = 250; pMemData->GameID2 = 0; - memset(pMemData->table, 0, 8); + for (int i = 0; i < 8; i++) + pMemData->table[i] = 0; - return true; + return true; } extern "C" OPENTRACK_EXPORT IProtocol* GetConstructor() diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx index d5d03011..896d8078 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx @@ -40,27 +40,23 @@ private: int main(void) { - ShmPosix lck_posix(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)); + 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; - } + 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(); + while (1) { + if (shm_posix->stop) + break; data->Yaw = -shm_posix->data[Yaw]; data->Pitch = -shm_posix->data[Pitch]; data->Roll = shm_posix->data[Roll]; @@ -74,8 +70,6 @@ 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(); (void) Sleep(4); - } + } } |