From 511b934a97dc7f9765270de69864c7132e1c5b24 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Thu, 23 Sep 2010 07:10:44 +0000 Subject: Done clean-up after switch to VS2005 git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@17 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR/Debug/BuildLog.htm | Bin 21418 -> 24030 bytes FaceTrackNoIR/Debug/FTServer.obj | Bin 97250 -> 93596 bytes .../Debug/FaceTrackNoIR.exe.intermediate.manifest | 9 +- FaceTrackNoIR/Debug/main.obj | Bin 211997 -> 166199 bytes FaceTrackNoIR/Debug/moc_FTServer.obj | Bin 71664 -> 67454 bytes FaceTrackNoIR/Debug/moc_tracker.obj | Bin 151670 -> 160647 bytes FaceTrackNoIR/Debug/mt.dep | 2 +- FaceTrackNoIR/Debug/tracker.obj | Bin 176503 -> 321759 bytes FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui | 262 +++++++++++ FaceTrackNoIR/FTNoIR_Preferences.ui | 225 ++++++++++ FaceTrackNoIR/FaceTrackNoIR.cpp | 479 ++++++++++++++++++++- FaceTrackNoIR/FaceTrackNoIR.h | 59 ++- FaceTrackNoIR/FaceTrackNoIR.ui | 18 + FaceTrackNoIR/FaceTrackNoIR.vcproj | 114 +++-- .../FaceTrackNoIR.vcproj.VRIEND200810.Wim.user | 2 +- FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp | 10 +- .../GeneratedFiles/ui_FTNoIR_ppjoycontrols.h | 2 +- FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h | 17 +- FaceTrackNoIR/Readme_Update_20100716.txt | 35 ++ FaceTrackNoIR/Readme_Update_20100822.txt | 32 ++ FaceTrackNoIR/Release/BuildLog.htm | Bin 11096 -> 14636 bytes .../FaceTrackNoIR.exe.intermediate.manifest | 14 +- FaceTrackNoIR/Release/mt.dep | 2 +- FaceTrackNoIR/tracker.cpp | 94 +++- FaceTrackNoIR/tracker.h | 15 + 25 files changed, 1313 insertions(+), 78 deletions(-) create mode 100644 FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui create mode 100644 FaceTrackNoIR/FTNoIR_Preferences.ui create mode 100644 FaceTrackNoIR/Readme_Update_20100716.txt create mode 100644 FaceTrackNoIR/Readme_Update_20100822.txt (limited to 'FaceTrackNoIR') diff --git a/FaceTrackNoIR/Debug/BuildLog.htm b/FaceTrackNoIR/Debug/BuildLog.htm index 63f09efb..7c0bed45 100644 Binary files a/FaceTrackNoIR/Debug/BuildLog.htm and b/FaceTrackNoIR/Debug/BuildLog.htm differ diff --git a/FaceTrackNoIR/Debug/FTServer.obj b/FaceTrackNoIR/Debug/FTServer.obj index c6e20cde..ec5b2a12 100644 Binary files a/FaceTrackNoIR/Debug/FTServer.obj and b/FaceTrackNoIR/Debug/FTServer.obj differ diff --git a/FaceTrackNoIR/Debug/FaceTrackNoIR.exe.intermediate.manifest b/FaceTrackNoIR/Debug/FaceTrackNoIR.exe.intermediate.manifest index b11b677b..386d1d84 100644 --- a/FaceTrackNoIR/Debug/FaceTrackNoIR.exe.intermediate.manifest +++ b/FaceTrackNoIR/Debug/FaceTrackNoIR.exe.intermediate.manifest @@ -1,15 +1,8 @@ - - - - - - - - + diff --git a/FaceTrackNoIR/Debug/main.obj b/FaceTrackNoIR/Debug/main.obj index f39a7a55..337e15e3 100644 Binary files a/FaceTrackNoIR/Debug/main.obj and b/FaceTrackNoIR/Debug/main.obj differ diff --git a/FaceTrackNoIR/Debug/moc_FTServer.obj b/FaceTrackNoIR/Debug/moc_FTServer.obj index 62816af9..40b920e8 100644 Binary files a/FaceTrackNoIR/Debug/moc_FTServer.obj and b/FaceTrackNoIR/Debug/moc_FTServer.obj differ diff --git a/FaceTrackNoIR/Debug/moc_tracker.obj b/FaceTrackNoIR/Debug/moc_tracker.obj index 9ae82a22..f7e97e64 100644 Binary files a/FaceTrackNoIR/Debug/moc_tracker.obj and b/FaceTrackNoIR/Debug/moc_tracker.obj differ diff --git a/FaceTrackNoIR/Debug/mt.dep b/FaceTrackNoIR/Debug/mt.dep index 64ff72f8..944d12c9 100644 --- a/FaceTrackNoIR/Debug/mt.dep +++ b/FaceTrackNoIR/Debug/mt.dep @@ -1 +1 @@ -Manifest resource last updated at 16:41:51,47 on vr 09-04-2010 +Manifest resource last updated at 13:41:52.12 on vr 03-09-2010 diff --git a/FaceTrackNoIR/Debug/tracker.obj b/FaceTrackNoIR/Debug/tracker.obj index acd3b275..fdc49f4e 100644 Binary files a/FaceTrackNoIR/Debug/tracker.obj and b/FaceTrackNoIR/Debug/tracker.obj differ diff --git a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui new file mode 100644 index 00000000..435f22ee --- /dev/null +++ b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui @@ -0,0 +1,262 @@ + + + UICKeyboardShortcutDialog + + + + 0 + 0 + 346 + 180 + + + + PPJoy settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 0 + 0 + + + + Center + + + false + + + + + + + Shift + + + + + + + Ctrl + + + + + + + Alt + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + + + + Start/stop + + + + + + + Shift + + + + + + + Ctrl + + + + + + + Alt + + + + + + + + 90 + 0 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + (Shortkeys are activated after tracker 'Start') + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/FaceTrackNoIR/FTNoIR_Preferences.ui b/FaceTrackNoIR/FTNoIR_Preferences.ui new file mode 100644 index 00000000..63db7fbc --- /dev/null +++ b/FaceTrackNoIR/FTNoIR_Preferences.ui @@ -0,0 +1,225 @@ + + + UICPreferencesDialog + + + + 0 + 0 + 463 + 180 + + + + FaceTrackNoIR Preferences + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 0 + 0 + + + + Auto Minimize FaceTrackNoIR (0 = disable): + + + false + + + + + + + + + + 1000 + + + Qt::Horizontal + + + + + + + + + + 1000 + + + 5 + + + + + + + sec. (after 'Start') + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + slideAutoMinimizeTime + valueChanged(int) + spinAutoMinimizeTime + setValue(int) + + + 245 + 21 + + + 330 + 17 + + + + + spinAutoMinimizeTime + valueChanged(int) + slideAutoMinimizeTime + setValue(int) + + + 352 + 17 + + + 267 + 18 + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 8556eb5b..30ad25ef 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -38,9 +38,12 @@ QMainWindow(parent, flags) cameraDetected = false; _engine_controls = 0; _server_controls = 0; + _keyboard_shortcuts = 0; + _preferences = 0; tracker = 0; _display = 0; l = 0; + trayIcon = 0; setupFaceTrackNoIR(); } @@ -59,6 +62,9 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { connect(ui.actionSave_As, SIGNAL(triggered()), this, SLOT(saveAs())); connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(exit())); + connect(ui.actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences())); + connect(ui.actionKeyboard_Shortcuts, SIGNAL(triggered()), this, SLOT(showKeyboardShortcuts())); + connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(about())); connect(ui.actionVideoWidget, SIGNAL(triggered()), this, SLOT(showVideoWidget())); @@ -115,6 +121,10 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { //Load the tracker-settings, from the INI-file loadSettings(); trayIcon->show(); + + //Setup the timer for automatically minimizing after StartTracker. + timMinimizeFTN = new QTimer(this); + connect(timMinimizeFTN, SIGNAL(timeout()), this, SLOT(showMinimized())); } /** destructor stops the engine and quits the faceapi **/ @@ -442,6 +452,19 @@ void FaceTrackNoIR::startTracker( ) { // Update the camera-name, FaceAPI can only use the 1st one found! // GetCameraNameDX(); + + + // + // Get the TimeOut value for minimizing FaceTrackNoIR + // Only start the Timer if value > 0 + // + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + int timevalue = settings.value ( "AutoMinimizeTime", 0 ).toInt() * 1000; + + if (timevalue > 0) { + timMinimizeFTN->setSingleShot( true ); + timMinimizeFTN->start(timevalue); + } } /** stop tracking the face **/ @@ -668,6 +691,38 @@ void FaceTrackNoIR::showServerControls() { } } +/** toggles FaceTrackNoIR Preferences Dialog **/ +void FaceTrackNoIR::showPreferences() { + + // Create if new + if (!_preferences) + { + _preferences = new PreferencesDialog( this, Qt::Dialog ); + } + + // Show if already created + if (_preferences) { + _preferences->show(); + _preferences->raise(); + } +} + +/** toggles Server Controls Dialog **/ +void FaceTrackNoIR::showKeyboardShortcuts() { + + // Create if new + if (!_keyboard_shortcuts) + { + _keyboard_shortcuts = new KeyboardShortcutDialog( this, Qt::Dialog ); + } + + // Show if already created + if (_keyboard_shortcuts) { + _keyboard_shortcuts->show(); + _keyboard_shortcuts->raise(); + } +} + /** exit application **/ void FaceTrackNoIR::exit() { QCoreApplication::exit(0); @@ -696,8 +751,8 @@ void FaceTrackNoIR::createActions() minimizeAction = new QAction(tr("Mi&nimize"), this); connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide())); - maximizeAction = new QAction(tr("Ma&ximize"), this); - connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized())); + //maximizeAction = new QAction(tr("Ma&ximize"), this); + //connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized())); restoreAction = new QAction(tr("&Restore"), this); connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal())); @@ -711,17 +766,18 @@ void FaceTrackNoIR::createActions() // void FaceTrackNoIR::createTrayIcon() { - trayIconMenu = new QMenu(this); - trayIconMenu->addAction(minimizeAction); - trayIconMenu->addAction(maximizeAction); - trayIconMenu->addAction(restoreAction); - trayIconMenu->addSeparator(); - trayIconMenu->addAction(quitAction); + if (QSystemTrayIcon::isSystemTrayAvailable()) { + trayIconMenu = new QMenu(this); + trayIconMenu->addAction(minimizeAction); + trayIconMenu->addAction(restoreAction); + trayIconMenu->addSeparator(); + trayIconMenu->addAction(quitAction); - trayIcon = new QSystemTrayIcon(this); - trayIcon->setContextMenu(trayIconMenu); + trayIcon = new QSystemTrayIcon(this); + trayIcon->setContextMenu(trayIconMenu); - trayIcon->setIcon(QIcon(QCoreApplication::applicationDirPath() + "/images/FaceTrackNoIR.ico")); + trayIcon->setIcon(QIcon(QCoreApplication::applicationDirPath() + "/images/FaceTrackNoIR.ico")); + } } // @@ -730,10 +786,14 @@ void FaceTrackNoIR::createTrayIcon() void FaceTrackNoIR::setIcon(int index) { QIcon icon = ui.iconcomboBox->itemIcon(index); - trayIcon->setIcon(icon); + if (trayIcon != 0) { + trayIcon->setIcon(icon); + trayIcon->setToolTip(ui.iconcomboBox->itemText(index)); + trayIcon->show(); + trayIcon->showMessage( "FaceTrackNoIR", ui.iconcomboBox->itemText(index)); + } setWindowIcon(QIcon(QCoreApplication::applicationDirPath() + "/images/FaceTrackNoIR.ico")); - trayIcon->setToolTip(ui.iconcomboBox->itemText(index)); settingsDirty = true; // Enable/disable Protocol-server Settings @@ -795,3 +855,396 @@ void FaceTrackNoIR::trackingSourceSelected(int index) break; } } + + +// +// Constructor for FaceTrackNoIR=Preferences-dialog +// +PreferencesDialog::PreferencesDialog( 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.slideAutoMinimizeTime, SIGNAL(valueChanged(int)), this, SLOT(keyChanged(int))); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +PreferencesDialog::~PreferencesDialog() { + qDebug() << "~PreferencesDialog() says: started"; +} + +// +// OK clicked on server-dialog +// +void PreferencesDialog::doOK() { + save(); + this->close(); +} + +// override show event +void PreferencesDialog::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void PreferencesDialog::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 PreferencesDialog::loadSettings() { + + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + ui.slideAutoMinimizeTime->setValue( settings.value ( "AutoMinimizeTime", 0 ).toInt() ); + + settingsDirty = false; + +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void PreferencesDialog::save() { + + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + settings.setValue( "AutoMinimizeTime", ui.slideAutoMinimizeTime->value() ); + + settingsDirty = false; +} + +// +// Constructor for server-settings-dialog +// +KeyboardShortcutDialog::KeyboardShortcutDialog( 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.cbxCenterKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); + connect(ui.chkCenterShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkCenterCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkCenterAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + + connect(ui.cbxStartStopKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); + connect(ui.chkStartStopShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkStartStopCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkStartStopAlt, 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 + // + stringList.clear(); + stringList.append("NONE"); + stringList.append("F1"); + stringList.append("F2"); + stringList.append("F3"); + stringList.append("F4"); + stringList.append("F5"); + stringList.append("F6"); + stringList.append("F7"); + stringList.append("F8"); + stringList.append("F9"); + stringList.append("F10"); + stringList.append("F11"); + stringList.append("F12"); + stringList.append("MINUS"); + stringList.append("EQUALS"); + stringList.append("BACK"); + stringList.append("A"); + stringList.append("B"); + stringList.append("C"); + stringList.append("D"); + stringList.append("E"); + stringList.append("F"); + stringList.append("G"); + stringList.append("H"); + stringList.append("I"); + stringList.append("J"); + stringList.append("K"); + stringList.append("L"); + stringList.append("M"); + stringList.append("N"); + stringList.append("O"); + stringList.append("P"); + stringList.append("Q"); + stringList.append("R"); + stringList.append("S"); + stringList.append("T"); + stringList.append("U"); + stringList.append("V"); + stringList.append("W"); + stringList.append("X"); + stringList.append("Y"); + stringList.append("Z"); + stringList.append("NUMPAD0"); + stringList.append("NUMPAD1"); + stringList.append("NUMPAD2"); + stringList.append("NUMPAD3"); + stringList.append("NUMPAD4"); + stringList.append("NUMPAD5"); + stringList.append("NUMPAD6"); + stringList.append("NUMPAD7"); + stringList.append("NUMPAD8"); + stringList.append("NUMPAD9"); + stringList.append("HOME"); + stringList.append("UP"); + stringList.append("PGUP"); /* PgUp on arrow keypad */ + stringList.append("LEFT"); + stringList.append("RIGHT"); + stringList.append("END"); + stringList.append("DOWN"); + stringList.append("PGDWN"); /* PgDn on arrow keypad */ + stringList.append("INSERT"); + stringList.append("DELETE"); + + keyList.clear(); + keyList.append(0); // NONE = 0 + keyList.append(DIK_F1); + keyList.append(DIK_F2); + keyList.append(DIK_F3); + keyList.append(DIK_F4); + keyList.append(DIK_F5); + keyList.append(DIK_F6); + keyList.append(DIK_F7); + keyList.append(DIK_F8); + keyList.append(DIK_F9); + keyList.append(DIK_F10); + keyList.append(DIK_F11); + keyList.append(DIK_F12); + keyList.append(DIK_MINUS); + keyList.append(DIK_EQUALS); + keyList.append(DIK_BACK); + keyList.append(DIK_A); + keyList.append(DIK_B); + keyList.append(DIK_C); + keyList.append(DIK_D); + keyList.append(DIK_E); + keyList.append(DIK_F); + keyList.append(DIK_G); + keyList.append(DIK_H); + keyList.append(DIK_I); + keyList.append(DIK_J); + keyList.append(DIK_K); + keyList.append(DIK_L); + keyList.append(DIK_M); + keyList.append(DIK_N); + keyList.append(DIK_O); + keyList.append(DIK_P); + keyList.append(DIK_Q); + keyList.append(DIK_R); + keyList.append(DIK_S); + keyList.append(DIK_T); + keyList.append(DIK_U); + keyList.append(DIK_V); + keyList.append(DIK_W); + keyList.append(DIK_X); + keyList.append(DIK_Y); + keyList.append(DIK_Z); + keyList.append(DIK_NUMPAD0); + keyList.append(DIK_NUMPAD1); + keyList.append(DIK_NUMPAD2); + keyList.append(DIK_NUMPAD3); + keyList.append(DIK_NUMPAD4); + keyList.append(DIK_NUMPAD5); + keyList.append(DIK_NUMPAD6); + keyList.append(DIK_NUMPAD7); + keyList.append(DIK_NUMPAD8); + keyList.append(DIK_NUMPAD9); + keyList.append(DIK_HOME); + keyList.append(DIK_UP); + keyList.append(DIK_PRIOR); /* PgUp on arrow keypad */ + keyList.append(DIK_LEFT); + keyList.append(DIK_RIGHT); + keyList.append(DIK_END); + keyList.append(DIK_DOWN); + keyList.append(DIK_NEXT); /* PgDn on arrow keypad */ + keyList.append(DIK_INSERT); + keyList.append(DIK_DELETE); + + // + // Add strings to the Listboxes. + // + for ( int i = 0; i < stringList.size(); i++) { + ui.cbxCenterKey->addItem(stringList.at(i)); + ui.cbxStartStopKey->addItem(stringList.at(i)); + } + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +KeyboardShortcutDialog::~KeyboardShortcutDialog() { + qDebug() << "~KeyboardShortcutDialog() says: started"; +} + +// +// OK clicked on server-dialog +// +void KeyboardShortcutDialog::doOK() { + save(); + this->close(); +} + +// override show event +void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void KeyboardShortcutDialog::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 KeyboardShortcutDialog::loadSettings() { +int keyindex; + + 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 ( "KB_Shortcuts" ); + + // Center key + keyindex = keyList.indexOf ( iniFile.value ( "Keycode_Center", 1 ).toInt() ); + if ( keyindex > 0 ) { + ui.cbxCenterKey->setCurrentIndex( keyindex ); + } + else { + ui.cbxCenterKey->setCurrentIndex( 0 ); + } + ui.chkCenterShift->setChecked (iniFile.value ( "Shift_Center", 0 ).toBool()); + ui.chkCenterCtrl->setChecked (iniFile.value ( "Ctrl_Center", 0 ).toBool()); + ui.chkCenterAlt->setChecked (iniFile.value ( "Alt_Center", 0 ).toBool()); + + // Start/stop key + keyindex = keyList.indexOf ( iniFile.value ( "Keycode_StartStop", 1 ).toInt() ); + if ( keyindex > 0 ) { + ui.cbxStartStopKey->setCurrentIndex( keyindex ); + } + else { + ui.cbxStartStopKey->setCurrentIndex( 0 ); + } + ui.chkStartStopShift->setChecked (iniFile.value ( "Shift_StartStop", 0 ).toBool()); + ui.chkStartStopCtrl->setChecked (iniFile.value ( "Ctrl_StartStop", 0 ).toBool()); + ui.chkStartStopAlt->setChecked (iniFile.value ( "Alt_StartStop", 0 ).toBool()); + + iniFile.endGroup (); + + settingsDirty = false; + +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void KeyboardShortcutDialog::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 ( "KB_Shortcuts" ); + iniFile.setValue ( "Keycode_Center", keyList.at( ui.cbxCenterKey->currentIndex() ) ); + iniFile.setValue ( "Shift_Center", ui.chkCenterShift->isChecked() ); + iniFile.setValue ( "Ctrl_Center", ui.chkCenterCtrl->isChecked() ); + iniFile.setValue ( "Alt_Center", ui.chkCenterAlt->isChecked() ); + + iniFile.setValue ( "Keycode_StartStop", keyList.at( ui.cbxStartStopKey->currentIndex() ) ); + iniFile.setValue ( "Shift_StartStop", ui.chkStartStopShift->isChecked() ); + iniFile.setValue ( "Ctrl_StartStop", ui.chkStartStopCtrl->isChecked() ); + iniFile.setValue ( "Alt_StartStop", ui.chkStartStopAlt->isChecked() ); + iniFile.endGroup (); + + settingsDirty = false; +} diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index 70f3f08d..93160c48 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -35,6 +35,8 @@ #include #include "ui_FaceTrackNoIR.h" +#include "ui_FTNoIR_KeyboardShortcuts.h" +#include "ui_FTNoIR_Preferences.h" #include #include @@ -56,19 +58,21 @@ public: private: Ui::FaceTrackNoIRClass ui; Tracker *tracker; + QTimer *timMinimizeFTN; /** face api variables **/ VideoDisplayWidget *_display; QVBoxLayout *l; QWidget *_engine_controls; QWidget *_server_controls; + QWidget *_preferences; + QWidget *_keyboard_shortcuts; /** QT objects **/ QDialog aboutDialog; QDesktopWidget desktop; QAction *minimizeAction; - QAction *maximizeAction; QAction *restoreAction; QAction *quitAction; @@ -103,6 +107,8 @@ private: void showHeadPoseWidget(); void showEngineControls(); void showServerControls(); + void showPreferences(); + void showKeyboardShortcuts(); // sensibility sliders void setSensYaw( int sens ); @@ -140,4 +146,55 @@ private: void about(); }; +// Widget that has controls for FaceTrackNoIR Preferences. +class PreferencesDialog: public QWidget, public Ui::UICPreferencesDialog +{ + Q_OBJECT +public: + + explicit PreferencesDialog( QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~PreferencesDialog(); + void showEvent ( QShowEvent * event ); + +private: + Ui::UICPreferencesDialog ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + +private slots: + void doOK(); + void doCancel(); + void keyChanged( int index ) { settingsDirty = true; }; +}; + +// Widget that has controls for Keyboard shortcuts. +class KeyboardShortcutDialog: public QWidget, public Ui::UICKeyboardShortcutDialog +{ + Q_OBJECT +public: + + explicit KeyboardShortcutDialog( QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~KeyboardShortcutDialog(); + void showEvent ( QShowEvent * event ); + +private: + Ui::UICKeyboardShortcutDialog ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + QList stringList; // List of strings, that describe the keyboard-keys + QList keyList; // List of keys, with the values of the keyboard-keys + +private slots: + void doOK(); + void doCancel(); + void keyChanged( int index ) { settingsDirty = true; }; +}; + + #endif // FaceTrackNoIR_H diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index 01213b37..16c91108 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -2199,8 +2199,16 @@ background:none; + + + Options + + + + + @@ -2337,6 +2345,16 @@ background:none; Save As + + + Keyboard Shortcuts + + + + + Preferences + + diff --git a/FaceTrackNoIR/FaceTrackNoIR.vcproj b/FaceTrackNoIR/FaceTrackNoIR.vcproj index 32418646..b35e07b9 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.vcproj +++ b/FaceTrackNoIR/FaceTrackNoIR.vcproj @@ -1,12 +1,11 @@ + @@ -172,6 +175,9 @@ + @@ -232,7 +238,7 @@ @@ -243,7 +249,7 @@ @@ -258,7 +264,7 @@ @@ -269,7 +275,7 @@ @@ -284,7 +290,7 @@ @@ -295,7 +301,7 @@ @@ -314,7 +320,7 @@ @@ -325,7 +331,7 @@ @@ -344,7 +350,7 @@ @@ -355,7 +361,7 @@ @@ -378,7 +384,7 @@ @@ -389,7 +395,7 @@ @@ -408,7 +414,7 @@ @@ -419,7 +425,7 @@ @@ -457,6 +463,32 @@ /> + + + + + + + + @@ -483,6 +515,32 @@ /> + + + + + + + + @@ -534,10 +592,18 @@ RelativePath=".\GeneratedFiles\ui_FaceTrackNoIR.h" > + + + + diff --git a/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp b/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp index 85287b60..363370e6 100644 --- a/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/GeneratedFiles/qrc_FaceTrackNoIR.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Resource object code ** -** Created: Tue 29. Jun 20:59:33 2010 +** Created: Fri 3. Sep 13:27:15 2010 ** by: The Resource Compiler for Qt version 4.6.2 ** ** WARNING! All changes made in this file will be lost! @@ -10,7 +10,7 @@ #include static const unsigned char qt_resource_data[] = { - // C:/Users/Wim/Documents/Visual Studio 2008/Projects/FaceTrackNoIR/FaceTrackNoIR/images/Freetrack.ico + // C:/Users/Wim/Documents/Visual Studio 2005/Projects/FaceTrackNoIR/FaceTrackNoIR/images/Freetrack.ico 0x0,0x0,0x44,0x86, 0x0, 0x0,0x1,0x0,0x4,0x0,0x30,0x30,0x0,0x0,0x1,0x0,0x20,0x0,0xa8,0x25,0x0, @@ -1110,7 +1110,7 @@ static const unsigned char qt_resource_data[] = { 0x41,0x80,0x0,0x9c,0x41,0x80,0x0,0x9c,0x41,0x80,0x0,0x9c,0x41,0x0,0x0,0x9c, 0x41,0x0,0x0,0x9c,0x41,0x0,0x0,0x9c,0x41,0x80,0x0,0x9c,0x41,0xc0,0x0,0x9c, 0x41,0xe0,0x1,0x9c,0x41, - // C:/Users/Wim/Documents/Visual Studio 2008/Projects/FaceTrackNoIR/FaceTrackNoIR/images/FaceTrackNoIR.ico + // C:/Users/Wim/Documents/Visual Studio 2005/Projects/FaceTrackNoIR/FaceTrackNoIR/images/FaceTrackNoIR.ico 0x0,0x0,0x5c,0x6, 0x0, 0x0,0x1,0x0,0x8,0x0,0x20,0x20,0x10,0x0,0x1,0x0,0x4,0x0,0xe8,0x2,0x0, @@ -2586,7 +2586,7 @@ static const unsigned char qt_resource_data[] = { 0x41,0x0,0x0,0x9c,0x41,0x0,0x0,0x9c,0x41,0x0,0x0,0x9c,0x41,0x0,0x0,0x9c, 0x41,0x80,0x1,0x9c,0x41,0x80,0x1,0x9c,0x41,0xc0,0x3,0x9c,0x41,0xe0,0x7,0x9c, 0x41,0xf8,0x1f,0x9c,0x41, - // C:/Users/Wim/Documents/Visual Studio 2008/Projects/FaceTrackNoIR/FaceTrackNoIR/images/SeeingMachines.ico + // C:/Users/Wim/Documents/Visual Studio 2005/Projects/FaceTrackNoIR/FaceTrackNoIR/images/SeeingMachines.ico 0x0,0x0,0x93,0xa6, 0x0, 0x0,0x1,0x0,0x4,0x0,0x80,0x80,0x0,0x0,0x1,0x0,0x8,0x0,0x28,0x4c,0x0, @@ -4952,7 +4952,7 @@ static const unsigned char qt_resource_data[] = { 0x41,0x80,0x1,0x9c,0x41,0x80,0x1,0x9c,0x41,0x80,0x1,0x9c,0x41,0x80,0x1,0x9c, 0x41,0x80,0x1,0x9c,0x41,0x80,0x1,0x9c,0x41,0x80,0x1,0x9c,0x41,0x80,0x1,0x9c, 0x41,0xff,0xff,0x9c,0x41, - // C:/Users/Wim/Documents/Visual Studio 2008/Projects/FaceTrackNoIR/FaceTrackNoIR/images/FlightGear.ico + // C:/Users/Wim/Documents/Visual Studio 2005/Projects/FaceTrackNoIR/FaceTrackNoIR/images/FlightGear.ico 0x0,0x0,0x33,0x26, 0x0, 0x0,0x1,0x0,0x4,0x0,0x40,0x40,0x0,0x0,0x1,0x0,0x8,0x0,0x28,0x16,0x0, diff --git a/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h b/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h index b361c21e..bb1e60c8 100644 --- a/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h +++ b/FaceTrackNoIR/GeneratedFiles/ui_FTNoIR_ppjoycontrols.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'FTNoIR_ppjoycontrols.ui' ** -** Created: Tue 29. Jun 20:59:28 2010 +** Created: Fri 3. Sep 13:27:15 2010 ** by: Qt User Interface Compiler version 4.6.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! diff --git a/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h b/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h index b4200594..32f64a21 100644 --- a/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h +++ b/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'FaceTrackNoIR.ui' ** -** Created: Tue 29. Jun 20:59:30 2010 +** Created: Fri 3. Sep 13:27:15 2010 ** by: Qt User Interface Compiler version 4.6.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! @@ -52,6 +52,8 @@ public: QAction *actionMute; QAction *actionSave; QAction *actionSave_As; + QAction *actionKeyboard_Shortcuts; + QAction *actionPreferences; QWidget *centralWidget; QVBoxLayout *verticalLayout_2; QWidget *widgetTop; @@ -157,6 +159,7 @@ public: QMenu *menuFile; QMenu *menuAbout; QMenu *menuView; + QMenu *menuOptions; void setupUi(QMainWindow *FaceTrackNoIRClass) { @@ -279,6 +282,10 @@ public: actionSave->setObjectName(QString::fromUtf8("actionSave")); actionSave_As = new QAction(FaceTrackNoIRClass); actionSave_As->setObjectName(QString::fromUtf8("actionSave_As")); + actionKeyboard_Shortcuts = new QAction(FaceTrackNoIRClass); + actionKeyboard_Shortcuts->setObjectName(QString::fromUtf8("actionKeyboard_Shortcuts")); + actionPreferences = new QAction(FaceTrackNoIRClass); + actionPreferences->setObjectName(QString::fromUtf8("actionPreferences")); centralWidget = new QWidget(FaceTrackNoIRClass); centralWidget->setObjectName(QString::fromUtf8("centralWidget")); centralWidget->setMinimumSize(QSize(800, 500)); @@ -1094,6 +1101,8 @@ public: menuAbout->setAutoFillBackground(true); menuView = new QMenu(menuBar); menuView->setObjectName(QString::fromUtf8("menuView")); + menuOptions = new QMenu(menuBar); + menuOptions->setObjectName(QString::fromUtf8("menuOptions")); FaceTrackNoIRClass->setMenuBar(menuBar); QWidget::setTabOrder(iconcomboTrackerSource, btnStartTracker); QWidget::setTabOrder(btnStartTracker, btnStopTracker); @@ -1122,6 +1131,7 @@ public: menuBar->addAction(menuFile->menuAction()); menuBar->addAction(menuView->menuAction()); + menuBar->addAction(menuOptions->menuAction()); menuBar->addAction(menuAbout->menuAction()); menuFile->addAction(actionOpen); menuFile->addAction(actionSave); @@ -1131,6 +1141,8 @@ public: menuAbout->addAction(actionAbout); menuView->addAction(actionVideoWidget); menuView->addAction(actionHeadPoseWidget); + menuOptions->addAction(actionPreferences); + menuOptions->addAction(actionKeyboard_Shortcuts); retranslateUi(FaceTrackNoIRClass); QObject::connect(sensYaw, SIGNAL(valueChanged(int)), spinSensYaw, SLOT(setValue(int))); @@ -1198,6 +1210,8 @@ public: actionMute->setShortcut(QApplication::translate("FaceTrackNoIRClass", "Ctrl+M", 0, QApplication::UnicodeUTF8)); actionSave->setText(QApplication::translate("FaceTrackNoIRClass", "Save", 0, QApplication::UnicodeUTF8)); actionSave_As->setText(QApplication::translate("FaceTrackNoIRClass", "Save As", 0, QApplication::UnicodeUTF8)); + actionKeyboard_Shortcuts->setText(QApplication::translate("FaceTrackNoIRClass", "Keyboard Shortcuts", 0, QApplication::UnicodeUTF8)); + actionPreferences->setText(QApplication::translate("FaceTrackNoIRClass", "Preferences", 0, QApplication::UnicodeUTF8)); headRotYLine->setText(QApplication::translate("FaceTrackNoIRClass", "N/A", 0, QApplication::UnicodeUTF8)); headRotXLine->setText(QApplication::translate("FaceTrackNoIRClass", "N/A", 0, QApplication::UnicodeUTF8)); headRotZLine->setText(QApplication::translate("FaceTrackNoIRClass", "N/A", 0, QApplication::UnicodeUTF8)); @@ -1255,6 +1269,7 @@ public: menuFile->setTitle(QApplication::translate("FaceTrackNoIRClass", "File", 0, QApplication::UnicodeUTF8)); menuAbout->setTitle(QApplication::translate("FaceTrackNoIRClass", "About", 0, QApplication::UnicodeUTF8)); menuView->setTitle(QApplication::translate("FaceTrackNoIRClass", "View", 0, QApplication::UnicodeUTF8)); + menuOptions->setTitle(QApplication::translate("FaceTrackNoIRClass", "Options", 0, QApplication::UnicodeUTF8)); } // retranslateUi }; diff --git a/FaceTrackNoIR/Readme_Update_20100716.txt b/FaceTrackNoIR/Readme_Update_20100716.txt new file mode 100644 index 00000000..e99111a1 --- /dev/null +++ b/FaceTrackNoIR/Readme_Update_20100716.txt @@ -0,0 +1,35 @@ +FaceTrackNoIR (v. 20100716). + +From various users we received requests for improvements and features. If you keep sending us your ideas, we can keep +improving FaceTrackNoIR... + +Installation: +Unzip the .exe and .dll to the installation folder of FaceTrackNoIR (best rename the old .exe first). The folders in the ZIP-file contain icons for the protocols and an .INI-file (FreeFalcon). Extract these to the folder 'Settings' and 'Images'. + + +The following upgrades have been applied: + +- TrackIR support is added. Start FaceTrackNoIR and the TrackIR-protocol before starting the game (at least once).. + A registry-entry is added/changed, that the game or flightsim needs. + +Hints from the previous update: +- ‘=’ is center view + +- ‘BACKSPACE’ = start (+center)/stop tracking. A messagebeep is generated when tracking is resumed and the + headpose-data is valid again (faceAPI has 'locked on'... ). + + + +Please let us know what you think of our little gadget. Posts can be made on the FaceTrackNoIR forum on SourceForge +(http://sourceforge.net/projects/facetracknoir/forums/forum/1150910) or on the various game-forums. + +If anyone has used FaceTrackNoIR successfully with other games, please let us know. If you can, we would also like to receive +examples of the .INI-file you used for that and maybe settings of other utilities needed. Thanks! + + + +The FaceTrackNoIR team: + +Wim Vriend +Ron Hendriks + diff --git a/FaceTrackNoIR/Readme_Update_20100822.txt b/FaceTrackNoIR/Readme_Update_20100822.txt new file mode 100644 index 00000000..e121fe9f --- /dev/null +++ b/FaceTrackNoIR/Readme_Update_20100822.txt @@ -0,0 +1,32 @@ +FaceTrackNoIR (v. 20100822). + +From various users we received requests for improvements and features. If you keep sending us your ideas, we can keep +improving FaceTrackNoIR... + +Installation: +Unzip all files to the installation folder of FaceTrackNoIR (typicaly c:\program files\abbequerque inc\facetracknoir\): overwrite files when asked. + + +The following upgrades have been applied: + +- The program-menu now contains a Tools menu. Via this menu the program preferences and keyboard shortcuts can be modified. + +- The preferences dialog contains the 'Auto-minimize' setting: FaceTrackNoIR will minimize x sec. after starting the face-tracker. + Entering 0 will disable auto-minimize. This setting is global, for all INI-files. + +- The keyboard shortcuts for 'center' and 'start/stop' can be assigned here. These settings are stored in the INI-file. + + +Please let us know what you think of our little gadget. Posts can be made on the FaceTrackNoIR forum on SourceForge +(http://sourceforge.net/projects/facetracknoir/forums/forum/1150910) or on the various game-forums. + +If anyone has used FaceTrackNoIR successfully with other games, please let us know. If you can, we would also like to receive +examples of the .INI-file you used for that and maybe settings of other utilities needed. Thanks! + + + +The FaceTrackNoIR team: + +Wim Vriend +Ron Hendriks + diff --git a/FaceTrackNoIR/Release/BuildLog.htm b/FaceTrackNoIR/Release/BuildLog.htm index 09e7b3af..995147bd 100644 Binary files a/FaceTrackNoIR/Release/BuildLog.htm and b/FaceTrackNoIR/Release/BuildLog.htm differ diff --git a/FaceTrackNoIR/Release/FaceTrackNoIR.exe.intermediate.manifest b/FaceTrackNoIR/Release/FaceTrackNoIR.exe.intermediate.manifest index 2cc84e15..ca044622 100644 --- a/FaceTrackNoIR/Release/FaceTrackNoIR.exe.intermediate.manifest +++ b/FaceTrackNoIR/Release/FaceTrackNoIR.exe.intermediate.manifest @@ -1,17 +1,5 @@ - - - - - - - - - - - - @@ -19,7 +7,7 @@ - + diff --git a/FaceTrackNoIR/Release/mt.dep b/FaceTrackNoIR/Release/mt.dep index 7f6bad00..d9624085 100644 --- a/FaceTrackNoIR/Release/mt.dep +++ b/FaceTrackNoIR/Release/mt.dep @@ -1 +1 @@ -Manifest resource last updated at 9:54:44.39 on za 17-07-2010 +Manifest resource last updated at 13:08:32.52 on vr 10-09-2010 diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 4cbd4453..c7a2fadb 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -57,6 +57,9 @@ THeadPoseDOF Tracker::X; THeadPoseDOF Tracker::Y; THeadPoseDOF Tracker::Z; +TShortKey Tracker::CenterKey; // ShortKey to Center headposition +TShortKey Tracker::StartStopKey; // ShortKey to Start/stop tracking + /** constructor **/ Tracker::Tracker( int clientID ) { @@ -120,7 +123,8 @@ Tracker::Tracker( int clientID ) { // should never be reached break; } - + // Load the settings from the INI-file + loadSettings(); } /** destructor empty **/ @@ -267,6 +271,9 @@ void Tracker::run() { // Check event for stop thread if(::WaitForSingleObject(m_StopThread, 0) == WAIT_OBJECT_0) { + dinkeyboard->Unacquire(); // Unacquire keyboard + din->Release(); // Release DirectInput + // Set event ::SetEvent(m_WaitThread); return; @@ -289,7 +296,13 @@ void Tracker::run() { // // Check the state of the BACK key (= Start/Stop tracking) and EQUALS key (= Center) // - if ( (keystate[DIK_BACK] & 0x80) && (!lastBackKey) ) { + if ( isShortKeyPressed( &CenterKey, &keystate[0] ) ) { + qDebug() << "Tracker::run Shortkey Center pressed!" << GetLastError(); + } + // + // Check the state of the BACK key (= Start/Stop tracking) and EQUALS key (= Center) + // + if ( isShortKeyPressed( &StartStopKey, &keystate[0] ) && (!lastBackKey) ) { Tracker::do_tracking = !Tracker::do_tracking; // @@ -319,15 +332,15 @@ void Tracker::run() { else { _engine->stop(); } - qDebug() << "Tracker::run() says BACK pressed, do_tracking =" << Tracker::do_tracking; + qDebug() << "Tracker::run() says StartStop pressed, do_tracking =" << Tracker::do_tracking; } - lastBackKey = (keystate[DIK_BACK] & 0x80); // Remember + lastBackKey = isShortKeyPressed( &StartStopKey, &keystate[0] ); // Remember - if ( (keystate[DIK_EQUALS] & 0x80) && (!lastEqualsKey) ) { + if ( isShortKeyPressed( &CenterKey, &keystate[0] ) && (!lastEqualsKey) ) { Tracker::do_center = true; - qDebug() << "Tracker::run() says EQUALS pressed"; + qDebug() << "Tracker::run() says Center pressed"; } - lastEqualsKey = (keystate[DIK_EQUALS] & 0x80); // Remember + lastEqualsKey = isShortKeyPressed( &CenterKey, &keystate[0] ); // Remember } } @@ -478,7 +491,7 @@ void Tracker::run() { float rotX = getDegreesFromRads ( Tracker::Pitch.invert * Tracker::Pitch.sens * Pitch.newPos ); float rotY = getDegreesFromRads ( Tracker::Yaw.invert * Tracker::Yaw.sens * Yaw.newPos ); float rotZ = getDegreesFromRads ( Tracker::Roll.invert * Tracker::Roll.sens * Roll.newPos ); - qDebug() << "Tracker::run() says: virtRotX =" << rotX << " virtRotY =" << rotY; +// qDebug() << "Tracker::run() says: virtRotX =" << rotX << " virtRotY =" << rotY; server_FTIR->setVirtRotX ( rotX ); server_FTIR->setVirtRotY ( rotY ); @@ -749,4 +762,67 @@ float clamped_value = 0.0f; *oldvalue = clamped_value; return clamped_value; -} \ No newline at end of file +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void Tracker::loadSettings() { + + qDebug() << "Tracker::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 ( "KB_Shortcuts" ); + + // Center key + CenterKey.keycode = iniFile.value ( "Keycode_Center", 0 ).toInt(); + CenterKey.shift = iniFile.value ( "Shift_Center", 0 ).toBool(); + CenterKey.ctrl = iniFile.value ( "Ctrl_Center", 0 ).toBool(); + CenterKey.alt = iniFile.value ( "Alt_Center", 0 ).toBool(); + + // StartStop key + StartStopKey.keycode = iniFile.value ( "Keycode_StartStop", 0 ).toInt(); + StartStopKey.shift = iniFile.value ( "Shift_StartStop", 0 ).toBool(); + StartStopKey.ctrl = iniFile.value ( "Ctrl_StartStop", 0 ).toBool(); + StartStopKey.alt = iniFile.value ( "Alt_StartStop", 0 ).toBool(); + + iniFile.endGroup (); +} + +// +// Determine if the ShortKey (incl. CTRL, SHIFT and/or ALT) is pressed. +// +bool Tracker::isShortKeyPressed( TShortKey *key, BYTE *keystate ){ +bool shift; +bool ctrl; +bool alt; + + // + // First, check if the right key is pressed. If so, check the modifiers + // + if (keystate[key->keycode] & 0x80) { + shift = ( (keystate[DIK_LSHIFT] & 0x80) || (keystate[DIK_RSHIFT] & 0x80) ); + ctrl = ( (keystate[DIK_LCONTROL] & 0x80) || (keystate[DIK_RCONTROL] & 0x80) ); + alt = ( (keystate[DIK_LALT] & 0x80) || (keystate[DIK_RALT] & 0x80) ); + + // + // If one of the modifiers is needed and not pressed, return false. + // + if (key->shift && !shift) return false; + if (key->ctrl && !ctrl) return false; + if (key->alt && !alt) return false; + + // + // All is well! + // + return true; + } + else { + return false; + } +} diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index b535324f..0b0abe7f 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -83,6 +83,16 @@ struct THeadPoseDOF { float prevRawPos; // Previous Raw Position }; +// +// Structure to hold keycode and CTRL, SHIFT, ALT for shortkeys +// +struct TShortKey { + BYTE keycode; // Required Key + bool shift; // Modifiers to examine + bool ctrl; + bool alt; +}; + class Tracker : public QThread { Q_OBJECT @@ -114,6 +124,9 @@ private: static THeadPoseDOF Y; // Head-movement Y-direction (Up/Down) static THeadPoseDOF Z; // Head-movement Z-direction (To/From camera) + static TShortKey CenterKey; // ShortKey to Center headposition + static TShortKey StartStopKey; // ShortKey to Start/stop tracking + // Flags to start/stop/reset tracking static bool confid; // Tracker data is OK static bool set_initial; // initial headpose is set @@ -153,6 +166,8 @@ public: void registerHeadPoseCallback(); bool handleGameCommand ( int command ); QString getGameProgramName(); // Get the ProgramName from the game and display it. + void loadSettings(); // Load settings from the INI-file + bool isShortKeyPressed( TShortKey *key, BYTE *keystate ); QSharedPointer getEngine() { return _engine; }; // smEngineHandle getEngineHandle() { return _engine->handle(); }; -- cgit v1.2.3