diff options
Diffstat (limited to 'facetracknoir')
-rw-r--r-- | facetracknoir/facetracknoir.cpp | 15 | ||||
-rw-r--r-- | facetracknoir/facetracknoir.h | 3 | ||||
-rw-r--r-- | facetracknoir/ftnoir_keyboardshortcuts.ui | 305 | ||||
-rw-r--r-- | facetracknoir/shortcuts.cpp | 103 | ||||
-rw-r--r-- | facetracknoir/shortcuts.h | 7 | ||||
-rw-r--r-- | facetracknoir/tracker.cpp | 8 | ||||
-rw-r--r-- | facetracknoir/tracker.h | 1 |
7 files changed, 283 insertions, 159 deletions
diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index eb24b320..dddcd4e4 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -95,6 +95,7 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : keybindingWorker(NULL), #else keyCenter(0), + keyToggle(0), #endif timUpdateHeadPose(this), pTrackerDialog(NULL), @@ -973,12 +974,18 @@ void FaceTrackNoIR::shortcutRecentered() { if (tracker) { -#if defined(_WIN32) - MessageBeep(MB_OK); -#else QApplication::beep(); -#endif qDebug() << "Center"; tracker->do_center = true; } } + +void FaceTrackNoIR::shortcutToggled() +{ + if (tracker) + { + QApplication::beep(); + qDebug() << "Toggle"; + tracker->enabled = !tracker->enabled; + } +} diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 6c087c43..8f510d78 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -91,12 +91,15 @@ public: #if defined(_WIN32) Key keyCenter; + Key keyToggle; KeybindingWorker* keybindingWorker; #else QxtGlobalShortcut* keyCenter; + QxtGlobalShortcut* keyToggle; #endif public slots: void shortcutRecentered(); + void shortcutToggled(); private: HeadPoseData pose; diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui index e70b7536..66ab004f 100644 --- a/facetracknoir/ftnoir_keyboardshortcuts.ui +++ b/facetracknoir/ftnoir_keyboardshortcuts.ui @@ -6,10 +6,16 @@ <rect>
<x>0</x>
<y>0</y>
- <width>289</width>
- <height>81</height>
+ <width>337</width>
+ <height>122</height>
</rect>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="windowTitle">
<string>FaceTrackNoIR Keyboard and Mouse shortcuts</string>
</property>
@@ -26,8 +32,8 @@ <widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
- <x>180</x>
- <y>50</y>
+ <x>120</x>
+ <y>90</y>
<width>100</width>
<height>23</height>
</rect>
@@ -57,8 +63,8 @@ <widget class="QPushButton" name="btnOK">
<property name="geometry">
<rect>
- <x>74</x>
- <y>50</y>
+ <x>230</x>
+ <y>90</y>
<width>100</width>
<height>23</height>
</rect>
@@ -85,131 +91,178 @@ <string>OK</string>
</property>
</widget>
- <widget class="QComboBox" name="cbxCenterKey">
- <property name="geometry">
- <rect>
- <x>179</x>
- <y>19</y>
- <width>101</width>
- <height>20</height>
- </rect>
- </property>
- <property name="minimumSize">
- <size>
- <width>90</width>
- <height>0</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Select Number</string>
- </property>
- <property name="insertPolicy">
- <enum>QComboBox::InsertAlphabetically</enum>
- </property>
- </widget>
- <widget class="QLabel" name="textLabel2_4">
- <property name="geometry">
- <rect>
- <x>210</x>
- <y>0</y>
- <width>46</width>
- <height>16</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Keyboard</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- </widget>
- <widget class="QCheckBox" name="chkCenterAlt">
- <property name="geometry">
- <rect>
- <x>141</x>
- <y>21</y>
- <width>36</width>
- <height>17</height>
- </rect>
- </property>
- <property name="maximumSize">
- <size>
- <width>50</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Alt</string>
- </property>
- </widget>
- <widget class="QLabel" name="textLabel2_3">
+ <widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>5</x>
- <y>23</y>
- <width>33</width>
- <height>16</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Center</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- </widget>
- <widget class="QCheckBox" name="chkCenterCtrl">
- <property name="geometry">
- <rect>
- <x>95</x>
- <y>21</y>
- <width>40</width>
- <height>17</height>
- </rect>
- </property>
- <property name="maximumSize">
- <size>
- <width>50</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Ctrl</string>
- </property>
- </widget>
- <widget class="QCheckBox" name="chkCenterShift">
- <property name="geometry">
- <rect>
- <x>44</x>
- <y>21</y>
- <width>45</width>
- <height>17</height>
+ <y>0</y>
+ <width>321</width>
+ <height>75</height>
</rect>
</property>
- <property name="maximumSize">
- <size>
- <width>50</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Shift</string>
- </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="4">
+ <widget class="QLabel" name="textLabel2_4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Keyboard</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel2_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Center</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="chkCenterShift">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Shift</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QCheckBox" name="chkCenterCtrl">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Ctrl</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QCheckBox" name="chkCenterAlt">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Alt</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QComboBox" name="cbxCenterKey">
+ <property name="minimumSize">
+ <size>
+ <width>90</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Select Number</string>
+ </property>
+ <property name="insertPolicy">
+ <enum>QComboBox::InsertAlphabetically</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="textLabel2_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Toggle</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="chkToggleShift">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Shift</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QCheckBox" name="chkToggleCtrl">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Ctrl</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QCheckBox" name="chkToggleAlt">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Alt</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <widget class="QComboBox" name="cbxToggleKey">
+ <property name="minimumSize">
+ <size>
+ <width>90</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Select Number</string>
+ </property>
+ <property name="insertPolicy">
+ <enum>QComboBox::InsertAlphabetically</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</widget>
<resources/>
diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 43c1019d..aae70bac 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -17,6 +17,7 @@ KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget * for ( int i = 0; i < global_key_sequences.size(); i++) { ui.cbxCenterKey->addItem(global_key_sequences.at(i)); + ui.cbxToggleKey->addItem(global_key_sequences.at(i)); } loadSettings(); @@ -38,7 +39,6 @@ void KeyboardShortcutDialog::doOK() { mainApp->bindKeyboardShortcuts(); } -// override show event void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) { loadSettings(); } @@ -76,11 +76,7 @@ void KeyboardShortcutDialog::doCancel() { } } -// -// Load the current Settings from the currently 'active' INI-file. -// void KeyboardShortcutDialog::loadSettings() { - qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); @@ -90,24 +86,82 @@ void KeyboardShortcutDialog::loadSettings() { iniFile.beginGroup ( "KB_Shortcuts" ); - 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()); + const char* names[] = { + "Center", "Togggle" + }; + + QComboBox* checkboxen[] = { + ui.cbxCenterKey, + ui.cbxToggleKey + }; + + QCheckBox* boxen[2][3] = { + { + ui.chkCenterShift, + ui.chkCenterCtrl, + ui.chkCenterAlt + }, + { + ui.chkToggleShift, + ui.chkToggleCtrl, + ui.chkToggleAlt + } + }; + + const char* modnames[] = { + "Shift", "Ctrl", "Alt" + }; + + const char* keynames[] = { + "Center", "Toggle" + }; - ui.cbxCenterKey->setCurrentIndex(iniFile.value("Key_index_Center", 0).toInt()); + const int KEY_COUNT = 2; + const int MODIFIERS = 3; + + for (int i = 0; i < KEY_COUNT; i++) + { + for (int m = 0; i < MODIFIERS; i++) + { + boxen[i][m]->setChecked (iniFile.value ( modnames[m] + QString("_") + QString(keynames[i]), 0 ).toBool()); + } + checkboxen[i]->setCurrentIndex(iniFile.value("Key_index_" + QString(names[i]), 0).toInt()); + } iniFile.endGroup (); settingsDirty = false; - } -// -// Save the current Settings to the currently 'active' INI-file. -// void KeyboardShortcutDialog::save() { + const char* keynames[] = { + "Center", "Toggle" + }; + + QComboBox* checkboxen[] = { + ui.cbxCenterKey, + ui.cbxToggleKey + }; + + const char* modnames[] = { + "Shift", "Ctrl", "Alt" + }; + + QCheckBox* boxen[2][3] = { + { + ui.chkCenterShift, + ui.chkCenterCtrl, + ui.chkCenterAlt + }, + { + ui.chkToggleShift, + ui.chkToggleCtrl, + ui.chkToggleAlt + } + }; - qDebug() << "save() says: started"; + const int MODIFIERS = 3; + const int KEY_COUNT = 2; QSettings settings("opentrack"); // Registry settings (in HK_USER) @@ -115,12 +169,18 @@ void KeyboardShortcutDialog::save() { QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "KB_Shortcuts" ); - iniFile.setValue ( "Key_index_Center", 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.endGroup (); + for (int i = 0; i < KEY_COUNT; i++) + { + iniFile.setValue ( "Key_index_" + QString(keynames[i]), + checkboxen[i]->currentIndex() ); + for (int m = 0; i < MODIFIERS; i++) + { + iniFile.setValue(modnames[m] + QString("_") + keynames[i], !!boxen[i][m]->isChecked()); + } + } + + iniFile.endGroup(); settingsDirty = false; } @@ -137,8 +197,8 @@ KeybindingWorkerImpl::~KeybindingWorkerImpl() { din->Release(); } -KeybindingWorkerImpl::KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter) -: din(0), dinkeyboard(0), kCenter(keyCenter), window(w), should_quit(true) +KeybindingWorkerImpl::KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter, Key keyToggle) +: din(0), dinkeyboard(0), kCenter(keyCenter), ktoggle(keyTogle), window(w), should_quit(true) { if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL) != DI_OK) { qDebug() << "setup DirectInput8 Creation failed!" << GetLastError(); @@ -219,6 +279,7 @@ void KeybindingWorkerImpl::run() { } PROCESS_KEY(kCenter, shortcutRecentered); + PROCESS_KEY(kToggle, shortcutToggled); Sleep(25); } diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h index 05c36520..9fd83af3 100644 --- a/facetracknoir/shortcuts.h +++ b/facetracknoir/shortcuts.h @@ -64,17 +64,18 @@ private: LPDIRECTINPUT8 din; LPDIRECTINPUTDEVICE8 dinkeyboard; Key kCenter; + Key kToggle; FaceTrackNoIR& window; public: volatile bool should_quit; ~KeybindingWorkerImpl(); - KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter); + KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter, Key keyToggle); void run(); }; #else class KeybindingWorkerImpl { public: - KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter); + KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter, Key keyToggle); void run() {} }; #endif @@ -82,7 +83,7 @@ public: class KeybindingWorker : public QThread, public KeybindingWorkerImpl { Q_OBJECT public: - KeybindingWorker(FaceTrackNoIR& w, Key keyCenter) : KeybindingWorkerImpl(w, keyCenter) + KeybindingWorker(FaceTrackNoIR& w, Key keyCenter, Key keyToggle) : KeybindingWorkerImpl(w, keyCenter, keyToggle) { } void run() { diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index b965140b..d1218098 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -31,7 +31,8 @@ /** constructor **/
Tracker::Tracker( FaceTrackNoIR *parent ) :
should_quit(false),
- do_center(false)
+ do_center(false),
+ enabled(true)
{
// Retieve the pointer to the parent
mainApp = parent;
@@ -145,17 +146,14 @@ void Tracker::run() { get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i));
}
- //
// Send the headpose to the game
- //
- if (Libraries->pProtocol) {
+ if (Libraries->pProtocol && enabled) {
gameoutput_camera = output_camera;
Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes, newpose ); // degrees & centimeters
}
}
}
- //for lower cpu load
msleep(8);
}
#if defined(_WIN32)
diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 885fc1e2..28f8dc99 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -108,6 +108,7 @@ public: volatile bool should_quit; // following are now protected by hTrackMutex volatile bool do_center; // Center head-position, using the shortkey + volatile bool enabled; T6DOF output_camera; }; |