From 4b7af2d35be630472daadf3b85f289603a7092ad Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Thu, 21 Oct 2010 16:01:47 +0000 Subject: FSUIPC added git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@24 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR/FTNoIR_Curves.ui | 173 +++++++++++++++++++----------- FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui | 7 -- FaceTrackNoIR/FaceTrackNoIR.cpp | 82 ++++++++++---- FaceTrackNoIR/FaceTrackNoIR.qrc | 1 + FaceTrackNoIR/FaceTrackNoIR.ui | 19 +++- FaceTrackNoIR/FaceTrackNoIR.vcproj | 99 ++++++++++++++++- FaceTrackNoIR/SCServer.cpp | 8 +- FaceTrackNoIR/SCServer.h | 10 +- FaceTrackNoIR/tracker.cpp | 112 ++++++++++++------- FaceTrackNoIR/tracker.h | 5 +- 10 files changed, 372 insertions(+), 144 deletions(-) (limited to 'FaceTrackNoIR') diff --git a/FaceTrackNoIR/FTNoIR_Curves.ui b/FaceTrackNoIR/FTNoIR_Curves.ui index 762ff059..c13565e2 100644 --- a/FaceTrackNoIR/FTNoIR_Curves.ui +++ b/FaceTrackNoIR/FTNoIR_Curves.ui @@ -6,8 +6,8 @@ 0 0 - 681 - 728 + 757 + 603 @@ -97,7 +97,7 @@ color: rgb(255, 255, 255); - 1 + 0 @@ -112,8 +112,8 @@ color: rgb(255, 255, 255); 10 10 - 643 - 627 + 708 + 511 @@ -252,21 +252,49 @@ color: rgb(255, 255, 255); - + 50 - + NeutralZone - + + + + NeutralZone + + + + + + + NeutralZone + + + + + + + 50 + + + + + + + 50 + + + + @@ -290,33 +318,51 @@ background-color: rgb(255, 255, 255); - - - - NeutralZone - - - - - - - NeutralZone - - - - - - - 50 - - - - - - 50 - - + + + + + Qt::Vertical + + + QSizePolicy::Maximum + + + + 20 + 115 + + + + + + + + + 16777215 + 25 + + + + Use the circular handles to change + + + + + + + + 16777215 + 25 + + + + the curve(s). + + + + @@ -334,12 +380,12 @@ background-color: rgb(255, 255, 255); 10 10 - 593 - 633 + 708 + 491 - + 50 @@ -384,7 +430,7 @@ background-color: rgb(255, 255, 255); - + 50 @@ -429,24 +475,7 @@ background-color: rgb(255, 255, 255); - - - - - - - 170 - 140 - - - - image: url(:/images/translation_DOFs.png); - - - - - - + 50 @@ -491,48 +520,65 @@ background-color: rgb(255, 255, 255); - + NeutralZone - + 50 - + NeutralZone - + NeutralZone - + 50 - + 50 + + + + + + + 170 + 140 + + + + image: url(:/images/translation_DOFs.png); + + + + + @@ -540,9 +586,6 @@ background-color: rgb(255, 255, 255); - - - diff --git a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui index 321a1af5..f495d38a 100644 --- a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui +++ b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui @@ -138,13 +138,6 @@ - - - - (Shortkeys are activated after tracker 'Start') - - - diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 17e4284a..ffa38344 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -25,6 +25,7 @@ #include "FaceTrackNoIR.h" #include "tracker.h" #include "PPJoyServer.h" +#include "FSUIPCServer.h" using namespace sm::faceapi; using namespace sm::faceapi::qt; @@ -72,6 +73,7 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { connect(ui.actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences())); connect(ui.actionKeyboard_Shortcuts, SIGNAL(triggered()), this, SLOT(showKeyboardShortcuts())); connect(ui.actionCurve_Configuration, SIGNAL(triggered()), this, SLOT(showCurveConfiguration())); + connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(about())); @@ -304,19 +306,50 @@ void FaceTrackNoIR::save() { // // Get the new name of the INI-file and save the settings to it. // +// The user may choose to overwrite an existing file. This will be deleted, before copying the current file to it. +// void FaceTrackNoIR::saveAs() { + // + // Get the current filename of the INI-file. + // + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + + // + // Get the new filename of the INI-file. + // QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), QCoreApplication::applicationDirPath() + "/Settings", tr("Settings file (*.ini);;All Files (*)")); if (!fileName.isEmpty()) { - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + + // + // Remove the file, if it already exists. + // + QFileInfo newFileInfo ( fileName ); + if (newFileInfo.exists()) { + QFile newFileFile ( fileName ); + newFileFile.remove(); + } + + // + // Copy the current INI-file to the new name. + // + QFileInfo oldFileInfo ( oldFile ); + if (oldFileInfo.exists()) { + QFile oldFileFile ( oldFile ); + oldFileFile.copy( fileName ); + } + + // + // Write the new name to the Registry and save the other INI-values. + // settings.setValue ("SettingsFile", fileName); save(); // Put the filename in the window-title - QFileInfo pathInfo ( fileName ); - setWindowTitle ( "FaceTrackNoIR - " + pathInfo.fileName() ); + setWindowTitle ( "FaceTrackNoIR (1.4) - " + newFileInfo.fileName() ); } } @@ -359,7 +392,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "FaceTrackNoIR - " + pathInfo.fileName() ); + setWindowTitle ( "FaceTrackNoIR (1.4) - " + pathInfo.fileName() ); } @@ -609,20 +642,34 @@ void FaceTrackNoIR::showEngineControls() { /** toggles Server Controls Dialog **/ void FaceTrackNoIR::showServerControls() { + + // + // Delete the existing QDialog + // + if (_server_controls) { + delete _server_controls; + _server_controls = 0; + } + // Create if new if (!_server_controls) { + + // Show the appropriate Protocol-server Settings switch (ui.iconcomboBox->currentIndex()) { case FREE_TRACK: - break; case FLIGHTGEAR: - break; case FTNOIR: + case TRACKIR: + case SIMCONNECT: break; case PPJOY: _server_controls = new PPJoyControls( this, Qt::Dialog ); break; + case FSUIPC: + _server_controls = new FSUIPCControls( this, Qt::Dialog ); + break; default: break; } @@ -698,7 +745,8 @@ void FaceTrackNoIR::createIconGroupBox() ui.iconcomboBox->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/FaceTrackNoIR.ico"), tr("FTNoir client")); ui.iconcomboBox->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/PPJoy.ico"), tr("Virtual Joystick")); ui.iconcomboBox->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/TrackIR.ico"), tr("Fake TrackIR")); - ui.iconcomboBox->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/FSX.ico"), tr("SimConnect")); + ui.iconcomboBox->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/FSX.ico"), tr("SimConnect (FSX)")); + ui.iconcomboBox->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/FS9.ico"), tr("FS2002/FS2004")); ui.iconcomboTrackerSource->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/SeeingMachines.ico"), tr("Face API")); ui.iconcomboTrackerSource->addItem(QIcon(QCoreApplication::applicationDirPath() + "/images/FaceTrackNoIR.ico"), tr("FTNoir server")); @@ -760,24 +808,22 @@ void FaceTrackNoIR::setIcon(int index) // Enable/disable Protocol-server Settings switch (ui.iconcomboBox->currentIndex()) { case FREE_TRACK: - ui.btnShowServerControls->hide(); - break; case FLIGHTGEAR: - ui.btnShowServerControls->hide(); - break; case FTNOIR: + case TRACKIR: + case SIMCONNECT: ui.btnShowServerControls->hide(); break; case PPJOY: ui.btnShowServerControls->show(); ui.btnShowServerControls->setEnabled ( true ); break; - case TRACKIR: - ui.btnShowServerControls->hide(); - break; - case SIMCONNECT: - ui.btnShowServerControls->hide(); + + case FSUIPC: + ui.btnShowServerControls->show(); + ui.btnShowServerControls->setEnabled ( true ); break; + default: break; } @@ -1239,7 +1285,7 @@ QWidget( parent , f) { ui.setupUi( this ); - QPoint offsetpos(100, 100); + QPoint offsetpos(120, 30); this->move(parent->pos() + offsetpos); mainApp = ftnoir; // Preserve a pointer to FTNoIR @@ -1444,7 +1490,6 @@ float newMax; // // If Point 1 exists, read it from the file. // If not: get the y-coord from the global (deprecated) NeutralZone setting. - // Any case: set the x-coord to '0', to keep it on the Y-axis // if (iniFile->contains(prefix + "point1")) { *point1 = iniFile->value ( prefix + "point1", 0 ).toPoint(); @@ -1452,7 +1497,6 @@ float newMax; else { point1->setY(NeutralZone); } - point1->setX(0); // // If Point 4 exists, read it from the file. diff --git a/FaceTrackNoIR/FaceTrackNoIR.qrc b/FaceTrackNoIR/FaceTrackNoIR.qrc index 258ea792..89899a37 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.qrc +++ b/FaceTrackNoIR/FaceTrackNoIR.qrc @@ -1,5 +1,6 @@ + UIElements/Curves.png images/rotation_DOFs.png images/translation_DOFs.png images/FlightGear.ico diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index 91c25ff5..042a11b9 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -918,7 +918,7 @@ color:#000; -1 - 5 + 6 @@ -945,6 +945,23 @@ color:#000; + + + + Curves + + + + :/UIElements/Curves.png:/UIElements/Curves.png + + + + 150 + 32 + + + + diff --git a/FaceTrackNoIR/FaceTrackNoIR.vcproj b/FaceTrackNoIR/FaceTrackNoIR.vcproj index e691835e..ae73dc1c 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.vcproj +++ b/FaceTrackNoIR/FaceTrackNoIR.vcproj @@ -70,11 +70,11 @@ /> + + @@ -317,6 +321,32 @@ RelativePath=".\FGTypes.h" > + + + + + + + + @@ -521,6 +551,32 @@ /> + + + + + + + + @@ -654,6 +710,10 @@ RelativePath=".\GeneratedFiles\ui_FTNoIR_Curves.h" > + + @@ -707,6 +767,18 @@ /> + + + + + @@ -809,6 +881,29 @@ /> + + + + + + + + diff --git a/FaceTrackNoIR/SCServer.cpp b/FaceTrackNoIR/SCServer.cpp index 70c36595..30b0b2e9 100644 --- a/FaceTrackNoIR/SCServer.cpp +++ b/FaceTrackNoIR/SCServer.cpp @@ -123,7 +123,7 @@ importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; // Write the 6DOF-data to FSX // if (S_OK == simconnect_set6DOF(hSimConnect, virtPosX, virtPosY, virtPosZ, virtRotX, virtRotZ, virtRotY)) { - qDebug() << "SCServer::run() says: SimConnect data written!"; +// qDebug() << "SCServer::run() says: SimConnect data written!"; } // just for lower cpu load @@ -147,7 +147,7 @@ bool SCServer::SCCheckClientDLL() ULONG_PTR ulCookie; - qDebug() << "FTCheckClientDLL says: Starting Function"; + qDebug() << "SCCheckClientDLL says: Starting Function"; try { @@ -166,7 +166,7 @@ bool SCServer::SCCheckClientDLL() if (hctx != INVALID_HANDLE_VALUE) { if (!ActivateActCtx(hctx, &ulCookie)) { ReleaseActCtx(hctx); - QMessageBox::information(0, "FaceTrackNoIR error", "SimConnect DLL not found!"); + qDebug() << "FTCheckClientDLL says: Error activating SimConnect manifest"; } } else { @@ -184,7 +184,7 @@ bool SCServer::SCCheckClientDLL() // SCClientLib.setFileName(aFileName); if (SCClientLib.load() != true) { - QMessageBox::information(0, "FaceTrackNoIR error", SCClientLib.errorString()); + qDebug() << "FTCheckClientDLL says: Error loading SimConnect DLL"; return false; } diff --git a/FaceTrackNoIR/SCServer.h b/FaceTrackNoIR/SCServer.h index 568cfe77..e694463d 100644 --- a/FaceTrackNoIR/SCServer.h +++ b/FaceTrackNoIR/SCServer.h @@ -29,6 +29,7 @@ // #define SIMCONNECT_H_NOMANIFEST #include "Windows.h" +#include #include "SimConnect.h" #include #include @@ -39,7 +40,6 @@ #include #include #include -#include typedef HRESULT (WINAPI *importSimConnect_Open)(HANDLE * phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex); typedef HRESULT (WINAPI *importSimConnect_Close)(HANDLE hSimConnect); @@ -84,13 +84,13 @@ public: static float virtRotY; static float virtRotZ; - static void setVirtRotX(float rot) { virtRotX = rot; } // degrees - static void setVirtRotY(float rot) { virtRotY = rot; } + static void setVirtRotX(float rot) { virtRotX = -1.0f * rot; } // degrees + static void setVirtRotY(float rot) { virtRotY = -1.0f * rot; } static void setVirtRotZ(float rot) { virtRotZ = rot; } - static void setVirtPosX(float pos) { virtPosX = pos/100.f; } // cm to meters + static void setVirtPosX(float pos) { virtPosX = pos/100.f; } // cm to meters static void setVirtPosY(float pos) { virtPosY = pos/100.f; } - static void setVirtPosZ(float pos) { virtPosZ = pos/100.f; } + static void setVirtPosZ(float pos) { virtPosZ = -1.0f * pos/100.f; } }; diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 1eeb2c88..374b45b2 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -23,6 +23,7 @@ *********************************************************************************/ /* Modifications (last one on top): + 20101021 - WVR: Added FSUIPC server for FS2004. 20101011 - WVR: Added SimConnect server. 20101007 - WVR: Created 6DOF-curves and drastically changed the tracker for that. Also eliminated a 'glitch' in the process. @@ -102,6 +103,7 @@ Tracker::Tracker( int clientID ) { server_PPJoy = 0; server_FTIR = 0; server_SC = 0; + server_FSUIPC = 0; switch (selectedClient) { case FREE_TRACK: server_FT = new FTServer; // Create Free-track protocol-server @@ -126,6 +128,10 @@ Tracker::Tracker( int clientID ) { server_SC = new SCServer; // Create SimConnect protocol-server break; + case FSUIPC: + server_FSUIPC = new FSUIPCServer; // Create FSUIPC protocol-server + break; + default: // should never be reached break; @@ -154,6 +160,10 @@ Tracker::~Tracker() { server_SC->deleteLater(); } + if (server_FSUIPC) { + server_FSUIPC->deleteLater(); + } + // Trigger thread to stop ::SetEvent(m_StopThread); @@ -238,12 +248,22 @@ void Tracker::setup(QWidget *head, FaceTrackNoIR *parent) { server_SC->start(); // Start the thread } else { - QMessageBox::information(0, "FaceTrackNoIR error", "This SimConnect version is not installed!"); + QMessageBox::information(mainApp, "FaceTrackNoIR error", "SimConnect is not (correctly) installed!"); + } + } + + // + // Check if the FSUIPC DLL is available, load it if so. + // + if (server_FSUIPC) { + DLL_Ok = server_FSUIPC->CheckClientDLL(); + + if (DLL_Ok) { + server_FSUIPC->start(); // Start the thread + } + else { + QMessageBox::information(mainApp, "FaceTrackNoIR error", "FSUIPC is not (correctly) installed!"); } - ////else { - //// server_SC->~SCServer(); - //// server_SC = 0; - ////} } } @@ -390,6 +410,9 @@ void Tracker::run() { // to substract that later... // if(Tracker::set_initial == false) { + Tracker::Pitch.initial_headPos = Tracker::Pitch.headPos; + Tracker::Yaw.initial_headPos = Tracker::Yaw.headPos; + Tracker::Roll.initial_headPos = Tracker::Roll.headPos; Tracker::X.initial_headPos = Tracker::X.headPos; Tracker::Y.initial_headPos = Tracker::Y.headPos; Tracker::Z.initial_headPos = Tracker::Z.headPos; @@ -397,10 +420,10 @@ void Tracker::run() { Tracker::set_initial = true; } - rawrotX = Tracker::Pitch.headPos; // degrees - rawrotY = Tracker::Yaw.headPos; - rawrotZ = Tracker::Roll.headPos; - rawposX = Tracker::X.headPos; // centimeters + rawrotX = Tracker::Pitch.headPos- Tracker::Pitch.initial_headPos; // degrees + rawrotY = Tracker::Yaw.headPos- Tracker::Yaw.initial_headPos; + rawrotZ = Tracker::Roll.headPos - Tracker::Roll.initial_headPos; + rawposX = Tracker::X.headPos - Tracker::X.initial_headPos; // centimeters rawposY = Tracker::Y.headPos - Tracker::Y.initial_headPos; rawposZ = Tracker::Z.headPos - Tracker::Z.initial_headPos; @@ -412,35 +435,19 @@ void Tracker::run() { headYLine->setText(QString("%1").arg( rawposY, 0, 'f', 1)); headZLine->setText(QString("%1").arg( rawposZ, 0, 'f', 1)); - - // - // Copy the Raw values directly to Free-track server - // - if (server_FT) { - //server_FT->setHeadRotX( rawrotX ); // degrees - //server_FT->setHeadRotY( rawrotY ); - //server_FT->setHeadRotZ( rawrotZ ); - - //server_FT->setHeadPosX( rawposX ); // meters - //server_FT->setHeadPosY( rawposY ); - //server_FT->setHeadPosZ( rawposZ ); - } } // // If Center is pressed, copy the current values to the offsets. // if (Tracker::do_center && Tracker::set_initial) { - Pitch.offset_headPos = getSmoothFromList( &Pitch.rawList ); - Yaw.offset_headPos = getSmoothFromList( &Yaw.rawList ); - Roll.offset_headPos = getSmoothFromList( &Roll.rawList ); - X.offset_headPos = getSmoothFromList( &X.rawList ); - - // - // Reset the initial distance to the camera - // + Pitch.offset_headPos = getSmoothFromList( &Pitch.rawList )- Tracker::Pitch.initial_headPos; + Yaw.offset_headPos = getSmoothFromList( &Yaw.rawList ) - Tracker::Yaw.initial_headPos; + Roll.offset_headPos = getSmoothFromList( &Roll.rawList ) - Tracker::Roll.initial_headPos; + X.offset_headPos = getSmoothFromList( &X.rawList ) - Tracker::X.initial_headPos; Y.offset_headPos = getSmoothFromList( &Y.rawList ) - Tracker::Y.initial_headPos; Z.offset_headPos = getSmoothFromList( &Z.rawList ) - Tracker::Z.initial_headPos; + Tracker::do_center = false; } @@ -456,31 +463,31 @@ void Tracker::run() { // Pitch if (Tracker::useFilter) { - rotX = lowPassFilter ( getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos, + rotX = lowPassFilter ( getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos - Pitch.initial_headPos, &Pitch.prevPos, dT, Tracker::Pitch.red ); } else { - rotX = getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos; + rotX = getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos - Pitch.initial_headPos; } rotX = Pitch.invert * getOutputFromCurve(&Pitch.curve, rotX, Pitch.NeutralZone, Pitch.MaxInput); // Yaw if (Tracker::useFilter) { - rotY = lowPassFilter ( getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos, + rotY = lowPassFilter ( getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos - Yaw.initial_headPos, &Yaw.prevPos, dT, Tracker::Yaw.red ); } else { - rotY = getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos; + rotY = getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos - Yaw.initial_headPos; } rotY = Yaw.invert * getOutputFromCurve(&Yaw.curve, rotY, Yaw.NeutralZone, Yaw.MaxInput); // Roll if (Tracker::useFilter) { - rotZ = lowPassFilter ( getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos, + rotZ = lowPassFilter ( getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos - Roll.initial_headPos, &Roll.prevPos, dT, Tracker::Roll.red ); } else { - rotZ = getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos; + rotZ = getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos - Roll.initial_headPos; } rotZ = Roll.invert * getOutputFromCurve(&Roll.curve, rotZ, Roll.NeutralZone, Roll.MaxInput); @@ -516,7 +523,7 @@ void Tracker::run() { // - // Also send the Virtual Pose to selected Protocol-Server + // Send the Virtual Pose to selected Protocol-Server // // Free-track if (server_FT) { @@ -581,6 +588,17 @@ void Tracker::run() { server_SC->setVirtPosZ ( posZ ); } + // FSUIPC + if (server_FSUIPC) { + server_FSUIPC->setVirtRotX ( rotX ); // degrees + server_FSUIPC->setVirtRotY ( rotY ); + server_FSUIPC->setVirtRotZ ( rotZ ); + + server_FSUIPC->setVirtPosX ( posX ); // centimeters + server_FSUIPC->setVirtPosY ( posY ); + server_FSUIPC->setVirtPosZ ( posZ ); + } + } else { // @@ -630,6 +648,15 @@ void Tracker::run() { server_SC->setVirtPosY ( 0.0f ); server_SC->setVirtPosZ ( 0.0f ); } + + if (server_FSUIPC) { + server_FSUIPC->setVirtRotX ( 0.0f ); + server_FSUIPC->setVirtRotY ( 0.0f ); + server_FSUIPC->setVirtRotZ ( 0.0f ); + server_FSUIPC->setVirtPosX ( 0.0f ); + server_FSUIPC->setVirtPosY ( 0.0f ); + server_FSUIPC->setVirtPosZ ( 0.0f ); + } } //for lower cpu load @@ -849,13 +876,12 @@ float sign; // Always return 0 inside the NeutralZone // Always return max. when input larger than expected // - if (fabs(input) < neutralzone) return 0.0f; if (fabs(input) > maxinput) return sign * curve->pointAtPercent(1.0).x(); // // Return the value, derived from the Bezier-curve // - return sign * curve->pointAtPercent((fabs(input) - neutralzone)/maxinput).x(); + return sign * curve->pointAtPercent((fabs(input))/maxinput).x(); } // @@ -899,7 +925,8 @@ QPointF point1, point2, point3, point4; getCurvePoints( &iniFile, "Yaw_", &point1, &point2, &point3, &point4, NeutralZone, sensYaw, 50, 180 ); QPainterPath newYawCurve; newYawCurve.moveTo( QPointF(0,0) ); - newYawCurve.cubicTo(point2, point3, point4); + newYawCurve.lineTo( point1 ); + newYawCurve.cubicTo(point2, point3, point4); Yaw.NeutralZone = point1.y(); // Get the Neutral Zone Yaw.MaxInput = point4.y(); // Get Maximum Input @@ -911,6 +938,7 @@ QPointF point1, point2, point3, point4; getCurvePoints( &iniFile, "Pitch_", &point1, &point2, &point3, &point4, NeutralZone, sensPitch, 50, 180 ); QPainterPath newPitchCurve; newPitchCurve.moveTo( QPointF(0,0) ); + newPitchCurve.lineTo( point1 ); newPitchCurve.cubicTo(point2, point3, point4); Pitch.NeutralZone = point1.y(); // Get the Neutral Zone @@ -921,6 +949,7 @@ QPointF point1, point2, point3, point4; getCurvePoints( &iniFile, "Roll_", &point1, &point2, &point3, &point4, NeutralZone, sensRoll, 50, 180 ); QPainterPath newRollCurve; newRollCurve.moveTo( QPointF(0,0) ); + newRollCurve.lineTo( point1 ); newRollCurve.cubicTo(point2, point3, point4); Roll.NeutralZone = point1.y(); // Get the Neutral Zone @@ -931,6 +960,7 @@ QPointF point1, point2, point3, point4; getCurvePoints( &iniFile, "X_", &point1, &point2, &point3, &point4, NeutralZone, sensX, 50, 180 ); QPainterPath newXCurve; newXCurve.moveTo( QPointF(0,0) ); + newXCurve.lineTo( point1 ); newXCurve.cubicTo(point2, point3, point4); X.NeutralZone = point1.y(); // Get the Neutral Zone @@ -941,6 +971,7 @@ QPointF point1, point2, point3, point4; getCurvePoints( &iniFile, "Y_", &point1, &point2, &point3, &point4, NeutralZone, sensY, 50, 180 ); QPainterPath newYCurve; newYCurve.moveTo( QPointF(0,0) ); + newYCurve.lineTo( point1 ); newYCurve.cubicTo(point2, point3, point4); Y.NeutralZone = point1.y(); // Get the Neutral Zone @@ -951,6 +982,7 @@ QPointF point1, point2, point3, point4; getCurvePoints( &iniFile, "Z_", &point1, &point2, &point3, &point4, NeutralZone, sensZ, 50, 180 ); QPainterPath newZCurve; newZCurve.moveTo( QPointF(0,0) ); + newZCurve.lineTo( point1 ); newZCurve.cubicTo(point2, point3, point4); Z.NeutralZone = point1.y(); // Get the Neutral Zone diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index a04b8ef4..8b7b13f1 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -41,6 +41,7 @@ #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) // include the DirectX Library files #pragma comment (lib, "dinput8.lib") @@ -64,7 +65,8 @@ enum FTNoIR_Client { FTNOIR = 2, PPJOY = 3, TRACKIR = 4, - SIMCONNECT = 5 + SIMCONNECT = 5, + FSUIPC = 6 }; class FaceTrackNoIR; // pre-define parent-class to avoid circular includes @@ -157,6 +159,7 @@ private: PPJoyServer *server_PPJoy; // PPJoy Server FTIRServer *server_FTIR; // Fake TIR Server SCServer *server_SC; // SimConnect Server + FSUIPCServer *server_FSUIPC; // FSUIPC Server protected: // qthread override run method -- cgit v1.2.3