From aa066bdd4622d4f6824fee864f6be6806813f04d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 07:37:41 +0100 Subject: move to subdirectory-based build system Closes #224 --- ftnoir_protocol_wine/ftnoir_protocol_wine.cpp | 59 ------- ftnoir_protocol_wine/ftnoir_protocol_wine.h | 57 ------- .../ftnoir_protocol_wine_dialog.cpp | 19 --- ftnoir_protocol_wine/ftnoir_winecontrols.ui | 170 --------------------- ftnoir_protocol_wine/images/wine.png | Bin 376 -> 0 bytes .../opentrack-wrapper-wine-main.cxx | 80 ---------- .../opentrack-wrapper-wine-posix.cxx | 7 - .../opentrack-wrapper-wine-windows.cxx | 40 ----- ftnoir_protocol_wine/wine-protocol.qrc | 5 - ftnoir_protocol_wine/wine-shm.h | 20 --- 10 files changed, 457 deletions(-) delete mode 100644 ftnoir_protocol_wine/ftnoir_protocol_wine.cpp delete mode 100644 ftnoir_protocol_wine/ftnoir_protocol_wine.h delete mode 100644 ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp delete mode 100644 ftnoir_protocol_wine/ftnoir_winecontrols.ui delete mode 100644 ftnoir_protocol_wine/images/wine.png delete mode 100644 ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx delete mode 100644 ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx delete mode 100644 ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx delete mode 100644 ftnoir_protocol_wine/wine-protocol.qrc delete mode 100644 ftnoir_protocol_wine/wine-shm.h (limited to 'ftnoir_protocol_wine') diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp deleted file mode 100644 index 99ad30a2..00000000 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "ftnoir_protocol_wine.h" -#include -#include -#include /* For mode constants */ -#include /* For O_* constants */ -#include "csv/csv.h" - -FTNoIR_Protocol::FTNoIR_Protocol() : lck_shm(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)), shm(NULL), gameid(0) -{ - if (lck_shm.success()) { - shm = (WineSHM*) lck_shm.ptr(); - memset(shm, 0, sizeof(*shm)); - } - wrapper.start("wine", QStringList() << (QCoreApplication::applicationDirPath() + "/opentrack-wrapper-wine.exe.so")); -} - -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - if (shm) { - shm->stop = true; - wrapper.waitForFinished(100); - } - wrapper.terminate(); - if (!wrapper.waitForFinished(100)) - { - wrapper.kill(); - wrapper.waitForFinished(42); - } - //shm_unlink("/" WINE_SHM_NAME); -} - -void FTNoIR_Protocol::pose( const double *headpose ) { - if (shm) - { - lck_shm.lock(); - for (int i = 3; i < 6; i++) - shm->data[i] = headpose[i] / 57.295781; - for (int i = 0; i < 3; i++) - shm->data[i] = headpose[i] * 10; - if (shm->gameid != gameid) - { - QString gamename; - QMutexLocker foo(&game_name_mutex); - /* 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 */ - CSV::getGameData(shm->gameid, shm->table, gamename); - gameid = shm->gameid2 = shm->gameid; - connected_game = gamename; - } - lck_shm.unlock(); - } -} - -bool FTNoIR_Protocol::correct() -{ - return lck_shm.success(); -} - -OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FTControls, FTNoIR_ProtocolDll) diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h deleted file mode 100644 index 2aeb4608..00000000 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include "ui_ftnoir_winecontrols.h" -#include -#include -#include -#include -#include -#include -#include -#include "opentrack/plugin-api.hpp" -#include "opentrack-compat/shm.h" -#include "ftnoir_protocol_wine/wine-shm.h" - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol() override; - - bool correct() override; - void pose(const double* headpose) override; - QString game_name() override { - QMutexLocker foo(&game_name_mutex); - return connected_game; - } -private: - PortableLockedShm lck_shm; - WineSHM* shm; - QProcess wrapper; - int gameid; - QString connected_game; - QMutex game_name_mutex; -}; - -class FTControls: public IProtocolDialog -{ - Q_OBJECT -public: - FTControls(); - void register_protocol(IProtocol *) override {} - void unregister_protocol() override {} - -private: - Ui::UICFTControls ui; - -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_ProtocolDll : public Metadata -{ -public: - QString name() override { return QString("Wine -- Windows layer for Unix"); } - QIcon icon() override { return QIcon(":/images/wine.png"); } -}; diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp deleted file mode 100644 index e4027c73..00000000 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "ftnoir_protocol_wine.h" -#include -#include "opentrack/plugin-api.hpp" - -FTControls::FTControls() -{ - ui.setupUi( this ); - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); -} - -void FTControls::doOK() { - this->close(); -} - -void FTControls::doCancel() { - this->close(); -} - diff --git a/ftnoir_protocol_wine/ftnoir_winecontrols.ui b/ftnoir_protocol_wine/ftnoir_winecontrols.ui deleted file mode 100644 index 9356c448..00000000 --- a/ftnoir_protocol_wine/ftnoir_winecontrols.ui +++ /dev/null @@ -1,170 +0,0 @@ - - - UICFTControls - - - Qt::NonModal - - - - 0 - 0 - 409 - 110 - - - - FreeTrack settings FaceTrackNoIR - - - - images/freetrack.pngimages/freetrack.png - - - Qt::LeftToRight - - - false - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - There are no settings necessary for the Wine protocol. - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/ftnoir_protocol_wine/images/wine.png b/ftnoir_protocol_wine/images/wine.png deleted file mode 100644 index bcf3a012..00000000 Binary files a/ftnoir_protocol_wine/images/wine.png and /dev/null differ diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx deleted file mode 100644 index ffe8938d..00000000 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx +++ /dev/null @@ -1,80 +0,0 @@ -#include -// OSX sdk 10.8 build error otherwise -#ifdef _LIBCPP_MSVCRT -# undef _LIBCPP_MSVCRT -#endif -#include -#include "freetrackclient/fttypes.h" -#include "ftnoir_protocol_wine/wine-shm.h" -#include "opentrack-compat/export.hpp" - -enum Axis { - TX = 0, TY, TZ, Yaw, Pitch, Roll -}; - -#include "opentrack-compat/shm.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 - -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) { - if (shm_posix->stop) - break; - 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]; - (void) Sleep(4); - } -} diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx deleted file mode 100644 index 50cce728..00000000 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx +++ /dev/null @@ -1,7 +0,0 @@ -#ifdef _WIN32 -# undef _WIN32 -#endif - -#define PortableLockedShm ShmPosix -#include "opentrack-compat/shm.h" -#include "opentrack-compat/shm.cpp" diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx deleted file mode 100644 index 19ee8ffd..00000000 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __WIN32 -# error "bad cross" -#endif - -#define PortableLockedShm ShmWine -#include "opentrack-compat/shm.h" -#include "opentrack-compat/shm.cpp" -#include "wine-shm.h" - -static void write_path(const char* key, const char* subkey) -{ - char dir[8192]; - - if (GetCurrentDirectoryA(8192, dir) < 8190) - { - HKEY hkpath; - if (RegCreateKeyExA(HKEY_CURRENT_USER, - key, - 0, - NULL, - 0, - KEY_ALL_ACCESS, - NULL, - &hkpath, - NULL) == ERROR_SUCCESS) - { - for (int i = 0; dir[i]; i++) - if (dir[i] == '\\') - dir[i] = '/'; - strcat(dir, "/"); - (void) RegSetValueExA(hkpath, subkey, 0, REG_SZ, (BYTE*) dir, strlen(dir) + 1); - RegCloseKey(hkpath); - } - } -} - -void create_registry_key(void) { - write_path("Software\\NaturalPoint\\NATURALPOINT\\NPClient Location", "Path"); - write_path("Software\\Freetrack\\FreeTrackClient", "Path"); -} diff --git a/ftnoir_protocol_wine/wine-protocol.qrc b/ftnoir_protocol_wine/wine-protocol.qrc deleted file mode 100644 index af81caea..00000000 --- a/ftnoir_protocol_wine/wine-protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/wine.png - - diff --git a/ftnoir_protocol_wine/wine-shm.h b/ftnoir_protocol_wine/wine-shm.h deleted file mode 100644 index c7e29abb..00000000 --- a/ftnoir_protocol_wine/wine-shm.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#define WINE_SHM_NAME "facetracknoir-wine-shm" -#define WINE_MTX_NAME "facetracknoir-wine-mtx" - -// OSX sdk 10.8 build error otherwise -#ifdef _LIBCPP_MSVCRT -# undef _LIBCPP_MSVCRT -#endif - -#include - -template using ptr = std::shared_ptr; - -struct WineSHM { - double data[6]; - int gameid, gameid2; - unsigned char table[8]; - bool stop; -}; -- cgit v1.2.3