summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_protocol_wine
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-09-22 15:25:19 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-09-22 15:25:19 +0200
commit69236c0317a30bf100ec4f3d0f8e58fdc565a34b (patch)
tree0e754b9454982efb0b3b9ac40ed769543d87f159 /ftnoir_protocol_wine
parentd3d17ad9b662aca4327b7b63ba1824eb14d7874b (diff)
fix Wine proto bitrot
Diffstat (limited to 'ftnoir_protocol_wine')
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine.cpp5
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine.h17
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp10
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp2
-rw-r--r--ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx84
-rw-r--r--ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx12
-rw-r--r--ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx16
-rw-r--r--ftnoir_protocol_wine/wine-shm.h4
8 files changed, 70 insertions, 80 deletions
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
index 3208795c..8ebc394d 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
@@ -3,11 +3,12 @@
#include <sys/mman.h>
#include <sys/stat.h> /* For mode constants */
#include <fcntl.h> /* For O_* constants */
+#include "ftnoir_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.mem;
+ shm = (WineSHM*) lck_shm.ptr();
memset(shm, 0, sizeof(*shm));
}
wrapper.start("wine", QStringList() << (QCoreApplication::applicationDirPath() + "/opentrack-wrapper-wine.exe.so"));
@@ -55,7 +56,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK()
return lck_shm.success();
}
-extern "C" FTNOIR_PROTOCOL_BASE_EXPORT void* CALLING_CONVENTION GetConstructor()
+extern "C" OPENTRACK_EXPORT void* CALLING_CONVENTION 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 95e833f6..9a7fb7d5 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h
@@ -1,8 +1,5 @@
#pragma once
-#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>
@@ -11,15 +8,15 @@
#include <QMutex>
#include <QMutexLocker>
#include <QFile>
-#include "facetracknoir/plugin-support.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);
@@ -48,15 +45,15 @@ private:
Ui::UICFTControls ui;
private slots:
- void doOK();
- void doCancel();
+ void doOK();
+ void doCancel();
};
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"); }
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp
index a6fae479..bcd3df45 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp
@@ -4,20 +4,20 @@
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()));
}
void FTControls::doOK() {
- this->close();
+ this->close();
}
void FTControls::doCancel() {
this->close();
}
-extern "C" FTNOIR_PROTOCOL_BASE_EXPORT void* CALLING_CONVENTION GetDialog( )
+extern "C" OPENTRACK_EXPORT void* CALLING_CONVENTION 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 7d7fb247..16e3e7c7 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp
@@ -9,7 +9,7 @@ FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll()
{
}
-extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
+extern "C" OPENTRACK_EXPORT Metadata* CALLING_CONVENTION 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..fe5a95f9 100644
--- a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
+++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
@@ -1,60 +1,42 @@
-#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"
-void create_registry_key(void);
+#define OPENTRACK_CROSS_ONLY
+#include "facetracknoir/plugin-api.hpp"
-class ShmPosix {
-public:
- ShmPosix(const char *shmName, const char *mutexName, int mapSize);
- ~ShmPosix();
- void lock();
- void unlock();
- bool success();
- void* mem;
-private:
- int fd, size;
-};
+#define OPENTRACK_COMPAT_BUNDLED
+#include "compat/compat.h"
-class ShmWine {
-public:
- ShmWine(const char *shmName, const char *mutexName, int mapSize);
- ~ShmWine();
- void lock();
- void unlock();
- bool success();
- void* mem;
-private:
- void *hMutex, *hMapFile;
-};
-#include <windows.h>
+void create_registry_key(void);
+ptr<BasePortableLockedShm> make_shm_posix();
+ptr<BasePortableLockedShm> make_shm_win32();
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()) {
- 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.mem;
- FTMemMap* shm_wine = (FTMemMap*) lck_wine.mem;
- TFreeTrackData* data = &shm_wine->data;
+ ptr<BasePortableLockedShm> lck_posix = make_shm_posix();
+ ptr<BasePortableLockedShm> lck_wine = make_shm_win32();
+ 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) {
- (void) Sleep(10);
- lck_posix.lock();
- if (shm_posix->stop) {
- lck_posix.unlock();
- break;
- }
- lck_wine.lock();
+ while (1) {
+ (void) Sleep(4);
+ lck_posix->lock();
+ if (shm_posix->stop) {
+ lck_posix->unlock();
+ break;
+ }
+ lck_wine->lock();
data->Yaw = shm_posix->data[Yaw];
data->Pitch = shm_posix->data[Pitch];
data->Roll = shm_posix->data[Roll];
@@ -68,7 +50,7 @@ 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();
- }
+ lck_wine->unlock();
+ lck_posix->unlock();
+ }
}
diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx
index 010c4440..ea01ff03 100644
--- a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx
+++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx
@@ -1,8 +1,12 @@
#define OPENTRACK_COMPAT_BUNDLED
-#ifdef _WIN32
-# undef _WIN32
-#endif
-
#define PortableLockedShm ShmPosix
+#undef _WIN32
+#include "ftnoir_protocol_ft/fttypes.h"
+#include "wine-shm.h"
#include "compat/compat.h"
#include "compat/compat.cpp"
+
+ptr<BasePortableLockedShm> make_shm_posix()
+{
+ return std::make_shared<ShmPosix>(FREETRACK_HEAP, FREETRACK_MUTEX, sizeof(FTHeap));
+}
diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx
index e7102600..715dcc69 100644
--- a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx
+++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx
@@ -1,19 +1,21 @@
-#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"
+
+ptr<BasePortableLockedShm> make_shm_win32()
+{
+ return std::make_shared<ShmWine>(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM));
+}
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;