diff options
Diffstat (limited to 'ftnoir_protocol_wine')
-rw-r--r-- | ftnoir_protocol_wine/ftnoir-wrapper-wine-main.cxx | 22 | ||||
-rw-r--r-- | ftnoir_protocol_wine/ftnoir-wrapper-wine-windows.cxx | 2 | ||||
-rw-r--r-- | ftnoir_protocol_wine/ftnoir_protocol_wine.cpp | 27 | ||||
-rw-r--r-- | ftnoir_protocol_wine/ftnoir_protocol_wine.h | 7 |
4 files changed, 36 insertions, 22 deletions
diff --git a/ftnoir_protocol_wine/ftnoir-wrapper-wine-main.cxx b/ftnoir_protocol_wine/ftnoir-wrapper-wine-main.cxx index 4132062f..9d8914bd 100644 --- a/ftnoir_protocol_wine/ftnoir-wrapper-wine-main.cxx +++ b/ftnoir_protocol_wine/ftnoir-wrapper-wine-main.cxx @@ -1,6 +1,8 @@ #include <errno.h> #include <stdio.h> -#include "ftnoir_protocol_wine/fttypes.h" +#include "ftnoir_protocol_ft/fttypes.h" +#include "ftnoir_protocol_wine/wine-shm.h" +#include "ftnoir_tracker_base/ftnoir_tracker_types.h" class ShmPosix { public: ShmPosix(const char *shmName, const char *mutexName, int mapSize); @@ -39,7 +41,7 @@ int main(void) WineSHM* shm_posix = (WineSHM*) lck_posix.mem; FTMemMap* shm_wine = (FTMemMap*) lck_wine.mem; TFreeTrackData* data = &shm_wine->data; - while (!shm_posix->stop) { + while (1) { (void) Sleep(10); lck_posix.lock(); if (shm_posix->stop) { @@ -47,15 +49,19 @@ int main(void) 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->Yaw = shm_posix->data[RX]; + data->Pitch = shm_posix->data[RY]; + data->Roll = shm_posix->data[RZ]; + data->X = shm_posix->data[TX]; + data->Y = shm_posix->data[TY]; + data->Z = shm_posix->data[TZ]; data->DataID = 1; 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(); } diff --git a/ftnoir_protocol_wine/ftnoir-wrapper-wine-windows.cxx b/ftnoir_protocol_wine/ftnoir-wrapper-wine-windows.cxx index f1345263..a0f444c2 100644 --- a/ftnoir_protocol_wine/ftnoir-wrapper-wine-windows.cxx +++ b/ftnoir_protocol_wine/ftnoir-wrapper-wine-windows.cxx @@ -2,6 +2,6 @@ #define __WIN32 #endif #define PortableLockedShm ShmWine -#include "fttypes.h" +#include "ftnoir_protocol_ft/fttypes.h" #include "compat/compat.h" #include "compat/compat.cpp" diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp index bc1e862a..2f4e64e7 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp @@ -35,16 +35,13 @@ Now it works direcly in shared memory! */ #include "ftnoir_protocol_wine.h" -#include "facetracknoir/global-settings.h" -#include "fttypes.h" - #include <string.h> #include <sys/mman.h> #include <sys/stat.h> /* For mode constants */ #include <fcntl.h> /* For O_* constants */ /** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() : lck_shm(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)), shm(NULL) +FTNoIR_Protocol::FTNoIR_Protocol() : lck_shm(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)), shm(NULL), gameid(0) { if (lck_shm.mem != (void*) -1) { shm = (WineSHM*) lck_shm.mem; @@ -68,16 +65,24 @@ void FTNoIR_Protocol::Initialize() wrapper.start("wine", QStringList() << (QCoreApplication::applicationDirPath() + "/ftnoir-wrapper-wine.exe.so")); } -void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { if (shm) { lck_shm.lock(); - shm->rx = headpose->yaw / 57.295781; - shm->ry = headpose->pitch / 57.295781; - shm->rz = headpose->roll / 57.295781; - shm->tx = headpose->x * 10; - shm->ty = headpose->y * 10; - shm->tz = headpose->z * 10; + for (int i = 0; i < 3; i++) + shm->data[i] = headpose[i] / 57.295781; + for (int i = 3; i < 6; i++) + shm->data[i] = headpose[i] * 10; + if (shm->gameid != gameid) + { + QString id_str = QString::number(gameid); + QString gamename; + /* only EZCA for FSX requires dummy process, and FSX doesn't work on Linux */ + /* memory-hacks DLL can't be loaded into a Linux process, either */ + bool tmp1, tmp2; + CSV::getGameData(id_str, tmp1, tmp2, shm->table, gamename); + gameid = shm->gameid2 = shm->gameid; + } lck_shm.unlock(); } } diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h index efc23cd6..8b3ea739 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h @@ -29,8 +29,9 @@ #define INCLUDED_FTSERVER_H #include "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ftnoir_protocol_ft/fttypes.h" +#include "ftnoir_csv/csv.h" #include "ui_ftnoir_winecontrols.h" -#include "fttypes.h" #include <QMessageBox> #include <QSettings> #include <QLibrary> @@ -39,6 +40,7 @@ #include <QFile> #include "facetracknoir/global-settings.h" #include "compat/compat.h" +#include "ftnoir_protocol_wine/wine-shm.h" class FTNoIR_Protocol : public IProtocol { @@ -49,13 +51,14 @@ public: void Initialize(); bool checkServerInstallationOK(); - void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); + void sendHeadposeToGame(double* headpose, double* rawheadpose ); void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... private: PortableLockedShm lck_shm; WineSHM* shm; QProcess wrapper; + int gameid; }; // Widget that has controls for FTNoIR protocol client-settings. |