summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_protocol_wine
diff options
context:
space:
mode:
authorDonovan Baarda <abo@minkirri.apana.org.au>2014-06-12 14:53:43 +1000
committerDonovan Baarda <abo@minkirri.apana.org.au>2014-06-12 14:53:43 +1000
commit0669a40347ffa233bc6042b0f65d244509a61394 (patch)
tree36a4577bdaa1ed28ca1ad222a54777012dd2dda8 /ftnoir_protocol_wine
parent72540e0a96a3120a5d02271e714aba29e136ab78 (diff)
parent7454496476ba17ea622781d280606161581c9544 (diff)
Merge branch 'master' of https://github.com/opentrack/opentrack into dev/ewma2
Resolved conflicts manually in files: ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp ftnoir_filter_ewma2/ftnoir_filter_ewma2.h
Diffstat (limited to 'ftnoir_protocol_wine')
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine.cpp53
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine.h19
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp32
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp32
-rw-r--r--ftnoir_protocol_wine/ftnoir_winecontrols.ui7
-rw-r--r--ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx6
-rw-r--r--ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx7
-rw-r--r--ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx4
8 files changed, 34 insertions, 126 deletions
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
index bb877cc6..58ffe974 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp
@@ -1,39 +1,3 @@
-/********************************************************************************
-* FaceTrackNoIR This program is a private project of the 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. *
-********************************************************************************/
-/*
- Modifications (last one on top):
- 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc.
- 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame
- is called from run() of Tracker.cpp
- 20100601 - WVR: Added Mutex-bit in run(). Thought it wasn't so important (still do...).
- 20100523 - WVR: Implemented the Freetrack-protocol just like Freetrack does. Earlier
- FaceTrackNoIR only worked with an adapted DLL, with a putdata function.
- Now it works direcly in shared memory!
-*/
#include "ftnoir_protocol_wine.h"
#include <string.h>
#include <sys/mman.h>
@@ -43,7 +7,7 @@
/** constructor **/
FTNoIR_Protocol::FTNoIR_Protocol() : lck_shm(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)), shm(NULL), gameid(0)
{
- if (lck_shm.mem != (void*) -1) {
+ if (lck_shm.success()) {
shm = (WineSHM*) lck_shm.mem;
memset(shm, 0, sizeof(*shm));
}
@@ -55,13 +19,18 @@ FTNoIR_Protocol::~FTNoIR_Protocol()
{
if (shm) {
shm->stop = true;
- wrapper.waitForFinished(2000);
+ wrapper.waitForFinished(100);
}
- wrapper.kill();
- shm_unlink("/" WINE_SHM_NAME);
+ wrapper.terminate();
+ if (!wrapper.waitForFinished(100))
+ {
+ wrapper.kill();
+ wrapper.waitForFinished(42);
+ }
+ //shm_unlink("/" WINE_SHM_NAME);
}
-void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) {
+void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) {
if (shm)
{
lck_shm.lock();
@@ -89,7 +58,7 @@ void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose
//
bool FTNoIR_Protocol::checkServerInstallationOK()
{
- return lck_shm.mem != (void*)-1;
+ return lck_shm.success();
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h
index c4837992..50d2bc0c 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h
@@ -33,7 +33,6 @@
#include "ftnoir_csv/csv.h"
#include "ui_ftnoir_winecontrols.h"
#include <QMessageBox>
-#include <QSettings>
#include <QLibrary>
#include <QProcess>
#include <QDebug>
@@ -48,11 +47,14 @@ class FTNoIR_Protocol : public IProtocol
{
public:
FTNoIR_Protocol();
- ~FTNoIR_Protocol();
+ virtual ~FTNoIR_Protocol();
bool checkServerInstallationOK();
- void sendHeadposeToGame(double* headpose, double* rawheadpose );
-
+ void sendHeadposeToGame(const double* headpose);
+ QString getGameName() {
+ QMutexLocker foo(&game_name_mutex);
+ return connected_game;
+ }
private:
PortableLockedShm lck_shm;
WineSHM* shm;
@@ -60,10 +62,6 @@ private:
int gameid;
QString connected_game;
QMutex game_name_mutex;
- QString getGameName() {
- QMutexLocker((QMutex*)&game_name_mutex);
- return connected_game;
- }
};
// Widget that has controls for FTNoIR protocol client-settings.
@@ -71,11 +69,8 @@ class FTControls: public QWidget, public IProtocolDialog
{
Q_OBJECT
public:
-
FTControls();
- void showEvent ( QShowEvent * event ) {show();}
- void Initialize(QWidget *parent) {show();}
- void registerProtocol(IProtocol *protocol) {}
+ void registerProtocol(IProtocol *) {}
void unRegisterProtocol() {}
private:
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp
index 4021a8e5..ecbc2137 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp
@@ -1,35 +1,3 @@
-/********************************************************************************
-* 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) 2012 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/>. *
-* *
-********************************************************************************/
-/*
- Modifications (last one on top):
- 20120830 - WVR: The Dialog class was used to get general info on the DLL. This
- had a big disadvantage: the complete dialog was loaded, just to get
- some data and then it was deleted again (without ever showing the dialog).
- The ProtocolDll class solves this.
- The functions to get the name(s) and icon were removed from the two other classes.
-*/
#include "ftnoir_protocol_wine.h"
#include <QDebug>
#include "facetracknoir/global-settings.h"
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp
index 1e9298b0..dd7f17a6 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp
@@ -1,35 +1,3 @@
-/********************************************************************************
-* 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) 2012 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/>. *
-* *
-********************************************************************************/
-/*
- Modifications (last one on top):
- 20120830 - WVR: The Dialog class was used to get general info on the DLL. This
- had a big disadvantage: the complete dialog was loaded, just to get
- some data and then it was deleted again (without ever showing the dialog).
- The ProtocolDll class solves this.
- The functions to get the name(s) and icon were removed from the two other classes.
-*/
#include "ftnoir_protocol_wine.h"
#include <QDebug>
#include "facetracknoir/global-settings.h"
diff --git a/ftnoir_protocol_wine/ftnoir_winecontrols.ui b/ftnoir_protocol_wine/ftnoir_winecontrols.ui
index 71e99d88..9356c448 100644
--- a/ftnoir_protocol_wine/ftnoir_winecontrols.ui
+++ b/ftnoir_protocol_wine/ftnoir_winecontrols.ui
@@ -2,12 +2,15 @@
<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>411</width>
- <height>112</height>
+ <width>409</width>
+ <height>110</height>
</rect>
</property>
<property name="windowTitle">
diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
index a81bccae..6e512b6e 100644
--- a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
+++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx
@@ -12,6 +12,7 @@ public:
~ShmPosix();
void lock();
void unlock();
+ bool success();
void* mem;
private:
int fd, size;
@@ -23,6 +24,7 @@ public:
~ShmWine();
void lock();
void unlock();
+ bool success();
void* mem;
private:
void *hMutex, *hMapFile;
@@ -33,11 +35,11 @@ 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.mem == (void*)-1) {
+ if(!lck_posix.success()) {
printf("Can't open posix map: %d\n", errno);
return 1;
}
- if(lck_wine.mem == NULL) {
+ if(!lck_wine.success()) {
printf("Can't open Wine map\n");
return 1;
}
diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx
index c88dd332..010c4440 100644
--- a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx
+++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx
@@ -1,9 +1,8 @@
+#define OPENTRACK_COMPAT_BUNDLED
#ifdef _WIN32
-#undef _WIN32
-#endif
-#ifdef __WIN32
-#undef __WIN32
+# undef _WIN32
#endif
+
#define PortableLockedShm ShmPosix
#include "compat/compat.h"
#include "compat/compat.cpp"
diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx
index 6d5484a9..e7102600 100644
--- a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx
+++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx
@@ -1,7 +1,11 @@
+#define OPENTRACK_COMPAT_BUNDLED
+
#ifndef __WIN32
#define __WIN32
#endif
+
#define PortableLockedShm ShmWine
+
#include "ftnoir_protocol_ft/fttypes.h"
#include "compat/compat.h"
#include "compat/compat.cpp"