diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-30 07:37:41 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-30 08:39:32 +0100 |
commit | aa066bdd4622d4f6824fee864f6be6806813f04d (patch) | |
tree | 3df328b8b364cba2373a85827191b259bd78d546 /ftnoir_protocol_wine | |
parent | d6a54431d178632a2bf466c9904f74abd143afe6 (diff) |
move to subdirectory-based build system
Closes #224
Diffstat (limited to 'ftnoir_protocol_wine')
-rw-r--r-- | ftnoir_protocol_wine/ftnoir_protocol_wine.cpp | 59 | ||||
-rw-r--r-- | ftnoir_protocol_wine/ftnoir_protocol_wine.h | 57 | ||||
-rw-r--r-- | ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp | 19 | ||||
-rw-r--r-- | ftnoir_protocol_wine/ftnoir_winecontrols.ui | 170 | ||||
-rw-r--r-- | ftnoir_protocol_wine/images/wine.png | bin | 376 -> 0 bytes | |||
-rw-r--r-- | ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx | 80 | ||||
-rw-r--r-- | ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx | 7 | ||||
-rw-r--r-- | ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx | 40 | ||||
-rw-r--r-- | ftnoir_protocol_wine/wine-protocol.qrc | 5 | ||||
-rw-r--r-- | ftnoir_protocol_wine/wine-shm.h | 20 |
10 files changed, 0 insertions, 457 deletions
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 <string.h> -#include <sys/mman.h> -#include <sys/stat.h> /* For mode constants */ -#include <fcntl.h> /* 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 <QMessageBox> -#include <QLibrary> -#include <QProcess> -#include <QDebug> -#include <QMutex> -#include <QMutexLocker> -#include <QFile> -#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 <QDebug> -#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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UICFTControls</class> - <widget class="QWidget" name="UICFTControls"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>409</width> - <height>110</height> - </rect> - </property> - <property name="windowTitle"> - <string>FreeTrack settings FaceTrackNoIR</string> - </property> - <property name="windowIcon"> - <iconset> - <normaloff>images/freetrack.png</normaloff>images/freetrack.png</iconset> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="_vertical_layout"> - <item> - <layout class="QHBoxLayout"> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>There are no settings necessary for the Wine protocol.</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="sizeConstraint"> - <enum>QLayout::SetDefaultConstraint</enum> - </property> - <item> - <widget class="QPushButton" name="btnOK"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>OK</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="btnCancel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>10</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> - <slots> - <slot>startEngineClicked()</slot> - <slot>stopEngineClicked()</slot> - <slot>cameraSettingsClicked()</slot> - </slots> -</ui> diff --git a/ftnoir_protocol_wine/images/wine.png b/ftnoir_protocol_wine/images/wine.png Binary files differdeleted file mode 100644 index bcf3a012..00000000 --- a/ftnoir_protocol_wine/images/wine.png +++ /dev/null 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 <cerrno> -// OSX sdk 10.8 build error otherwise -#ifdef _LIBCPP_MSVCRT -# undef _LIBCPP_MSVCRT -#endif -#include <cstdio> -#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 <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) { - 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 @@ -<RCC> - <qresource prefix="/"> - <file>images/wine.png</file> - </qresource> -</RCC> 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 <memory> - -template<typename t> using ptr = std::shared_ptr<t>; - -struct WineSHM { - double data[6]; - int gameid, gameid2; - unsigned char table[8]; - bool stop; -}; |