summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_protocol_wine
diff options
context:
space:
mode:
Diffstat (limited to 'ftnoir_protocol_wine')
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine.cpp20
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine.h53
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp28
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp18
-rw-r--r--ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx29
-rw-r--r--ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx11
-rw-r--r--ftnoir_protocol_wine/wine-shm.h4
7 files changed, 46 insertions, 117 deletions
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
index 58ffe974..29a2a70c 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
@@ -3,18 +3,17 @@
#include <sys/mman.h>
#include <sys/stat.h> /* For mode constants */
#include <fcntl.h> /* For O_* constants */
+#include "ftnoir_csv/csv.h"
-/** constructor **/
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.mem;
+ shm = (WineSHM*) lck_shm.ptr();
memset(shm, 0, sizeof(*shm));
}
wrapper.start("wine", QStringList() << (QCoreApplication::applicationDirPath() + "/opentrack-wrapper-wine.exe.so"));
}
-/** destructor **/
FTNoIR_Protocol::~FTNoIR_Protocol()
{
if (shm) {
@@ -52,25 +51,12 @@ void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) {
}
}
-//
-// Check if the Client DLL exists and load it (to test it), if so.
-// Returns 'true' if all seems OK.
-//
bool FTNoIR_Protocol::checkServerInstallationOK()
{
return lck_shm.success();
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocol - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocol@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0")
-
-extern "C" FTNOIR_PROTOCOL_BASE_EXPORT void* CALLING_CONVENTION GetConstructor()
+extern "C" OPENTRACK_EXPORT void* GetConstructor()
{
return (IProtocol*) new FTNoIR_Protocol;
}
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h
index 50d2bc0c..9a7fb7d5 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h
@@ -1,36 +1,5 @@
-/********************************************************************************
-* FaceTrackNoIR This program is a private project of some enthusiastic *
-* gamers from Holland, who don't like to pay much for *
-* head-tracking. *
-* *
-* Copyright (C) 2010 Wim Vriend (Developing) *
-* Ron Hendriks (Researching and Testing) *
-* *
-* Homepage *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU General Public License as published by the *
-* Free Software Foundation; either version 3 of the License, or (at your *
-* option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but *
-* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
-* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
-* more details. *
-* *
-* You should have received a copy of the GNU General Public License along *
-* with this program; if not, see <http://www.gnu.org/licenses/>. *
-* *
-* FTServer FTServer is the Class, that communicates headpose-data *
-* to games, using the FreeTrackClient.dll. *
-********************************************************************************/
#pragma once
-#ifndef INCLUDED_FTSERVER_H
-#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 <QMessageBox>
#include <QLibrary>
@@ -39,15 +8,15 @@
#include <QMutex>
#include <QMutexLocker>
#include <QFile>
-#include "facetracknoir/global-settings.h"
+#include "facetracknoir/plugin-api.hpp"
#include "compat/compat.h"
#include "ftnoir_protocol_wine/wine-shm.h"
class FTNoIR_Protocol : public IProtocol
{
public:
- FTNoIR_Protocol();
- virtual ~FTNoIR_Protocol();
+ FTNoIR_Protocol();
+ ~FTNoIR_Protocol() override;
bool checkServerInstallationOK();
void sendHeadposeToGame(const double* headpose);
@@ -64,7 +33,6 @@ private:
QMutex game_name_mutex;
};
-// Widget that has controls for FTNoIR protocol client-settings.
class FTControls: public QWidget, public IProtocolDialog
{
Q_OBJECT
@@ -77,18 +45,15 @@ private:
Ui::UICFTControls ui;
private slots:
- void doOK();
- void doCancel();
+ void doOK();
+ void doCancel();
};
-//*******************************************************************************************************
-// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol
-//*******************************************************************************************************
class FTNoIR_ProtocolDll : public Metadata
{
public:
- FTNoIR_ProtocolDll();
- ~FTNoIR_ProtocolDll();
+ FTNoIR_ProtocolDll();
+ ~FTNoIR_ProtocolDll();
void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Wine"); }
void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Wine"); }
@@ -96,7 +61,3 @@ public:
void getIcon(QIcon *icon) { *icon = QIcon(":/images/wine.png"); }
};
-
-
-#endif//INCLUDED_FTSERVER_H
-//END
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp
index ecbc2137..c092de42 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp
@@ -1,39 +1,23 @@
#include "ftnoir_protocol_wine.h"
#include <QDebug>
-#include "facetracknoir/global-settings.h"
+#include "facetracknoir/plugin-support.h"
-//*******************************************************************************************************
-// FaceTrackNoIR Client Settings-dialog.
-//*******************************************************************************************************
-
-//
-// Constructor for server-settings-dialog
-//
FTControls::FTControls() : QWidget()
{
- ui.setupUi( this );
- connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
+ ui.setupUi( this );
+ connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
+ connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
}
-//
-// Destructor for server-dialog
-
-//
-// OK clicked on server-dialog
-//
void FTControls::doOK() {
- this->close();
+ this->close();
}
-//
-// Cancel clicked on server-dialog
-//
void FTControls::doCancel() {
this->close();
}
-extern "C" FTNOIR_PROTOCOL_BASE_EXPORT void* CALLING_CONVENTION GetDialog( )
+extern "C" OPENTRACK_EXPORT void* GetDialog( )
{
return (IProtocolDialog*) new FTControls;
}
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp
index dd7f17a6..c6e3d433 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp
@@ -1,25 +1,15 @@
#include "ftnoir_protocol_wine.h"
-#include <QDebug>
-#include "facetracknoir/global-settings.h"
+#include "facetracknoir/plugin-support.h"
-FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() {
+FTNoIR_ProtocolDll::FTNoIR_ProtocolDll()
+{
}
FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll()
{
-
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0")
-
-extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
+extern "C" OPENTRACK_EXPORT Metadata* GetMetadata()
{
return new FTNoIR_ProtocolDll;
}
diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
index 6e512b6e..40f36f8d 100644
--- a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
+++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
@@ -1,8 +1,13 @@
-#include <errno.h>
-#include <stdio.h>
+#include <cerrno>
+#include <cstdio>
#include "ftnoir_protocol_ft/fttypes.h"
#include "ftnoir_protocol_wine/wine-shm.h"
-#include "ftnoir_tracker_base/ftnoir_tracker_types.h"
+
+#define OPENTRACK_CROSS_ONLY
+#include "facetracknoir/plugin-api.hpp"
+
+#define OPENTRACK_COMPAT_BUNDLED
+#include "compat/compat.h"
void create_registry_key(void);
@@ -13,8 +18,9 @@ public:
void lock();
void unlock();
bool success();
- void* mem;
+ inline void* ptr() { return mem; }
private:
+ void* mem;
int fd, size;
};
@@ -25,8 +31,9 @@ public:
void lock();
void unlock();
bool success();
- void* mem;
+ inline void* ptr() { return mem; }
private:
+ void* mem;
void *hMutex, *hMapFile;
};
#include <windows.h>
@@ -34,8 +41,8 @@ private:
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.success()) {
+ ShmWine lck_wine("FT_SharedMem", "FT_Mutext", sizeof(FTHeap));
+ if(!lck_posix.success()) {
printf("Can't open posix map: %d\n", errno);
return 1;
}
@@ -43,12 +50,11 @@ int main(void)
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;
+ WineSHM* shm_posix = (WineSHM*) lck_posix.ptr();
+ FTHeap* shm_wine = (FTHeap*) lck_wine.ptr();
+ FTData* data = &shm_wine->data;
create_registry_key();
while (1) {
- (void) Sleep(10);
lck_posix.lock();
if (shm_posix->stop) {
lck_posix.unlock();
@@ -70,5 +76,6 @@ int main(void)
shm_wine->table[i] = shm_posix->table[i];
lck_wine.unlock();
lck_posix.unlock();
+ (void) Sleep(4);
}
}
diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx
index e7102600..b7dc531c 100644
--- a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx
+++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx
@@ -1,19 +1,16 @@
-#define OPENTRACK_COMPAT_BUNDLED
-
#ifndef __WIN32
-#define __WIN32
+# error "bad cross"
#endif
+#define OPENTRACK_COMPAT_BUNDLED
#define PortableLockedShm ShmWine
-
-#include "ftnoir_protocol_ft/fttypes.h"
#include "compat/compat.h"
#include "compat/compat.cpp"
-#include <string.h>
+#include "wine-shm.h"
void create_registry_key(void) {
char dir[8192];
-
+
if (GetCurrentDirectoryA(8192, dir) < 8190)
{
HKEY hkpath;
diff --git a/ftnoir_protocol_wine/wine-shm.h b/ftnoir_protocol_wine/wine-shm.h
index ddbda8b5..c0f29cd3 100644
--- a/ftnoir_protocol_wine/wine-shm.h
+++ b/ftnoir_protocol_wine/wine-shm.h
@@ -3,6 +3,10 @@
#define WINE_SHM_NAME "facetracknoir-wine-shm"
#define WINE_MTX_NAME "facetracknoir-wine-mtx"
+#include <memory>
+
+template<typename t> using ptr = std::shared_ptr<t>;
+
struct WineSHM {
double data[6];
int gameid, gameid2;