From b785bbaf8ce50e0e11bd08e8818a613b5add66ed Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Sun, 24 Oct 2010 14:30:55 +0000 Subject: Axis inhibitor shortkey added. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@26 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR.suo | Bin 268288 -> 268288 bytes FaceTrackNoIR/FTNoIR_FSUIPCcontrols.ui | 11 ++ FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui | 214 +++++++++++++++++++++++++++--- FaceTrackNoIR/FaceTrackNoIR.cpp | 47 +++++++ FaceTrackNoIR/FaceTrackNoIR.ui | 4 +- FaceTrackNoIR/tracker.cpp | 55 +++++++- FaceTrackNoIR/tracker.h | 12 +- bin/FaceTrackNoIR.exe | Bin 667648 -> 684032 bytes 8 files changed, 316 insertions(+), 27 deletions(-) diff --git a/FaceTrackNoIR.suo b/FaceTrackNoIR.suo index b3bb6fca..bb4a4a07 100644 Binary files a/FaceTrackNoIR.suo and b/FaceTrackNoIR.suo differ diff --git a/FaceTrackNoIR/FTNoIR_FSUIPCcontrols.ui b/FaceTrackNoIR/FTNoIR_FSUIPCcontrols.ui index 7dc627b0..b6120378 100644 --- a/FaceTrackNoIR/FTNoIR_FSUIPCcontrols.ui +++ b/FaceTrackNoIR/FTNoIR_FSUIPCcontrols.ui @@ -115,6 +115,17 @@ + + + + + + The DLL should be placed in the Modules folder of MS Flight Simulator + + + + + diff --git a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui index f495d38a..02f2028f 100644 --- a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui +++ b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui @@ -6,8 +6,8 @@ 0 0 - 346 - 180 + 638 + 165 @@ -25,8 +25,8 @@ - - + + @@ -42,28 +42,46 @@ - + + + + 50 + 16777215 + + Shift - + + + + 50 + 16777215 + + Ctrl - + + + + 50 + 16777215 + + Alt - + @@ -79,39 +97,53 @@ - - - - - + Start/stop - + + + + 50 + 16777215 + + Shift - + + + + 50 + 16777215 + + Ctrl - + + + + 50 + 16777215 + + Alt - + @@ -121,6 +153,147 @@ + + + + Axis Inhibitor + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 90 + 0 + + + + + + + + + 50 + 16777215 + + + + Pitch + + + + + + + + 50 + 16777215 + + + + Yaw + + + + + + + + 50 + 16777215 + + + + Roll + + + + + + + + 30 + 16777215 + + + + X + + + + + + + + 30 + 16777215 + + + + Y + + + + + + + + 30 + 16777215 + + + + Z + + + + + + + Disables: + + + @@ -138,6 +311,13 @@ + + + + The axis inhibitor shortkey toggles the selected axis Off/On + + + diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 3f3d3018..8f26d08a 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -805,6 +805,7 @@ void FaceTrackNoIR::setIcon(int index) trayIcon->showMessage( "FaceTrackNoIR", ui.iconcomboBox->itemText(index)); } setWindowIcon(QIcon(QCoreApplication::applicationDirPath() + "/images/FaceTrackNoIR.ico")); + ui.btnShowServerControls->setIcon(icon); settingsDirty = true; @@ -999,6 +1000,19 @@ QWidget( parent , f) connect(ui.chkStartStopCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); connect(ui.chkStartStopAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.cbxInhibitKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); + connect(ui.chkInhibitShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + + // Also add events for the Axis-checkboxes + connect(ui.chkInhibitShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitYaw, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitRoll, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitX, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitY, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitZ, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + // // Clear the Lists with key-descriptions and keycodes and build the Lists // The strings will all be added to the ListBoxes for each Shortkey @@ -1137,6 +1151,7 @@ QWidget( parent , f) for ( int i = 0; i < stringList.size(); i++) { ui.cbxCenterKey->addItem(stringList.at(i)); ui.cbxStartStopKey->addItem(stringList.at(i)); + ui.cbxInhibitKey->addItem(stringList.at(i)); } // Load the settings from the current .INI-file @@ -1236,6 +1251,25 @@ int keyindex; ui.chkStartStopCtrl->setChecked (iniFile.value ( "Ctrl_StartStop", 0 ).toBool()); ui.chkStartStopAlt->setChecked (iniFile.value ( "Alt_StartStop", 0 ).toBool()); + // Axis-inhibitor key + keyindex = keyList.indexOf ( iniFile.value ( "Keycode_Inhibit", 1 ).toInt() ); + if ( keyindex > 0 ) { + ui.cbxInhibitKey->setCurrentIndex( keyindex ); + } + else { + ui.cbxInhibitKey->setCurrentIndex( 0 ); + } + ui.chkInhibitShift->setChecked (iniFile.value ( "Shift_Inhibit", 0 ).toBool()); + ui.chkInhibitCtrl->setChecked (iniFile.value ( "Ctrl_Inhibit", 0 ).toBool()); + ui.chkInhibitAlt->setChecked (iniFile.value ( "Alt_Inhibit", 0 ).toBool()); + + ui.chkInhibitPitch->setChecked (iniFile.value ( "Inhibit_Pitch", 0 ).toBool()); + ui.chkInhibitYaw->setChecked (iniFile.value ( "Inhibit_Yaw", 0 ).toBool()); + ui.chkInhibitRoll->setChecked (iniFile.value ( "Inhibit_Roll", 0 ).toBool()); + ui.chkInhibitX->setChecked (iniFile.value ( "Inhibit_X", 0 ).toBool()); + ui.chkInhibitY->setChecked (iniFile.value ( "Inhibit_Y", 0 ).toBool()); + ui.chkInhibitZ->setChecked (iniFile.value ( "Inhibit_Z", 0 ).toBool()); + iniFile.endGroup (); settingsDirty = false; @@ -1264,6 +1298,19 @@ void KeyboardShortcutDialog::save() { iniFile.setValue ( "Shift_StartStop", ui.chkStartStopShift->isChecked() ); iniFile.setValue ( "Ctrl_StartStop", ui.chkStartStopCtrl->isChecked() ); iniFile.setValue ( "Alt_StartStop", ui.chkStartStopAlt->isChecked() ); + + iniFile.setValue ( "Keycode_Inhibit", keyList.at( ui.cbxInhibitKey->currentIndex() ) ); + iniFile.setValue ( "Shift_Inhibit", ui.chkInhibitShift->isChecked() ); + iniFile.setValue ( "Ctrl_Inhibit", ui.chkInhibitCtrl->isChecked() ); + iniFile.setValue ( "Alt_Inhibit", ui.chkInhibitAlt->isChecked() ); + + iniFile.setValue ( "Inhibit_Pitch", ui.chkInhibitPitch->isChecked() ); + iniFile.setValue ( "Inhibit_Yaw", ui.chkInhibitYaw->isChecked() ); + iniFile.setValue ( "Inhibit_Roll", ui.chkInhibitRoll->isChecked() ); + iniFile.setValue ( "Inhibit_X", ui.chkInhibitX->isChecked() ); + iniFile.setValue ( "Inhibit_Y", ui.chkInhibitY->isChecked() ); + iniFile.setValue ( "Inhibit_Z", ui.chkInhibitZ->isChecked() ); + iniFile.endGroup (); settingsDirty = false; diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index 3ef87463..74201bb0 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -892,7 +892,7 @@ color:#000; - 200 + 190 100 @@ -929,7 +929,7 @@ color:#000; 10 80 - 161 + 151 23 diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 4c6d619b..91cdaea2 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -23,6 +23,7 @@ *********************************************************************************/ /* Modifications (last one on top): + 20101024 - WVR: Added shortkey to disable/enable one or more axis during tracking. 20101021 - WVR: Added FSUIPC server for FS2004. 20101011 - WVR: Added SimConnect server. 20101007 - WVR: Created 6DOF-curves and drastically changed the tracker for that. @@ -50,6 +51,7 @@ bool Tracker::confid = false; bool Tracker::set_initial = false; bool Tracker::do_tracking = true; bool Tracker::do_center = false; +bool Tracker::do_inhibit = false; bool Tracker::useFilter = false; long Tracker::prevHeadPoseTime = 0; @@ -62,6 +64,7 @@ THeadPoseDOF Tracker::Z; TShortKey Tracker::CenterKey; // ShortKey to Center headposition TShortKey Tracker::StartStopKey; // ShortKey to Start/stop tracking +TShortKey Tracker::InhibitKey; // ShortKey to inhibit axis while tracking /** constructor **/ Tracker::Tracker( int clientID ) { @@ -275,8 +278,9 @@ void Tracker::run() { LPDIRECTINPUTDEVICE8 dinkeyboard; // the pointer to the keyboard device BYTE keystate[256]; // the storage for the key-information HRESULT retAcquire; - bool lastBackKey = false; // Remember state, to detect rising edge - bool lastEqualsKey = false; + bool lastCenterKey = false; // Remember state, to detect rising edge + bool lastStartStopKey = false; + bool lastInhibitKey = false; float rawrotX, rawrotY, rawrotZ; // Locals... float rawposX, rawposY, rawposZ; @@ -342,7 +346,7 @@ void Tracker::run() { // // Check the state of the Start/Stop key // - if ( isShortKeyPressed( &StartStopKey, &keystate[0] ) && (!lastBackKey) ) { + if ( isShortKeyPressed( &StartStopKey, &keystate[0] ) && (!lastStartStopKey) ) { Tracker::do_tracking = !Tracker::do_tracking; // @@ -374,16 +378,32 @@ void Tracker::run() { } qDebug() << "Tracker::run() says StartStop pressed, do_tracking =" << Tracker::do_tracking; } - lastBackKey = isShortKeyPressed( &StartStopKey, &keystate[0] ); // Remember + lastStartStopKey = isShortKeyPressed( &StartStopKey, &keystate[0] ); // Remember // // Check the state of the Center key // - if ( isShortKeyPressed( &CenterKey, &keystate[0] ) && (!lastEqualsKey) ) { + if ( isShortKeyPressed( &CenterKey, &keystate[0] ) && (!lastCenterKey) ) { Tracker::do_center = true; qDebug() << "Tracker::run() says Center pressed"; } - lastEqualsKey = isShortKeyPressed( &CenterKey, &keystate[0] ); // Remember + lastCenterKey = isShortKeyPressed( &CenterKey, &keystate[0] ); // Remember + + // + // Check the state of the Inhibit key + // + if ( isShortKeyPressed( &InhibitKey, &keystate[0] ) && (!lastInhibitKey) ) { + Tracker::do_inhibit = !Tracker::do_inhibit; + qDebug() << "Tracker::run() says Inhibit pressed"; + // + // Execute Center command too, when inhibition ends. + // + if (!Tracker::do_inhibit) { + Tracker::do_center = true; + } + } + lastInhibitKey = isShortKeyPressed( &InhibitKey, &keystate[0] ); // Remember + } } @@ -518,6 +538,17 @@ void Tracker::run() { } posZ = Z.invert * getOutputFromCurve(&Z.curve, posZ, Z.NeutralZone, Z.MaxInput); + // + // Reset value for the selected axis, if inhibition is active + // + if (Tracker::do_inhibit) { + if (InhibitKey.doPitch) rotX = 0.0f; + if (InhibitKey.doYaw) rotY = 0.0f; + if (InhibitKey.doRoll) rotZ = 0.0f; + if (InhibitKey.doX) posX = 0.0f; + if (InhibitKey.doY) posY = 0.0f; + if (InhibitKey.doZ) posZ = 0.0f; + } // // Send the Virtual Pose to selected Protocol-Server @@ -1005,6 +1036,18 @@ QPointF point1, point2, point3, point4; StartStopKey.ctrl = iniFile.value ( "Ctrl_StartStop", 0 ).toBool(); StartStopKey.alt = iniFile.value ( "Alt_StartStop", 0 ).toBool(); + // Inhibit key + InhibitKey.keycode = iniFile.value ( "Keycode_Inhibit", 0 ).toInt(); + InhibitKey.shift = iniFile.value ( "Shift_Inhibit", 0 ).toBool(); + InhibitKey.ctrl = iniFile.value ( "Ctrl_Inhibit", 0 ).toBool(); + InhibitKey.alt = iniFile.value ( "Alt_Inhibit", 0 ).toBool(); + InhibitKey.doPitch = iniFile.value ( "Inhibit_Pitch", 0 ).toBool(); + InhibitKey.doYaw = iniFile.value ( "Inhibit_Yaw", 0 ).toBool(); + InhibitKey.doRoll = iniFile.value ( "Inhibit_Roll", 0 ).toBool(); + InhibitKey.doX = iniFile.value ( "Inhibit_X", 0 ).toBool(); + InhibitKey.doY = iniFile.value ( "Inhibit_Y", 0 ).toBool(); + InhibitKey.doZ = iniFile.value ( "Inhibit_Z", 0 ).toBool(); + iniFile.endGroup (); } diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index 8b7b13f1..277c11ca 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -97,6 +97,12 @@ struct TShortKey { bool shift; // Modifiers to examine bool ctrl; bool alt; + bool doPitch; // Modifiers to act on axis + bool doYaw; + bool doRoll; + bool doX; + bool doY; + bool doZ; }; class Tracker : public QThread { @@ -132,12 +138,14 @@ private: static TShortKey CenterKey; // ShortKey to Center headposition static TShortKey StartStopKey; // ShortKey to Start/stop tracking + static TShortKey InhibitKey; // ShortKey to one or more axis during tracking // Flags to start/stop/reset tracking static bool confid; // Tracker data is OK static bool set_initial; // initial headpose is set - static bool do_tracking; // Start/stop tracking, using MINUS key on keyboard - static bool do_center; // Center head-position, using EQUALS key on keyboard + static bool do_tracking; // Start/stop tracking, using the shortkey + static bool do_center; // Center head-position, using the shortkey + static bool do_inhibit; // Inhibit DOF-axis, using the shortkey static bool useFilter; static long prevHeadPoseTime; // Time from previous sample diff --git a/bin/FaceTrackNoIR.exe b/bin/FaceTrackNoIR.exe index c8ae7003..de1532da 100644 Binary files a/bin/FaceTrackNoIR.exe and b/bin/FaceTrackNoIR.exe differ -- cgit v1.2.3