summaryrefslogtreecommitdiffhomepage
path: root/FaceTrackNoIR
diff options
context:
space:
mode:
authorWim Vriend <facetracknoir@gmail.com>2011-04-07 17:44:03 +0000
committerWim Vriend <facetracknoir@gmail.com>2011-04-07 17:44:03 +0000
commit394dca378432d8ba65dd84432ea1a85ddea636fd (patch)
tree52ab9c5a900e78529f823d40ac0dc6b3b233e072 /FaceTrackNoIR
parentb07a116670236fe13262f04d618b11460f4e4b73 (diff)
PPJoy in DLL
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@65 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FaceTrackNoIR')
-rw-r--r--FaceTrackNoIR/FTNoIR_ppjoycontrols.ui172
-rw-r--r--FaceTrackNoIR/FTServer.cpp257
-rw-r--r--FaceTrackNoIR/FTServer.h105
-rw-r--r--FaceTrackNoIR/FTTypes.h85
-rw-r--r--FaceTrackNoIR/FaceApp.cpp2
-rw-r--r--FaceTrackNoIR/FaceTrackNoIR.cpp23
-rw-r--r--FaceTrackNoIR/FaceTrackNoIR.vcproj146
-rw-r--r--FaceTrackNoIR/PPJIoctl.h32
-rw-r--r--FaceTrackNoIR/PPJoyServer.cpp285
-rw-r--r--FaceTrackNoIR/PPJoyServer.h136
-rw-r--r--FaceTrackNoIR/tracker.cpp48
-rw-r--r--FaceTrackNoIR/tracker.h4
12 files changed, 68 insertions, 1227 deletions
diff --git a/FaceTrackNoIR/FTNoIR_ppjoycontrols.ui b/FaceTrackNoIR/FTNoIR_ppjoycontrols.ui
deleted file mode 100644
index a160801a..00000000
--- a/FaceTrackNoIR/FTNoIR_ppjoycontrols.ui
+++ /dev/null
@@ -1,172 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>UICPPJoyControls</class>
- <widget class="QWidget" name="UICPPJoyControls">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>346</width>
- <height>180</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>PPJoy settings FaceTrackNoIR</string>
- </property>
- <property name="windowIcon">
- <iconset>
- <normaloff>images/FaceTrackNoIR.ico</normaloff>images/FaceTrackNoIR.ico</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>
- <widget class="QLabel" name="textLabel2">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Virtual Joystick number:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="cbxSelectPPJoyNumber">
- <property name="toolTip">
- <string>Select Number</string>
- </property>
- <property name="insertPolicy">
- <enum>QComboBox::InsertAlphabetically</enum>
- </property>
- </widget>
- </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="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/FaceTrackNoIR/FTServer.cpp b/FaceTrackNoIR/FTServer.cpp
deleted file mode 100644
index 7814c2d3..00000000
--- a/FaceTrackNoIR/FTServer.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/********************************************************************************
-* FTServer FTServer is the Class, that communicates headpose-data *
-* to games, using the FreeTrackClient.dll. *
-* It was (very) loosely translated from FTServer.pas. *
-* which was created by the FreeTrack-team. *
-* *
-* Copyright (C) 2010 Wim Vriend (Developing) *
-* Ron Hendriks (Testing and Research) *
-* *
-* Homepage <http://www.free-track.net> *
-* *
-* 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/>. *
-* *
-* We would like to extend our grattitude to the creators of SweetSpotter, *
-* which has become the basis of this program: "Great work guys!" *
-********************************************************************************/
-//
-// There are some issues, that may need solving:
-//
-// The FaceAPI only runs in the 'Release' configuration. It may have something to
-// do with compiler-settings, but for now it's not solved...
-// --> WVR 20101023: This was solved by downgrading to VS2005...
-//
-// Connecting with the Freetrack DLL only seems to work, when UNICODE is OFF.
-// That's strange, isn't it?
-// --> WVR 20100409: Update on this: Loading the DLL with QLibrary implemented.
-// With UNICODE on, the DLL is loaded fine, but the memory-mapping
-// does not. Explicitely using the 'A' extension for CreateFileMapping
-// solves this (for now.) Maybe there is a Qt substitute for this?
-//
-/*
- Modifications (last one on top):
- 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 "FTServer.h"
-
-/** constructor **/
-FTServer::FTServer() {
- ProgramName = "";
-}
-
-/** destructor **/
-FTServer::~FTServer() {
-
- //
- // Free the DLL
- //
- FTClientLib.unload();
-}
-
-//
-// Update Headpose in Game.
-//
-void FTServer::sendHeadposeToGame() {
-
- //
- // Check if the pointer is OK and wait for the Mutex.
- //
- if ( (pMemData != NULL) && (WaitForSingleObject(hFTMutex, 100) == WAIT_OBJECT_0) ) {
-
- //
- // Copy the Raw measurements directly to the client.
- //
- pMemData->data.RawX = headPosX;
- pMemData->data.RawY = headPosY;
- pMemData->data.RawZ = headPosZ;
- pMemData->data.RawPitch = headRotX;
- pMemData->data.RawYaw = headRotY;
- pMemData->data.RawRoll = headRotZ;
-
- //
- // Multiply the FaceAPI value, with the sensitivity setting
- //
- pMemData->data.X = virtPosX;
- pMemData->data.Y = virtPosY;
- pMemData->data.Z = virtPosZ;
- pMemData->data.Pitch = virtRotX;
- pMemData->data.Yaw = virtRotY;
- pMemData->data.Roll = virtRotZ;
-
- //
- // Leave some values 0 yet...
- //
- pMemData->data.X1 = pMemData->data.DataID + 10;
- pMemData->data.X2 = 0;
- pMemData->data.X3 = 0;
- pMemData->data.X4 = 0;
- pMemData->data.Y1 = 0;
- pMemData->data.Y2 = 0;
- pMemData->data.Y3 = 0;
- pMemData->data.Y4 = 0;
-
- //qDebug() << "FTServer says: pMemData.DataID =" << pMemData->data.DataID;
- //qDebug() << "FTServer says: ProgramName =" << pMemData->ProgramName;
- ReleaseMutex(hFTMutex);
- }
-
- pMemData->data.DataID += 1;
-}
-
-//
-// Create a memory-mapping to the Freetrack data.
-// It contains the tracking data, a handle to the main-window and the program-name of the Game!
-//
-//
-bool FTServer::FTCreateMapping(HANDLE handle)
-{
- qDebug() << "FTCreateMapping says: Starting Function";
-
- //
- // A FileMapping is used to create 'shared memory' between the FTServer and the FTClient.
- //
- // Try to create a FileMapping to the Shared Memory.
- // If one already exists: close it.
- //
- hFTMemMap = CreateFileMappingA( INVALID_HANDLE_VALUE , 00 , PAGE_READWRITE , 0 ,
- sizeof( TFreeTrackData ) + sizeof( HANDLE ) + 100,
- (LPCSTR) FT_MM_DATA );
-
- if ( hFTMemMap != 0 ) {
- qDebug() << "FTCreateMapping says: FileMapping Created!" << hFTMemMap;
- }
-
- if ( ( hFTMemMap != 0 ) && ( (long) GetLastError == ERROR_ALREADY_EXISTS ) ) {
- CloseHandle( hFTMemMap );
- hFTMemMap = 0;
- }
-
- //
- // Create a new FileMapping, Read/Write access
- //
- hFTMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) FT_MM_DATA );
- if ( ( hFTMemMap != 0 ) ) {
- qDebug() << "FTCreateMapping says: FileMapping Created again:" << hFTMemMap;
- pMemData = (FTMemMap *) MapViewOfFile(hFTMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TFreeTrackData) + sizeof(hFTMemMap) + 100);
- if (pMemData != NULL) {
- pMemData->handle = handle; // The game uses the handle, to send a message that the Program-Name was set!
- }
- hFTMutex = CreateMutexA(NULL, false, FREETRACK_MUTEX);
- }
- else {
- QMessageBox::information(0, "FaceTrackNoIR error", QString("FTServer Error! \n"));
- return false;
- }
-
- if (pMemData != NULL) {
- pMemData->data.DataID = 1;
- pMemData->data.CamWidth = 100;
- pMemData->data.CamHeight = 250;
- }
-
- return true;
-}
-
-//
-// Destory the FileMapping to the shared memory
-//
-void FTServer::FTDestroyMapping()
-{
- if ( pMemData != NULL ) {
- UnmapViewOfFile ( pMemData );
- }
-
- CloseHandle( hFTMutex );
- CloseHandle( hFTMemMap );
- hFTMemMap = 0;
-}
-
-//
-// Get the program-name from the client (Game!).
-//
-QString FTServer::GetProgramName() {
-QString *str;
-
- str = new QString(pMemData->ProgramName);
- return *str;
-}
-
-
-//
-// Check if the Client DLL exists and load it (to test it), if so.
-// Returns 'true' if all seems OK.
-//
-bool FTServer::checkServerInstallationOK( HANDLE handle )
-{
- QSettings settings("Freetrack", "FreetrackClient"); // Registry settings (in HK_USER)
- QString aLocation; // Location of Client DLL
- QString aFileName; // File Path and Name
-
- importProvider provider;
- char *pProvider;
-
- qDebug() << "FTCheckClientDLL says: Starting Function";
-
- try {
-
- //
- // Load the FreeTrackClient.dll from the current path of FaceTrackNoIR, because there is no
- // guarantee FreeTrack is also installed.
- //
- // Write this path in the registry (under FreeTrack/FreeTrackClient, for the game(s).
- //
- aLocation = QCoreApplication::applicationDirPath() + "/";
- qDebug() << "FTCheckClientDLL says: Location of DLL =" << aLocation;
-
- //
- // Append a '/' to the Path and then the name of the dll.
- //
- aFileName = aLocation;
- aFileName.append(FT_CLIENT_FILENAME);
- qDebug() << "FTCheckClientDLL says: Full path of DLL =" << aFileName;
-
- if ( QFile::exists( aFileName ) ) {
- qDebug() << "FTCheckClientDLL says: DLL exists!";
- //
- // Write the path to the key in the Registry, so the game(s) can find it too...
- //
- settings.setValue( "Path" , aLocation );
-
- //
- // Load the DLL and map to the functions in it.
- //
- FTClientLib.setFileName(aFileName);
- FTClientLib.load();
- provider = (importProvider) FTClientLib.resolve("FTProvider");
- if (provider) {
- pProvider = provider();
- qDebug() << "FTCheckClientDLL says: Provider =" << pProvider;
- }
- }
- else {
- QMessageBox::information(0, "FaceTrackNoIR error", QString("Necessary file (FreeTrackClient.dll) was NOT found!\n"));
- return false;
- }
- } catch(...) {
- settings.~QSettings();
- }
- return FTCreateMapping( handle );
-}
-
-//END
diff --git a/FaceTrackNoIR/FTServer.h b/FaceTrackNoIR/FTServer.h
deleted file mode 100644
index 68b0cabb..00000000
--- a/FaceTrackNoIR/FTServer.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/********************************************************************************
-* FTServer FTServer is the Class, that communicates headpose-data *
-* to games, using the FreeTrackClient.dll. *
-* It was (very) loosely translated from FTServer.pas. *
-* which was created by the FreeTrack-team. *
-* *
-* Copyright (C) 2010 Wim Vriend (Developing) *
-* Ron Hendriks (Testing and Research) *
-* *
-* Homepage <http://www.free-track.net> *
-* *
-* 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/>. *
-* *
-* We would like to extend our grattitude to the creators of SweetSpotter, *
-* which has become the basis of this program: "Great work guys!" *
-********************************************************************************/
-#pragma once
-#ifndef INCLUDED_FTSERVER_H
-#define INCLUDED_FTSERVER_H
-
-#include "FTNoIR_cxx_protocolserver.h"
-#include "FTTypes.h"
-#include <QString>
-#include <QMessageBox>
-#include <QSettings>
-#include <QFile>
-#include <QApplication>
-#include <QDebug>
-//#include <QThread>
-#include <QMutex>
-#include <QLibrary>
-#include <QUdpSocket>
-
-typedef char *(WINAPI *importProvider)(void);
-typedef bool (WINAPI *importGetData)(TFreeTrackData * data);
-typedef HANDLE (WINAPI *importGetMapHandle)(void);
-
-using namespace std;
-using namespace v4friend::ftnoir;
-
-class FTServer : public ProtocolServerBase {
- Q_OBJECT
-
-public:
-
- // public member methods
- FTServer();
- ~FTServer();
-
- QString GetProgramName();
-
- // protected member methods
-protected:
-// void run();
- bool checkServerInstallationOK( HANDLE handle );
- void sendHeadposeToGame();
-
-private:
- bool FTCreateMapping(HANDLE handle);
- void FTDestroyMapping();
-
- HANDLE hFTMemMap;
- FTMemMap *pMemData;
- HANDLE hFTMutex;
-
- /** member varables for saving the head pose **/
- bool confid;
-
- // Private properties
- QString ProgramName;
- QLibrary FTClientLib;
-
-public:
- void setHeadRotX(float x) { headRotX = getRadsFromDegrees(x); }
- void setHeadRotY(float y) { headRotY = getRadsFromDegrees(y); }
- void setHeadRotZ(float z) { headRotZ = getRadsFromDegrees(z); }
- void setHeadPosX(float x) { headPosX = x * 10; }
- void setHeadPosY(float y) { headPosY = y * 10; }
- void setHeadPosZ(float z) { headPosZ = z * 10; }
-
- void setVirtRotX(float rot) { virtRotX = getRadsFromDegrees(rot); }
- void setVirtRotY(float rot) { virtRotY = getRadsFromDegrees(rot); }
- void setVirtRotZ(float rot) { virtRotZ = getRadsFromDegrees(rot); }
- void setVirtPosX(float pos) { virtPosX = pos * 10; }
- void setVirtPosY(float pos) { virtPosY = pos * 10; }
- void setVirtPosZ(float pos) { virtPosZ = pos * 10; }
-
- float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); }
-
-};
-
-
-#endif//INCLUDED_FTSERVER_H
-//END
diff --git a/FaceTrackNoIR/FTTypes.h b/FaceTrackNoIR/FTTypes.h
deleted file mode 100644
index a6dcb6c9..00000000
--- a/FaceTrackNoIR/FTTypes.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/********************************************************************************
-* FTTypes FTTypes contains th specific type definitions for the *
-* FreeTrack protocol. *
-* It was loosely translated from FTTypes.pas *
-* which was created by the FreeTrack-team. *
-* *
-* Copyright (C) 2010 Wim Vriend (Developing) *
-* Ron Hendriks (Testing and Research) *
-* *
-* Homepage <http://www.free-track.net> *
-* *
-* 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/>. *
-* *
-* We would like to extend our grattitude to the creators of SweetSpotter, *
-* which has become the basis of this program: "Great work guys!" *
-********************************************************************************/
-#pragma once
-#ifndef INCLUDED_FTTYPES_H
-#define INCLUDED_FTTYPES_H
-
-#include "Windows.h"
-#include <tchar.h>
-#include <stdio.h>
-
-//#include "Registry.h"
-
-// static const char* FT_CLIENT_LOCATION = "Software\\Freetrack\\FreetrackClient";
- static const char* FT_CLIENT_FILENAME = "FreeTrackClient.Dll";
- static const char* FT_MM_DATA = "FT_SharedMem";
- static const char* FREETRACK = "Freetrack";
- static const char* FREETRACK_MUTEX = "FT_Mutext";
- static const char* FT_PROGRAMID = "FT_ProgramID";
-
-
-struct TFreeTrackData {
- int DataID;
- int CamWidth;
- int CamHeight;
- // virtual pose
- float Yaw; // positive yaw to the left
- float Pitch; // positive pitch up
- float Roll; // positive roll to the left
- float X;
- float Y;
- float Z;
- // raw pose with no smoothing, sensitivity, response curve etc.
- float RawYaw;
- float RawPitch;
- float RawRoll;
- float RawX;
- float RawY;
- float RawZ;
- // raw points, sorted by Y, origin top left corner
- float X1;
- float Y1;
- float X2;
- float Y2;
- float X3;
- float Y3;
- float X4;
- float Y4;
-};
-typedef TFreeTrackData * PFreetrackData;
-
-struct FTMemMap {
- TFreeTrackData data;
- HANDLE handle;
- char ProgramName[100];
-};
-typedef FTMemMap * PFTMemMap;
-
-extern bool (*FTGetData) (PFreetrackData data);
-
-#endif//INCLUDED_FTTYPES_H
diff --git a/FaceTrackNoIR/FaceApp.cpp b/FaceTrackNoIR/FaceApp.cpp
index 5998ebcf..2811974c 100644
--- a/FaceTrackNoIR/FaceApp.cpp
+++ b/FaceTrackNoIR/FaceApp.cpp
@@ -1,6 +1,6 @@
#include "FaceApp.h"
#include "windows.h"
-#include "FTTypes.h"
+#include "..\FTNoIR_Protocol_FT\FTTypes.h"
#include "..\FTNoIR_Protocol_FTIR\FTIRTypes.h"
#include <QDebug>
diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp
index 03f819de..49a6aab2 100644
--- a/FaceTrackNoIR/FaceTrackNoIR.cpp
+++ b/FaceTrackNoIR/FaceTrackNoIR.cpp
@@ -31,7 +31,7 @@
*/
#include "FaceTrackNoIR.h"
#include "tracker.h"
-#include "PPJoyServer.h"
+//#include "PPJoyServer.h"
#include "FSUIPCServer.h"
//#include "FTIRServer.h"
//#include "FGServer.h"
@@ -835,9 +835,28 @@ QLibrary *protocolLib;
case FREE_TRACK:
case SIMCONNECT:
break;
+
case PPJOY:
- _server_controls = new PPJoyControls( this, Qt::Dialog );
+ protocolLib = new QLibrary("FTNoIR_Protocol_PPJOY.dll");
+
+ getIT = (importGetProtocolDialog) protocolLib->resolve("GetProtocolDialog");
+ if (getIT) {
+ IProtocolDialogPtr ptrXyz(getIT());
+ if (ptrXyz)
+ {
+ pProtocolDialog = ptrXyz;
+ pProtocolDialog->Initialize( this );
+ qDebug() << "FaceTrackNoIR::showServerControls GetProtocolDialog Function Resolved!";
+ }
+ else {
+ qDebug() << "FaceTrackNoIR::showServerControls Function NOT Resolved!";
+ }
+ }
+ else {
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton);
+ }
break;
+
case FSUIPC:
_server_controls = new FSUIPCControls( this, Qt::Dialog );
break;
diff --git a/FaceTrackNoIR/FaceTrackNoIR.vcproj b/FaceTrackNoIR/FaceTrackNoIR.vcproj
index c16635b9..67546f1b 100644
--- a/FaceTrackNoIR/FaceTrackNoIR.vcproj
+++ b/FaceTrackNoIR/FaceTrackNoIR.vcproj
@@ -220,10 +220,6 @@
>
</File>
<File
- RelativePath=".\FTServer.cpp"
- >
- </File>
- <File
RelativePath="..\FTNoIR_PoseWidget\glwidget.cpp"
>
</File>
@@ -232,10 +228,6 @@
>
</File>
<File
- RelativePath=".\PPJoyServer.cpp"
- >
- </File>
- <File
RelativePath=".\SCServer.cpp"
>
</File>
@@ -406,36 +398,6 @@
</FileConfiguration>
</File>
<File
- RelativePath=".\FTServer.h"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCustomBuildTool"
- Description="Moc&apos;ing $(InputFileName)..."
- CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_OPENGL_LIB -DQT_NETWORK_LIB -DQT_DLL -I&quot;.\GeneratedFiles\.&quot; -I&quot;$(QTDIR)\include\.&quot; -I&quot;.\GeneratedFiles\$(ConfigurationName)\.&quot; -I&quot;$(QTDIR)\include\QtCore\.&quot; -I&quot;$(QTDIR)\include\QtNetwork\.&quot; -I&quot;$(QTDIR)\include\QtGui\.&quot; -I&quot;$(QTDIR)\include\QtOpenGL\.&quot; -I&quot;$(QTDIR)\include\QtWebKit\.&quot; -I&quot;$(QTDIR)\include\QtTest\.&quot; -I&quot;$(SolutionDir)\FTNoIR_Tracker_UDP\.&quot; -I&quot;$(SolutionDir)\FTNoIR_Tracker_UDP\GeneratedFiles\.&quot; -I&quot;$(SolutionDir)\FTNoIR_Filter_EWMA2\.&quot; &quot;.\FTServer.h&quot; -o &quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot;&#x0D;&#x0A;"
- AdditionalDependencies="&quot;$(QTDIR)\bin\moc.exe&quot;;$(InputPath)"
- Outputs="&quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot;"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCustomBuildTool"
- Description="Moc&apos;ing $(InputFileName)..."
- CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_CORE_LIB -DQT_GUI_LIB -DQT_OPENGL_LIB -DQT_DLL -I&quot;.\GeneratedFiles\.&quot; -I&quot;$(QTDIR)\include\.&quot; -I&quot;.\GeneratedFiles\$(ConfigurationName)\.&quot; -I&quot;$(QTDIR)\include\QtCore\.&quot; -I&quot;$(QTDIR)\include\QtGui\.&quot; -I&quot;$(QTDIR)\include\QtNetwork\.&quot; -I&quot;$(QTDIR)\include\QtOpenGL\.&quot; -I&quot;$(QTDIR)\include\QtWebKit\.&quot; -I&quot;$(QTDIR)\include\QtTest\.&quot; -I&quot;.\.&quot; &quot;.\FTServer.h&quot; -o &quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot;&#x0D;&#x0A;"
- AdditionalDependencies="&quot;$(QTDIR)\bin\moc.exe&quot;;$(InputPath)"
- Outputs="&quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot;"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\FTTypes.h"
- >
- </File>
- <File
RelativePath="..\FTNoIR_PoseWidget\glwidget.h"
>
<FileConfiguration
@@ -462,36 +424,6 @@
</FileConfiguration>
</File>
<File
- RelativePath=".\PPJIoctl.h"
- >
- </File>
- <File
- RelativePath=".\PPJoyServer.h"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCustomBuildTool"
- Description="Moc&apos;ing $(InputFileName)..."
- CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_OPENGL_LIB -DQT_NETWORK_LIB -DQT_DLL -I&quot;.\GeneratedFiles\.&quot; -I&quot;$(QTDIR)\include\.&quot; -I&quot;.\GeneratedFiles\$(ConfigurationName)\.&quot; -I&quot;$(QTDIR)\include\QtCore\.&quot; -I&quot;$(QTDIR)\include\QtNetwork\.&quot; -I&quot;$(QTDIR)\include\QtGui\.&quot; -I&quot;$(QTDIR)\include\QtOpenGL\.&quot; -I&quot;$(QTDIR)\include\QtWebKit\.&quot; -I&quot;$(QTDIR)\include\QtTest\.&quot; -I&quot;$(SolutionDir)\FTNoIR_Tracker_UDP\.&quot; -I&quot;$(SolutionDir)\FTNoIR_Tracker_UDP\GeneratedFiles\.&quot; -I&quot;$(SolutionDir)\FTNoIR_Filter_EWMA2\.&quot; &quot;.\PPJoyServer.h&quot; -o &quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot;&#x0D;&#x0A;"
- AdditionalDependencies="&quot;$(QTDIR)\bin\moc.exe&quot;;$(InputPath)"
- Outputs="&quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot;"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCustomBuildTool"
- Description="Moc&apos;ing $(InputFileName)..."
- CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_CORE_LIB -DQT_GUI_LIB -DQT_OPENGL_LIB -DQT_DLL -I&quot;.\GeneratedFiles\.&quot; -I&quot;$(QTDIR)\include\.&quot; -I&quot;.\GeneratedFiles\$(ConfigurationName)\.&quot; -I&quot;$(QTDIR)\include\QtCore\.&quot; -I&quot;$(QTDIR)\include\QtGui\.&quot; -I&quot;$(QTDIR)\include\QtNetwork\.&quot; -I&quot;$(QTDIR)\include\QtOpenGL\.&quot; -I&quot;$(QTDIR)\include\QtWebKit\.&quot; -I&quot;$(QTDIR)\include\QtTest\.&quot; -I&quot;.\.&quot; &quot;.\PPJoyServer.h&quot; -o &quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot;&#x0D;&#x0A;"
- AdditionalDependencies="&quot;$(QTDIR)\bin\moc.exe&quot;;$(InputPath)"
- Outputs="&quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot;"
- />
- </FileConfiguration>
- </File>
- <File
RelativePath=".\resource.h"
>
</File>
@@ -684,32 +616,6 @@
</FileConfiguration>
</File>
<File
- RelativePath=".\FTNoIR_ppjoycontrols.ui"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCustomBuildTool"
- Description="Uic&apos;ing $(InputFileName)..."
- CommandLine="&quot;$(QTDIR)\bin\uic.exe&quot; -o &quot;.\GeneratedFiles\ui_$(InputName).h&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
- AdditionalDependencies="$(QTDIR)\bin\uic.exe"
- Outputs="&quot;.\GeneratedFiles\ui_$(InputName).h&quot;"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCustomBuildTool"
- Description="Uic&apos;ing $(InputFileName)..."
- CommandLine="&quot;$(QTDIR)\bin\uic.exe&quot; -o &quot;.\GeneratedFiles\ui_$(InputName).h&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
- AdditionalDependencies="$(QTDIR)\bin\uic.exe"
- Outputs="&quot;.\GeneratedFiles\ui_$(InputName).h&quot;"
- />
- </FileConfiguration>
- </File>
- <File
RelativePath=".\FTNoIR_Preferences.ui"
>
<FileConfiguration
@@ -823,10 +729,6 @@
>
</File>
<File
- RelativePath=".\GeneratedFiles\ui_FTNoIR_ppjoycontrols.h"
- >
- </File>
- <File
RelativePath=".\GeneratedFiles\ui_FTNoIR_Preferences.h"
>
</File>
@@ -908,18 +810,6 @@
</FileConfiguration>
</File>
<File
- RelativePath=".\GeneratedFiles\Release\moc_FTServer.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
RelativePath=".\GeneratedFiles\Release\moc_glwidget.cpp"
>
<FileConfiguration
@@ -932,18 +822,6 @@
</FileConfiguration>
</File>
<File
- RelativePath=".\GeneratedFiles\Release\moc_PPJoyServer.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
RelativePath=".\GeneratedFiles\Release\moc_SCServer.cpp"
>
<FileConfiguration
@@ -1079,18 +957,6 @@
</FileConfiguration>
</File>
<File
- RelativePath=".\GeneratedFiles\Debug\moc_FTServer.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
RelativePath=".\GeneratedFiles\Debug\moc_glwidget.cpp"
>
<FileConfiguration
@@ -1114,18 +980,6 @@
</FileConfiguration>
</File>
<File
- RelativePath=".\GeneratedFiles\Debug\moc_PPJoyServer.cpp"
- >
- <FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
RelativePath=".\GeneratedFiles\Debug\moc_SCServer.cpp"
>
<FileConfiguration
diff --git a/FaceTrackNoIR/PPJIoctl.h b/FaceTrackNoIR/PPJIoctl.h
deleted file mode 100644
index c406224f..00000000
--- a/FaceTrackNoIR/PPJIoctl.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __PPJIOCTL_H__
-#define __PPJIOCTL_H__
-
-#include "Windows.h"
-
-/* Define to use byte-size values for joystick axes, else dword size */
-#undef UCHAR_AXES
-
-#define PPJOY_AXIS_MIN 1
-#ifdef UCHAR_AXES
-#define PPJOY_AXIS_MAX 127
-#else
-#define PPJOY_AXIS_MAX 32767
-#endif
-
-#define FILE_DEVICE_PPORTJOY FILE_DEVICE_UNKNOWN
-
-#define PPORTJOY_IOCTL(_index_) \
- CTL_CODE (FILE_DEVICE_PPORTJOY, _index_, METHOD_BUFFERED, FILE_ANY_ACCESS)
-
-#define IOCTL_PPORTJOY_SET_STATE PPORTJOY_IOCTL (0x0)
-
-#define JOYSTICK_STATE_V1 0x53544143
-
-typedef struct
-{
- unsigned long Version;
- unsigned char Data[1];
-} JOYSTICK_SET_STATE, *PJOYSTICK_SET_STATE;
-
-
-#endif
diff --git a/FaceTrackNoIR/PPJoyServer.cpp b/FaceTrackNoIR/PPJoyServer.cpp
deleted file mode 100644
index 83b27f39..00000000
--- a/FaceTrackNoIR/PPJoyServer.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/********************************************************************************
-* 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/>. *
-* *
-* PPJoyServer PPJoyServer is the Class, that communicates headpose-data *
-* to the Virtual Joystick, created by Deon van der Westhuysen.*
-********************************************************************************/
-#include <QtGui>
-#include <QtNetwork>
-#include "PPJoyServer.h"
-#include "Tracker.h"
-#include <Winsock.h>
-
-//long PPJoyServer::PPJoyCorrection = 1470;
-//long PPJoyServer::analogDefault = (PPJOY_AXIS_MIN+PPJOY_AXIS_MAX)/2 - PPJoyServer::PPJoyCorrection;
-static const char* DevName = "\\\\.\\PPJoyIOCTL";
-
-/** constructor **/
-PPJoyServer::PPJoyServer( Tracker *parent ) {
-char strDevName[100];
-
- // Save the parent
- headTracker = parent;
-
- // Initialize arrays
- for (int i = 0;i < 3;i++) {
- centerPos[i] = 0;
- centerRot[i] = 0;
- }
- selectedPPJoy = 1;
- loadSettings();
-
- /* Open a handle to the control device for the first virtual joystick. */
- /* Virtual joystick devices are named PPJoyIOCTL1 to PPJoyIOCTL16. */
- sprintf_s(strDevName, "%s%d", DevName, selectedPPJoy);
- h = CreateFileA((LPCSTR) strDevName,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL);
-
- /* Make sure we could open the device! */
- if (h == INVALID_HANDLE_VALUE)
- {
- QMessageBox::critical(0, "Connection Failed", QString("FaceTrackNoIR failed to connect to Virtual Joystick %1.\nCheck if it was properly installed!").arg(selectedPPJoy));
- return;
- }
-}
-
-/** destructor **/
-PPJoyServer::~PPJoyServer() {
-
-
- /* Make sure we could open the device! */
- if (h == INVALID_HANDLE_VALUE) {
- return;
- }
-
- //
- // Free the Virtual Joystick
- //
- CloseHandle(h);
-}
-
-/** QThread run @override **/
-void PPJoyServer::sendHeadposeToGame() {
-
- /* Initialise the IOCTL data structure */
- JoyState.Signature= JOYSTICK_STATE_V1;
- JoyState.NumAnalog= NUM_ANALOG; // Number of analog values
- Analog= JoyState.Analog; // Keep a pointer to the analog array for easy updating
- Digital= JoyState.Digital; // Keep a pointer to the digital array for easy updating
- JoyState.NumDigital= NUM_DIGITAL; // Number of digital values
-
- /* Make sure we could open the device! */
- /* MessageBox in run() does not work! (runtime error...)*/
- if (h == INVALID_HANDLE_VALUE) {
- return;
- }
-
- // The effective angle for faceTracking will be < 90 degrees, so we assume a smaller range here
- Analog[0] = scale2AnalogLimits( virtRotX, -50.0f, 50.0f ); // Pitch
- Analog[1] = scale2AnalogLimits( virtRotY, -50.0f, 50.0f ); // Yaw
- Analog[2] = scale2AnalogLimits( virtRotZ, -50.0f, 50.0f ); // Roll
-
- // The effective movement for faceTracking will be < 50 cm, so we assume a smaller range here
- Analog[3] = scale2AnalogLimits( virtPosX, -40.0f, 40.0f ); // X
-
- Analog[4] = scale2AnalogLimits( virtPosY, -40.0f, 40.0f ); // Y
- Analog[5] = scale2AnalogLimits( virtPosZ, -40.0f, 40.0f ); // Z
-
- checkAnalogLimits();
-
- /* Send request to PPJoy for processing. */
- /* Currently there is no Return Code from PPJoy, this may be added at a */
- /* later stage. So we pass a 0 byte output buffer. */
- if (!DeviceIoControl( h, IOCTL_PPORTJOY_SET_STATE, &JoyState, sizeof(JoyState), NULL, 0, &RetSize, NULL))
- {
- return;
- }
-}
-
-//
-// Limit the Joystick values
-//
-void PPJoyServer::checkAnalogLimits() {
- for (int i = 0;i < NUM_ANALOG;i++) {
- if (Analog[i]>PPJOY_AXIS_MAX) {
- Analog[i]=PPJOY_AXIS_MAX;
- }
- else if (Analog[i]<PPJOY_AXIS_MIN) {
- Analog[i]=PPJOY_AXIS_MIN;
- }
- }
-}
-
-//
-// Scale the measured value to the Joystick values
-//
-long PPJoyServer::scale2AnalogLimits( float x, float min_x, float max_x ) {
-double y;
-
- y = ((PPJOY_AXIS_MAX - PPJOY_AXIS_MIN)/(max_x - min_x)) * x + ((PPJOY_AXIS_MAX - PPJOY_AXIS_MIN)/2) + PPJOY_AXIS_MIN;
-// qDebug() << "scale2AnalogLimits says: long_y =" << y;
-
- return (long) y;
-}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void PPJoyServer::loadSettings() {
-
- QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "PPJoy" );
- selectedPPJoy = iniFile.value ( "Selection", 1 ).toInt();
- iniFile.endGroup ();
-}
-
-
-//
-// Constructor for server-settings-dialog
-//
-PPJoyControls::PPJoyControls( QWidget *parent, Qt::WindowFlags f ) :
-QWidget( parent , f)
-{
- ui.setupUi( this );
-
- QPoint offsetpos(100, 100);
- this->move(parent->pos() + offsetpos);
-
- // Connect Qt signals to member-functions
- connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
- connect(ui.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int )));
-
- for (int i = 1 ; i < 17; i++) {
- QString cbxText = QString("Virtual Joystick %1").arg(i);
- ui.cbxSelectPPJoyNumber->addItem(QIcon("images/PPJoy.ico"), cbxText);
- }
- // Load the settings from the current .INI-file
- loadSettings();
-}
-
-//
-// Destructor for server-dialog
-//
-PPJoyControls::~PPJoyControls() {
- qDebug() << "~PPJoyControls() says: started";
-}
-
-//
-// OK clicked on server-dialog
-//
-void PPJoyControls::doOK() {
- save();
- this->close();
-}
-
-// override show event
-void PPJoyControls::showEvent ( QShowEvent * event ) {
- loadSettings();
-}
-
-//
-// Cancel clicked on server-dialog
-//
-void PPJoyControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
- switch (ret) {
- case QMessageBox::Save:
- save();
- this->close();
- break;
- case QMessageBox::Discard:
- this->close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- this->close();
- }
-}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void PPJoyControls::loadSettings() {
-
- qDebug() << "loadSettings says: Starting ";
- QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "PPJoy" );
- ui.cbxSelectPPJoyNumber->setCurrentIndex(iniFile.value ( "Selection", 1 ).toInt() - 1);
- iniFile.endGroup ();
-
- settingsDirty = false;
-
-}
-
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
-void PPJoyControls::save() {
-
- qDebug() << "save() says: started";
-
- QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "PPJoy" );
- iniFile.setValue ( "Selection", ui.cbxSelectPPJoyNumber->currentIndex() + 1 );
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-//
-// Handle changes of the Virtual Joystick selection
-//
-void PPJoyControls::virtualJoystickSelected( int index )
-{
- settingsDirty = true;
-}
-
-//END
diff --git a/FaceTrackNoIR/PPJoyServer.h b/FaceTrackNoIR/PPJoyServer.h
deleted file mode 100644
index a12ce34a..00000000
--- a/FaceTrackNoIR/PPJoyServer.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/********************************************************************************
-* 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/>. *
-* *
-* PPJoyServer PPJoyServer is the Class, that communicates headpose-data *
-* to the Virtual Joystick, created by Deon van der Westhuysen.*
-********************************************************************************/
-#pragma once
-#ifndef INCLUDED_PPJOYSERVER_H
-#define INCLUDED_PPJOYSERVER_H
-
-#include "FTNoIR_cxx_protocolserver.h"
-#include "PPJIoctl.h"
-#include <QString>
-#include <QMessageBox>
-#include <QSettings>
-#include <QFile>
-#include <QApplication>
-#include <QDebug>
-#include <QThread>
-#include <QMutex>
-#include <QLibrary>
-
-#include "ui_FTNoIR_ppjoycontrols.h"
-
-using namespace std;
-using namespace v4friend::ftnoir;
-
-class Tracker; // pre-define parent-class to avoid circular includes
-
-#define NUM_ANALOG 7 /* Number of analog values which we will provide */
-#define NUM_DIGITAL 1 /* Number of digital values which we will provide */
-
-#pragma pack(push,1) /* All fields in structure must be byte aligned. */
-typedef struct
-{
- unsigned long Signature; /* Signature to identify packet to PPJoy IOCTL */
- char NumAnalog; /* Num of analog values we pass */
- long Analog[NUM_ANALOG]; /* Analog values */
- char NumDigital; /* Num of digital values we pass */
- char Digital[NUM_DIGITAL]; /* Digital values */
-} JOYSTICK_STATE;
-#pragma pack(pop)
-
-class PPJoyServer : public ProtocolServerBase {
- Q_OBJECT
-
-public:
-
- // public member methods
- PPJoyServer( Tracker *parent );
- ~PPJoyServer();
-
- // protected member methods
-protected:
-// void run();
- void sendHeadposeToGame();
-
-private slots:
-// void readPendingDatagrams();
-
-private:
- Tracker *headTracker; // For upstream messages...
-
- HANDLE h;
- JOYSTICK_STATE JoyState;
- DWORD RetSize;
- DWORD rc;
- long *Analog;
- char *Digital;
- int selectedPPJoy; // Number of virtual joystick (1..16)
-
-// static long analogDefault,PPJoyCorrection;
- long centerPos[3],centerRot[3];
-
- void checkAnalogLimits();
- long scale2AnalogLimits( float x, float min_x, float max_x );
- void loadSettings();
-
-public:
- void setVirtRotX(float rot) { virtRotX = rot; }
- void setVirtRotY(float rot) { virtRotY = rot; }
- void setVirtRotZ(float rot) { virtRotZ = rot; }
- void setVirtPosX(float pos) { virtPosX = pos; }
- void setVirtPosY(float pos) { virtPosY = pos; }
- void setVirtPosZ(float pos) { virtPosZ = pos; }
-
-};
-
-// Widget that has controls for PPJoy server-settings.
-class PPJoyControls: public QWidget, public Ui::UICPPJoyControls
-{
- Q_OBJECT
-public:
-
- explicit PPJoyControls( QWidget *parent=0, Qt::WindowFlags f=0 );
- virtual ~PPJoyControls();
- void showEvent ( QShowEvent * event );
-
-private:
- Ui::UICPPJoyControls ui;
- void loadSettings();
- void save();
-
- /** helper **/
- bool settingsDirty;
-
-private slots:
- void doOK();
- void doCancel();
- void virtualJoystickSelected( int index );
-
-};
-
-
-#endif//INCLUDED_PPJOYSERVER_H
-//END
diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp
index 46b26237..0dd7311e 100644
--- a/FaceTrackNoIR/tracker.cpp
+++ b/FaceTrackNoIR/tracker.cpp
@@ -183,11 +183,31 @@ QFrame *video_frame;
//
switch (selectedClient) {
case FREE_TRACK:
- server_Game = QSharedPointer<FTServer>(new FTServer ( )); // Create Free-track protocol-server
+ server_Game = QSharedPointer<FTNServer>(new FTNServer ( this )); // Create FaceTrackNoIR protocol-server
+
+ //
+ // Load the DLL with the protocol-logic and retrieve a pointer to the Protocol-class.
+ //
+ protocolLib = new QLibrary("FTNoIR_Protocol_FT.dll");
+
+ getProtocol = (importGetProtocol) protocolLib->resolve("GetProtocol");
+ if (getProtocol) {
+ IProtocolPtr ptrXyz(getProtocol());
+ if (ptrXyz)
+ {
+ pProtocol = ptrXyz;
+ pProtocol->Initialize();
+ qDebug() << "Protocol::setup Function Resolved!";
+ }
+ }
+ else {
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "Protocol-DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton);
+ return;
+ }
break;
case FLIGHTGEAR:
- server_Game = QSharedPointer<FTServer>(new FTServer ( )); // Create Free-track protocol-server
+ server_Game = QSharedPointer<FTNServer>(new FTNServer ( this )); // Create FaceTrackNoIR protocol-server
//
// Load the DLL with the protocol-logic and retrieve a pointer to the Protocol-class.
@@ -215,11 +235,31 @@ QFrame *video_frame;
break;
case PPJOY:
- server_Game = QSharedPointer<PPJoyServer>(new PPJoyServer ( this )); // Create PPJoy protocol-server
+ server_Game = QSharedPointer<FTNServer>(new FTNServer ( this )); // Create FaceTrackNoIR protocol-server
+
+ //
+ // Load the DLL with the protocol-logic and retrieve a pointer to the Protocol-class.
+ //
+ protocolLib = new QLibrary("FTNoIR_Protocol_PPJOY.dll");
+
+ getProtocol = (importGetProtocol) protocolLib->resolve("GetProtocol");
+ if (getProtocol) {
+ IProtocolPtr ptrXyz(getProtocol());
+ if (ptrXyz)
+ {
+ pProtocol = ptrXyz;
+ pProtocol->Initialize();
+ qDebug() << "Protocol::setup Function Resolved!";
+ }
+ }
+ else {
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "Protocol-installation invalid",QMessageBox::Ok,QMessageBox::NoButton);
+ return;
+ }
break;
case TRACKIR:
- server_Game = QSharedPointer<FTServer>(new FTServer ( )); // Create Free-track protocol-server
+ server_Game = QSharedPointer<FTNServer>(new FTNServer ( this )); // Create FaceTrackNoIR protocol-server
//
// Load the DLL with the protocol-logic and retrieve a pointer to the Protocol-class.
diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h
index c5921e85..3440495f 100644
--- a/FaceTrackNoIR/tracker.h
+++ b/FaceTrackNoIR/tracker.h
@@ -35,9 +35,9 @@
#define DIRECTINPUT_VERSION 0x0800
#include <Dinput.h>
-#include "FTServer.h" // Freetrack-server
+//#include "FTServer.h" // Freetrack-server
//#include "FGServer.h" // FlightGear-server
-#include "PPJoyServer.h" // Virtual Joystick
+//#include "PPJoyServer.h" // Virtual Joystick
//#include "FTIRServer.h" // FakeTIR-server
#include "SCServer.h" // SimConnect-server (for MS Flight Simulator X)
#include "FSUIPCServer.h" // FSUIPC-server (for MS Flight Simulator 2004)