summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-10-16 20:59:40 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-10-16 20:59:40 +0200
commit33ed4d75801d547572e4d3c55a4f459d28dcf646 (patch)
treec845392790b2eca5556432dfd75db6ddb4390078
parent8e988b5a8509cf811ababd8e49ce85aa4afe4da0 (diff)
parent015547df5de7dcfaa60bfa6f8ac30b1f9c91385a (diff)
New feature: tracker disablement on keystroke
Requested-by: Patrick Ruoff (c14) Reviewed-by: mm0zct (first commit) Untested on Win32! Not even compile-time-tested... Merge remote-tracking branch 'origin/feature/toggle-tracking-enabled-20131016'
-rw-r--r--facetracknoir/curve-config.cpp2
-rw-r--r--facetracknoir/curve-config.h4
-rw-r--r--facetracknoir/facetracknoir.cpp128
-rw-r--r--facetracknoir/facetracknoir.h11
-rw-r--r--facetracknoir/facetracknoir.ui270
-rw-r--r--facetracknoir/ftnoir_keyboardshortcuts.ui342
-rw-r--r--facetracknoir/main.cpp9
-rw-r--r--facetracknoir/shortcuts.cpp104
-rw-r--r--facetracknoir/shortcuts.h9
-rw-r--r--facetracknoir/tracker.cpp8
-rw-r--r--facetracknoir/tracker.h1
11 files changed, 397 insertions, 491 deletions
diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp
index 36caa5c0..117e5803 100644
--- a/facetracknoir/curve-config.cpp
+++ b/facetracknoir/curve-config.cpp
@@ -35,7 +35,7 @@ void CurveConfigurationDialog::doOK() {
}
// override show event
-void CurveConfigurationDialog::showEvent ( QShowEvent * event ) {
+void CurveConfigurationDialog::showEvent ( QShowEvent * ) {
loadSettings();
}
diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h
index d02f1587..a9073840 100644
--- a/facetracknoir/curve-config.h
+++ b/facetracknoir/curve-config.h
@@ -22,6 +22,6 @@ private:
private slots:
void doOK();
void doCancel();
- void curveChanged( bool change ) { settingsDirty = true; }
- void curveChanged( int change ) { settingsDirty = true; }
+ void curveChanged( bool ) { settingsDirty = true; }
+ void curveChanged( int ) { settingsDirty = true; }
};
diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp
index eb24b320..af630bea 100644
--- a/facetracknoir/facetracknoir.cpp
+++ b/facetracknoir/facetracknoir.cpp
@@ -91,11 +91,12 @@ static void fill_combobox(const QString& filter, QList<DynamicLibrary*>& list, Q
//
FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) :
QMainWindow(parent, flags),
- #if defined(_WIN32)
- keybindingWorker(NULL),
- #else
- keyCenter(0),
- #endif
+#if defined(_WIN32)
+ keybindingWorker(NULL),
+#else
+ keyCenter(this),
+ keyToggle(this),
+#endif
timUpdateHeadPose(this),
pTrackerDialog(NULL),
pSecondTrackerDialog(NULL),
@@ -181,6 +182,9 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) :
ui.lcdNumOutputRotX->setVisible(false);
ui.lcdNumOutputRotY->setVisible(false);
ui.lcdNumOutputRotZ->setVisible(false);
+
+ connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered()));
+ connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled()));
}
/** destructor stops the engine and quits the faceapi **/
@@ -544,7 +548,7 @@ void FaceTrackNoIR::startTracker( ) {
}
#if defined(_WIN32)
- keybindingWorker = new KeybindingWorker(*this, keyCenter);
+ keybindingWorker = new KeybindingWorker(*this, &keyCenter, &keyToggle);
keybindingWorker->start();
#endif
@@ -912,73 +916,97 @@ void FaceTrackNoIR::profileSelected(int index)
loadSettings();
}
-void FaceTrackNoIR::bindKeyboardShortcuts()
-{
- QSettings settings("opentrack"); // 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" );
- int idxCenter = iniFile.value("Key_index_Center", 0).toInt();
-
#if !defined(_WIN32)
- if (keyCenter) {
- delete keyCenter;
- keyCenter = NULL;
- }
-
- if (idxCenter > 0)
+void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile)
+{
+ const int idx = iniFile.value("Key_index_" + label, 0).toInt();
+ key.setShortcut(QKeySequence::fromString(""));
+ key.setDisabled();
+ QString seq(global_key_sequences.value(idx, ""));
+ if (idx > 0)
{
- QString seq(global_key_sequences.value(idxCenter, ""));
if (!seq.isEmpty())
{
- if (iniFile.value("Shift_Center", false).toBool())
+ if (iniFile.value(QString("Shift_%1").arg(label), false).toBool())
seq = "Shift+" + seq;
- if (iniFile.value("Alt_Center", false).toBool())
+ if (iniFile.value(QString("Alt_%1").arg(label), false).toBool())
seq = "Alt+" + seq;
- if (iniFile.value("Ctrl_Center", false).toBool())
+ if (iniFile.value(QString("Ctrl_%1").arg(label), false).toBool())
seq = "Ctrl+" + seq;
- keyCenter = new QxtGlobalShortcut(QKeySequence(seq), this);
- connect(keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered()));
+ key.setShortcut(QKeySequence::fromString(seq, QKeySequence::NativeText));
+ key.setEnabled();
}
}
+}
#else
- keyCenter.keycode = 0;
- keyCenter.shift = keyCenter.alt = keyCenter.ctrl = 0;
- if (idxCenter > 0 && idxCenter < global_windows_key_sequences.size())
- keyCenter.keycode = global_windows_key_sequences[idxCenter];
- keyCenter.shift = iniFile.value("Shift_Center", false).toBool();
- keyCenter.alt = iniFile.value("Alt_Center", false).toBool();
- keyCenter.ctrl = iniFile.value("Ctrl_Center", false).toBool();
+static void bind_keyboard_shotcut(Key& key, const QString label, QSettings& iniFile)
+{
+ const int idx = iniFile.value("Key_index_" + label, 0).toInt();
+ if (idx > 0)
+ {
+ key.keycode = 0;
+ key.shift = key.alt = key.ctrl = 0;
+ if (idx < global_windows_key_sequences.size())
+ key.keycode = global_windows_key_sequences[idx];
+ key.shift = iniFile.value(QString("Shift_").arg(label), false).toBool();
+ key.alt = iniFile.value(QString("Alt_").arg(label), false).toBool();
+ key.ctrl = iniFile.value(QString("Ctrl_").arg(label), false).toBool();
+ }
+}
#endif
- iniFile.endGroup ();
+
+void FaceTrackNoIR::bindKeyboardShortcuts()
+{
+ QSettings settings("opentrack"); // 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" );
+#if !defined(_WIN32)
+ bind_keyboard_shortcut(keyCenter, "Center", iniFile);
+ bind_keyboard_shortcut(keyToggle, "Toggle", iniFile);
+#else
+ bind_keyboard_shortcut(&keyCenter, "Center", iniFile));
+ bind_keyboard_shortcut(&keyToggle, "Toggle", iniFile));
+#endif
+ iniFile.endGroup ();
+
if (tracker) /* running already */
{
#if defined(_WIN32)
- if (keybindingWorker)
- {
- keybindingWorker->should_quit = true;
- keybindingWorker->wait();
- delete keybindingWorker;
- keybindingWorker = NULL;
- }
- keybindingWorker = new KeybindingWorker(*this, keyCenter);
- keybindingWorker->start();
+ if (keybindingWorker)
+ {
+ keybindingWorker->should_quit = true;
+ keybindingWorker->wait();
+ delete keybindingWorker;
+ keybindingWorker = NULL;
+ }
+ const int idx_center = iniFile.value("Key_index_Center", 0).toInt();
+ const int idx_toggle = iniFile.value("Key_index_Toggle", 0).toInt();
+ keybindingWorker = new KeybindingWorker(*this, keyCenter, keyToggle);
+ keybindingWorker->start();
#endif
}
}
void FaceTrackNoIR::shortcutRecentered()
{
+ QApplication::beep();
+
+ qDebug() << "Center";
if (tracker)
{
-#if defined(_WIN32)
- MessageBeep(MB_OK);
-#else
- QApplication::beep();
-#endif
- qDebug() << "Center";
tracker->do_center = true;
}
}
+
+void FaceTrackNoIR::shortcutToggled()
+{
+ QApplication::beep();
+ qDebug() << "Toggle";
+ if (tracker)
+ {
+ tracker->enabled = !tracker->enabled;
+ }
+}
diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h
index 6c087c43..bfeb2d38 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 keyCenter;
+ QxtGlobalShortcut keyToggle;
#endif
public slots:
void shortcutRecentered();
+ void shortcutToggled();
private:
HeadPoseData pose;
@@ -109,7 +112,6 @@ private:
IProtocolDialog* pProtocolDialog; // Pointer to Protocol dialog instance (in DLL)
IFilterDialog* pFilterDialog; // Pointer to Filter dialog instance (in DLL)
- /** Widget variables **/
QWidget *_keyboard_shortcuts;
QWidget *_curve_config;
@@ -117,12 +119,15 @@ private:
void GetCameraNameDX();
void loadSettings();
- void setupFaceTrackNoIR();
QList<DynamicLibrary*> dlopen_filters;
QList<DynamicLibrary*> dlopen_trackers;
QList<DynamicLibrary*> dlopen_protocols;
+#ifndef _WIN32
+ void bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile);
+#endif
+
bool looping;
private slots:
diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui
index 0578e2f6..2f35e29b 100644
--- a/facetracknoir/facetracknoir.ui
+++ b/facetracknoir/facetracknoir.ui
@@ -181,259 +181,6 @@ QGroupBox {
<height>419</height>
</size>
</property>
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>192</red>
- <green>192</green>
- <blue>192</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>72</red>
- <green>72</green>
- <blue>72</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>192</red>
- <green>192</green>
- <blue>192</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>72</red>
- <green>72</green>
- <blue>72</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>192</red>
- <green>192</green>
- <blue>192</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>72</red>
- <green>72</green>
- <blue>72</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
@@ -1464,7 +1211,6 @@ background:none;</string>
</property>
<property name="styleSheet">
<string notr="true">* {
- text-color: white;
color: white;
}
</string>
@@ -1727,8 +1473,7 @@ color:white;</string>
</rect>
</property>
<property name="styleSheet">
- <string notr="true">color: white;
-text-color: white;</string>
+ <string notr="true">color: white; </string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@@ -1750,19 +1495,6 @@ text-color: white;</string>
</property>
</widget>
</widget>
- <zorder>groupBox</zorder>
- <zorder>lcdNumZ</zorder>
- <zorder>lcdNumY</zorder>
- <zorder>label_8</zorder>
- <zorder>label_9</zorder>
- <zorder>lcdNumRotY</zorder>
- <zorder>label_4</zorder>
- <zorder>lcdNumRotX</zorder>
- <zorder>label_7</zorder>
- <zorder>lcdNumRotZ</zorder>
- <zorder>lcdNumX</zorder>
- <zorder>label_5</zorder>
- <zorder>label_6</zorder>
</widget>
<widget class="QWidget" name="widget4logo" native="true">
<property name="geometry">
diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui
index e70b7536..0bbd42ff 100644
--- a/facetracknoir/ftnoir_keyboardshortcuts.ui
+++ b/facetracknoir/ftnoir_keyboardshortcuts.ui
@@ -6,10 +6,53 @@
<rect>
<x>0</x>
<y>0</y>
- <width>289</width>
- <height>81</height>
+ <width>335</width>
+ <height>120</height>
</rect>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="HighlightedText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="HighlightedText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="HighlightedText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>141</red>
+ <green>143</green>
+ <blue>145</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
<property name="windowTitle">
<string>FaceTrackNoIR Keyboard and Mouse shortcuts</string>
</property>
@@ -26,8 +69,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 +100,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 +128,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="layoutWidget">
<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/main.cpp b/facetracknoir/main.cpp
index 5a52c034..cf7ff6fb 100644
--- a/facetracknoir/main.cpp
+++ b/facetracknoir/main.cpp
@@ -28,7 +28,6 @@
#include <QDesktopWidget>
#include <QDebug>
#include <QList>
-#include <QFont>
#if defined(_WIN32)
# include <windows.h>
@@ -40,14 +39,6 @@ int main(int argc, char** argv)
QApplication::setAttribute(Qt::AA_X11InitThreads, true);
QApplication app(argc, argv);
-#if 0
-
- QFont font;
- font.setFamily(font.defaultFamily());
- font.setPointSize(9);
- font.setStyleStrategy(QFont::PreferAntialias);
- app.setFont(font);
-#endif
FaceTrackNoIR w;
QDesktopWidget desktop;
diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp
index 43c1019d..1cd967e0 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,8 +39,7 @@ void KeyboardShortcutDialog::doOK() {
mainApp->bindKeyboardShortcuts();
}
-// override show event
-void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) {
+void KeyboardShortcutDialog::showEvent ( QShowEvent * ) {
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", "Toggle"
+ };
+
+ QComboBox* comboboxen[] = {
+ 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; m < MODIFIERS; m++)
+ {
+ boxen[i][m]->setChecked (iniFile.value ( QString("%1_%2").arg(modnames[m], keynames[i]), 0).toBool());
+ }
+ comboboxen[i]->setCurrentIndex(iniFile.value(QString("Key_index_%1").arg(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* comboboxen[] = {
+ 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,17 @@ 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++)
+ {
+ for (int m = 0; m < MODIFIERS; m++)
+ {
+ iniFile.setValue(QString("%1_%2").arg(modnames[m], keynames[i]), boxen[i][m]->isChecked());
+ }
+ iniFile.setValue(QString("Key_index_%1").arg(keynames[i]), comboboxen[i]->currentIndex());
+ }
+
+ iniFile.endGroup();
settingsDirty = false;
}
@@ -137,8 +196,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 +278,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..a98211a8 100644
--- a/facetracknoir/shortcuts.h
+++ b/facetracknoir/shortcuts.h
@@ -17,7 +17,7 @@ public:
explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent );
virtual ~KeyboardShortcutDialog();
- void showEvent ( QShowEvent * event );
+ void showEvent (QShowEvent *);
private:
Ui::UICKeyboardShortcutDialog ui;
@@ -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..53b3ffd3 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;
@@ -121,7 +122,7 @@ void Tracker::run() {
Libraries->pFilter->Initialize();
}
- if (confid) {
+ if (confid && enabled) {
// get values
for (int i = 0; i < 6; i++)
target_camera.axes[i] = mainApp->axis(i).headPos;
@@ -145,9 +146,7 @@ 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) {
gameoutput_camera = output_camera;
Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes, newpose ); // degrees & centimeters
@@ -155,7 +154,6 @@ void Tracker::run() {
}
}
- //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;
};