summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-10-20 08:09:08 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-10-20 08:09:08 +0200
commitfeb12bd0eecc9f09ef7a1ab7fc60858ea519edbe (patch)
tree5e2132290e27490d6878f442a6762b406934d503 /facetracknoir
parentf493c94a8d8e44efa9bfbccba81ae8016efb9fee (diff)
refactor 1/2 (?)
Diffstat (limited to 'facetracknoir')
-rw-r--r--facetracknoir/facetracknoir.cpp212
-rw-r--r--facetracknoir/facetracknoir.h44
-rw-r--r--facetracknoir/ftnoir_keyboardshortcuts.ui125
-rw-r--r--facetracknoir/shortcuts.cpp144
-rw-r--r--facetracknoir/shortcuts.h83
5 files changed, 142 insertions, 466 deletions
diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp
index 005e85f5..4c074e6e 100644
--- a/facetracknoir/facetracknoir.cpp
+++ b/facetracknoir/facetracknoir.cpp
@@ -28,23 +28,16 @@
FaceTrackNoIR::FaceTrackNoIR() : QMainWindow(nullptr),
b(bundle("opentrack-ui")),
s(b),
- #if defined(_WIN32)
- keybindingWorker(NULL),
- #else
- keyCenter(this),
- keyToggle(this),
- #endif
pose(std::vector<axis_opts*>{&s.a_x, &s.a_y, &s.a_z, &s.a_yaw, &s.a_pitch, &s.a_roll}),
timUpdateHeadPose(this),
kbd_quit(QKeySequence("Ctrl+Q"), this),
- no_feed_pixmap(":/uielements/no-feed.png"),
- module_list(dylib::enum_libraries())
+ no_feed_pixmap(":/uielements/no-feed.png")
{
ui.setupUi(this);
+
setFixedSize(size());
- ui.video_frame_label->setPixmap(no_feed_pixmap);
updateButtonState(false, false);
-
+ ui.video_frame_label->setPixmap(no_feed_pixmap);
QDir::setCurrent(QCoreApplication::applicationDirPath());
connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open()));
@@ -57,12 +50,17 @@ FaceTrackNoIR::FaceTrackNoIR() : QMainWindow(nullptr),
connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls()));
connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls()));
- filter_modules.push_back(nullptr);
+ modules.filters().push_back(nullptr);
ui.iconcomboFilter->addItem(QIcon(), "");
- fill_combobox(dylib::Tracker, module_list, tracker_modules, ui.iconcomboTrackerSource);
- fill_combobox(dylib::Protocol, module_list, protocol_modules, ui.iconcomboProtocol);
- fill_combobox(dylib::Filter, module_list, filter_modules, ui.iconcomboFilter);
+ for (auto x : modules.trackers())
+ ui.iconcomboTrackerSource->addItem(x->icon, x->name);
+
+ for (auto x : modules.protocols())
+ ui.iconcomboProtocol->addItem(x->icon, x->name);
+
+ for (auto x : modules.filters())
+ ui.iconcomboFilter->addItem(x->icon, x->name);
fill_profile_combobox();
@@ -72,15 +70,9 @@ FaceTrackNoIR::FaceTrackNoIR() : QMainWindow(nullptr),
connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker()));
connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker()));
-
connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int)));
+
connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose()));
-
-#ifndef _WIN32
- connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered()));
- connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled()));
-#endif
-
connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit()));
kbd_quit.setEnabled(true);
}
@@ -91,25 +83,6 @@ FaceTrackNoIR::~FaceTrackNoIR()
save();
}
-void FaceTrackNoIR::fill_combobox(dylib::Type t,
- QList<ptr<dylib>> list,
- QList<ptr<dylib>>& out_list,
- QComboBox* cbx)
-{
- for (auto x : list)
- {
- if (t == x->type)
- {
- cbx->addItem(x->icon, x->name);
- out_list.append(x);
- }
- }
-}
-
-QFrame* FaceTrackNoIR::video_frame() {
- return ui.video_frame;
-}
-
void FaceTrackNoIR::open() {
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::ExistingFile);
@@ -226,15 +199,27 @@ void FaceTrackNoIR::updateButtonState(bool running, bool inertialp)
ui.video_frame_label->setVisible(not_running || inertialp);
}
+void FaceTrackNoIR::bindKeyboardShortcuts()
+{
+ if (work)
+ work->sc = std::make_shared<Shortcuts>();
+}
+
void FaceTrackNoIR::startTracker( ) {
b->save();
loadSettings();
bindKeyboardShortcuts();
- // Tracker dtor needs run first
- tracker = nullptr;
+ // tracker dtor needs run first
+ work = nullptr;
- libs = SelectedLibraries(video_frame(), current_tracker(), current_protocol(), current_filter());
+ libs = SelectedLibraries(ui.video_frame, current_tracker(), current_protocol(), current_filter());
+ work = std::make_shared<Work>(s, pose, libs, this);
+
+ {
+ double p[6] = {0,0,0, 0,0,0};
+ display_pose(p, p);
+ }
if (!libs.correct)
{
@@ -252,8 +237,6 @@ void FaceTrackNoIR::startTracker( ) {
ui.video_frame->show();
timUpdateHeadPose.start(50);
- tracker = std::make_shared<Tracker>(s, pose, libs);
- tracker->start();
// NB check valid since SelectedLibraries ctor called
// trackers take care of layout state updates
@@ -293,41 +276,53 @@ void FaceTrackNoIR::stopTracker( ) {
pFilterDialog = nullptr;
}
- tracker = nullptr;
+ work = nullptr;
libs = SelectedLibraries();
+
+ {
+ double p[6] = {0,0,0, 0,0,0};
+ display_pose(p, p);
+ }
updateButtonState(false, false);
}
-void FaceTrackNoIR::showHeadPose()
+void FaceTrackNoIR::display_pose(const double *mapped, const double *raw)
{
- double mapped[6], raw[6];
-
- tracker->get_raw_and_mapped_poses(mapped, raw);
-
ui.pose_display->rotateBy(mapped[Yaw], mapped[Roll], mapped[Pitch]);
if (mapping_widget)
mapping_widget->update();
+ double mapped_[6], raw_[6];
+
for (int i = 0; i < 6; i++)
{
- mapped[i] = (int) mapped[i];
- raw[i] = (int) raw[i];
+ mapped_[i] = (int) mapped[i];
+ raw_[i] = (int) raw[i];
}
- ui.lcdNumX->display(raw[TX]);
- ui.lcdNumY->display(raw[TY]);
- ui.lcdNumZ->display(raw[TZ]);
- ui.lcdNumRotX->display(raw[Yaw]);
- ui.lcdNumRotY->display(raw[Pitch]);
- ui.lcdNumRotZ->display(raw[Roll]);
+ ui.lcdNumX->display(raw_[TX]);
+ ui.lcdNumY->display(raw_[TY]);
+ ui.lcdNumZ->display(raw_[TZ]);
+ ui.lcdNumRotX->display(raw_[Yaw]);
+ ui.lcdNumRotY->display(raw_[Pitch]);
+ ui.lcdNumRotZ->display(raw_[Roll]);
+
+ ui.lcdNumOutputPosX->display(mapped_[TX]);
+ ui.lcdNumOutputPosY->display(mapped_[TY]);
+ ui.lcdNumOutputPosZ->display(mapped_[TZ]);
+ ui.lcdNumOutputRotX->display(mapped_[Yaw]);
+ ui.lcdNumOutputRotY->display(mapped_[Pitch]);
+ ui.lcdNumOutputRotZ->display(mapped_[Roll]);
+}
+
+void FaceTrackNoIR::showHeadPose()
+{
+ double mapped[6], raw[6];
+
+ work->tracker->get_raw_and_mapped_poses(mapped, raw);
- ui.lcdNumOutputPosX->display(mapped[TX]);
- ui.lcdNumOutputPosY->display(mapped[TY]);
- ui.lcdNumOutputPosZ->display(mapped[TZ]);
- ui.lcdNumOutputRotX->display(mapped[Yaw]);
- ui.lcdNumOutputRotY->display(mapped[Pitch]);
- ui.lcdNumOutputRotZ->display(mapped[Roll]);
+ display_pose(mapped, raw);
if (libs.pProtocol)
{
@@ -338,7 +333,7 @@ void FaceTrackNoIR::showHeadPose()
void FaceTrackNoIR::showTrackerSettings()
{
- ptr<dylib> lib = tracker_modules.value(ui.iconcomboTrackerSource->currentIndex(), nullptr);
+ ptr<dylib> lib = modules.trackers().value(ui.iconcomboTrackerSource->currentIndex(), nullptr);
if (lib) {
pTrackerDialog = ptr<ITrackerDialog>(reinterpret_cast<ITrackerDialog*>(lib->Dialog()));
@@ -349,7 +344,7 @@ void FaceTrackNoIR::showTrackerSettings()
}
void FaceTrackNoIR::showServerControls() {
- ptr<dylib> lib = protocol_modules.value(ui.iconcomboProtocol->currentIndex(), nullptr);
+ ptr<dylib> lib = modules.protocols().value(ui.iconcomboProtocol->currentIndex(), nullptr);
if (lib) {
pProtocolDialog = ptr<IProtocolDialog>(reinterpret_cast<IProtocolDialog*>(lib->Dialog()));
@@ -359,7 +354,7 @@ void FaceTrackNoIR::showServerControls() {
}
void FaceTrackNoIR::showFilterControls() {
- ptr<dylib> lib = filter_modules.value(ui.iconcomboFilter->currentIndex(), nullptr);
+ ptr<dylib> lib = modules.filters().value(ui.iconcomboFilter->currentIndex(), nullptr);
if (lib) {
pFilterDialog = ptr<IFilterDialog>(reinterpret_cast<IFilterDialog*>(lib->Dialog()));
@@ -369,9 +364,10 @@ void FaceTrackNoIR::showFilterControls() {
}
}
void FaceTrackNoIR::showKeyboardShortcuts() {
- shortcuts_widget = std::make_shared<KeyboardShortcutDialog>( this, this );
+ shortcuts_widget = std::make_shared<KeyboardShortcutDialog>();
shortcuts_widget->show();
shortcuts_widget->raise();
+ connect(shortcuts_widget.get(), SIGNAL(reload()), this, SLOT(bindKeyboardShortcuts()));
}
void FaceTrackNoIR::showCurveConfiguration() {
mapping_widget = std::make_shared<MapWidget>(pose, s, this);
@@ -394,86 +390,16 @@ void FaceTrackNoIR::profileSelected(int index)
loadSettings();
}
-#if !defined(_WIN32)
-void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, key_opts& k)
-{
- key.setShortcut(QKeySequence::fromString(""));
- key.setDisabled();
- const int idx = k.key_index;
- if (idx > 0)
- {
- QString seq(global_key_sequences.value(idx, ""));
- if (!seq.isEmpty())
- {
- if (k.shift)
- seq = "Shift+" + seq;
- if (k.alt)
- seq = "Alt+" + seq;
- if (k.ctrl)
- seq = "Ctrl+" + seq;
- key.setShortcut(QKeySequence::fromString(seq, QKeySequence::PortableText));
- key.setEnabled();
- } else {
- key.setDisabled();
- }
- }
-}
-#else
-static void bind_keyboard_shortcut(Key& key, key_opts& k)
-{
- int idx = k.key_index;
- 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 = k.shift;
- key.alt = k.alt;
- key.ctrl = k.ctrl;
- }
-}
-#endif
-
-void FaceTrackNoIR::bindKeyboardShortcuts()
-{
-#if !defined(_WIN32)
- bind_keyboard_shortcut(keyCenter, s.center_key);
- bind_keyboard_shortcut(keyToggle, s.toggle_key);
-#else
- bind_keyboard_shortcut(keyCenter, s.center_key);
- bind_keyboard_shortcut(keyToggle, s.toggle_key);
-#endif
- if (tracker) /* running already */
- {
-#if defined(_WIN32)
- if (keybindingWorker)
- {
- keybindingWorker->should_quit = true;
- keybindingWorker->wait();
- delete keybindingWorker;
- keybindingWorker = NULL;
- }
- keybindingWorker = new KeybindingWorker(*this, keyCenter, keyToggle);
- keybindingWorker->start();
-#endif
- }
-}
-
void FaceTrackNoIR::shortcutRecentered()
{
qDebug() << "Center";
- if (s.dingp)
- QApplication::beep();
- if (tracker)
- tracker->center();
+ if (work)
+ work->tracker->center();
}
void FaceTrackNoIR::shortcutToggled()
{
qDebug() << "Toggle";
- if (s.dingp)
- QApplication::beep();
- if (tracker)
- tracker->toggle_enabled();
+ if (work)
+ work->tracker->toggle_enabled();
}
diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h
index 32bf8239..13c2bb59 100644
--- a/facetracknoir/facetracknoir.h
+++ b/facetracknoir/facetracknoir.h
@@ -48,7 +48,8 @@
#include "opentrack/main-settings.hpp"
#include "opentrack/plugin-support.h"
#include "opentrack/tracker.h"
-#include "shortcuts.h"
+#include "opentrack/shortcuts.h"
+#include "opentrack/work.hpp"
#include "curve-config.h"
using namespace options;
@@ -59,70 +60,54 @@ class FaceTrackNoIR : public QMainWindow
public:
pbundle b;
main_settings s;
- ptr<Tracker> tracker;
-
- // XXX move kbd handling into class its own -sh 20141019
-#ifndef _WIN32
- void bind_keyboard_shortcut(QxtGlobalShortcut&, key_opts& k);
-#endif
private:
-#if defined(_WIN32)
- Key keyCenter;
- Key keyToggle;
- KeybindingWorker* keybindingWorker;
-#else
- QxtGlobalShortcut keyCenter;
- QxtGlobalShortcut keyToggle;
-#endif
// XXX move the shit outta the _widget_, establish a class
// for running tracker state, etc -sh 20141014
Mappings pose;
Ui::OpentrackUI ui;
+
QTimer timUpdateHeadPose;
SelectedLibraries libs;
- ptr<ITrackerDialog> pTrackerDialog;
- ptr<IProtocolDialog> pProtocolDialog;
- ptr<IFilterDialog> pFilterDialog;
+ ptr<Work> work;
ptr<KeyboardShortcutDialog> shortcuts_widget;
ptr<MapWidget> mapping_widget;
QShortcut kbd_quit;
QPixmap no_feed_pixmap;
-
- QList<ptr<dylib>> filter_modules;
- QList<ptr<dylib>> tracker_modules;
- QList<ptr<dylib>> protocol_modules;
-
- QList<ptr<dylib>> module_list;
+ ptr<IFilterDialog> pFilterDialog;
+ ptr<IProtocolDialog> pProtocolDialog;
+ ptr<ITrackerDialog> pTrackerDialog;
+ Modules modules;
// XXX this shit stinks -sh 20141004
// TODO move to separate class representing running tracker state
ptr<dylib> current_tracker()
{
- return tracker_modules.value(ui.iconcomboTrackerSource->currentIndex(), nullptr);
+ return modules.trackers().value(ui.iconcomboTrackerSource->currentIndex(), nullptr);
}
ptr<dylib> current_protocol()
{
- return protocol_modules.value(ui.iconcomboProtocol->currentIndex(), nullptr);
+ return modules.protocols().value(ui.iconcomboProtocol->currentIndex(), nullptr);
}
ptr<dylib> current_filter()
{
- return filter_modules.value(ui.iconcomboFilter->currentIndex(), nullptr);
+ return modules.filters().value(ui.iconcomboFilter->currentIndex(), nullptr);
}
void createIconGroupBox();
void loadSettings();
void updateButtonState(bool running, bool inertialp);
- void fill_combobox(dylib::Type t, QList<ptr<dylib>> list, QList<ptr<dylib> > &out_list, QComboBox* cbx);
void fill_profile_combobox();
- QFrame *video_frame();
+ void display_pose(const double* mapped, const double* raw);
+
public slots:
void shortcutRecentered();
void shortcutToggled();
+ void bindKeyboardShortcuts();
private slots:
void open();
void save();
@@ -146,5 +131,4 @@ public:
~FaceTrackNoIR();
void save_mappings();
void load_mappings();
- void bindKeyboardShortcuts();
};
diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui
index 245b503a..f576d8fb 100644
--- a/facetracknoir/ftnoir_keyboardshortcuts.ui
+++ b/facetracknoir/ftnoir_keyboardshortcuts.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>371</width>
- <height>125</height>
+ <width>415</width>
+ <height>143</height>
</rect>
</property>
<property name="sizePolicy">
@@ -30,6 +30,38 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
+ <item row="2" column="0">
+ <widget class="QLabel" name="textLabel2_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" 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="1" column="0">
+ <widget class="QLabel" name="textLabel2_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" 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="2" column="1">
<widget class="QCheckBox" name="chkToggleShift">
<property name="maximumSize">
@@ -59,22 +91,6 @@
</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="1" column="3">
<widget class="QCheckBox" name="chkCenterAlt">
<property name="maximumSize">
@@ -88,8 +104,8 @@
</property>
</widget>
</item>
- <item row="1" column="2">
- <widget class="QCheckBox" name="chkCenterCtrl">
+ <item row="2" column="2">
+ <widget class="QCheckBox" name="chkToggleCtrl">
<property name="maximumSize">
<size>
<width>50</width>
@@ -101,22 +117,6 @@
</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="0" column="4">
<widget class="QLabel" name="textLabel2_4">
<property name="sizePolicy">
@@ -136,15 +136,8 @@
</property>
</widget>
</item>
- <item row="4" column="3" colspan="2">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QCheckBox" name="chkToggleCtrl">
+ <item row="2" column="3">
+ <widget class="QCheckBox" name="chkToggleAlt">
<property name="maximumSize">
<size>
<width>50</width>
@@ -152,28 +145,19 @@
</size>
</property>
<property name="text">
- <string>Ctrl</string>
+ <string>Alt</string>
</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>
+ <item row="3" column="3" colspan="2">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
- <item row="2" column="3">
- <widget class="QCheckBox" name="chkToggleAlt">
+ <item row="1" column="2">
+ <widget class="QCheckBox" name="chkCenterCtrl">
<property name="maximumSize">
<size>
<width>50</width>
@@ -181,7 +165,7 @@
</size>
</property>
<property name="text">
- <string>Alt</string>
+ <string>Ctrl</string>
</property>
</widget>
</item>
@@ -198,10 +182,19 @@
</property>
</widget>
</item>
- <item row="3" column="0" colspan="2">
- <widget class="QCheckBox" name="ding">
- <property name="text">
- <string>Ding!</string>
+ <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>
diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp
deleted file mode 100644
index 53d67957..00000000
--- a/facetracknoir/shortcuts.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-#include "facetracknoir.h"
-#include "shortcuts.h"
-
-// XXX todo remove ref to ui class -sh 20141019
-
-KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent )
- : QWidget( parent, Qt::Dialog)
-{
- ui.setupUi( this );
-
- QPoint offsetpos(100, 100);
- this->move(parent->pos() + offsetpos);
-
- mainApp = ftnoir;
-
- connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
- connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
-
- 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));
- }
-
- tie_setting(mainApp->s.center_key.key_index, ui.cbxCenterKey);
- tie_setting(mainApp->s.center_key.alt, ui.chkCenterAlt);
- tie_setting(mainApp->s.center_key.shift, ui.chkCenterShift);
- tie_setting(mainApp->s.center_key.ctrl, ui.chkCenterCtrl);
-
- tie_setting(mainApp->s.toggle_key.key_index, ui.cbxToggleKey);
- tie_setting(mainApp->s.toggle_key.alt, ui.chkToggleAlt);
- tie_setting(mainApp->s.toggle_key.shift, ui.chkToggleShift);
- tie_setting(mainApp->s.toggle_key.ctrl, ui.chkToggleCtrl);
-
- tie_setting(mainApp->s.dingp, ui.ding);
-}
-
-void KeyboardShortcutDialog::doOK() {
- mainApp->b->save();
- this->close();
- if (mainApp->tracker)
- mainApp->bindKeyboardShortcuts();
-}
-
-void KeyboardShortcutDialog::doCancel() {
- mainApp->s.b->reload();
- close();
-}
-
-#if defined(_WIN32)
-#include <windows.h>
-
-KeybindingWorkerImpl::~KeybindingWorkerImpl() {
- if (dinkeyboard) {
- dinkeyboard->Unacquire();
- dinkeyboard->Release();
- }
- if (din)
- din->Release();
-}
-
-KeybindingWorkerImpl::KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter, Key keyToggle)
-: din(0), dinkeyboard(0), kCenter(keyCenter), kToggle(keyToggle), window(w), should_quit(true)
-{
- if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL) != DI_OK) {
- qDebug() << "setup DirectInput8 Creation failed!" << GetLastError();
- return;
- }
- if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL) != DI_OK) {
- din->Release();
- din = 0;
- qDebug() << "setup CreateDevice function failed!" << GetLastError();
- return;
- }
- if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) {
- qDebug() << "setup SetDataFormat function failed!" << GetLastError();
- dinkeyboard->Release();
- dinkeyboard = 0;
- din->Release();
- din = 0;
- return;
- }
-
- if (dinkeyboard->SetCooperativeLevel((HWND) window.winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) {
- dinkeyboard->Release();
- din->Release();
- din = 0;
- dinkeyboard = 0;
- qDebug() << "setup SetCooperativeLevel function failed!" << GetLastError();
- return;
- }
- if (dinkeyboard->Acquire() != DI_OK)
- {
- dinkeyboard->Release();
- din->Release();
- din = 0;
- dinkeyboard = 0;
- qDebug() << "setup dinkeyboard Acquire failed!" << GetLastError();
- return;
- }
- should_quit = false;
-}
-
-static bool isKeyPressed( const Key *key, const BYTE *keystate ) {
- bool shift;
- bool ctrl;
- bool alt;
-
- 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 (key->shift && !shift) return false;
- if (key->ctrl && !ctrl) return false;
- if (key->alt && !alt) return false;
-
- return true;
- }
- return false;
-}
-
-#define PROCESS_KEY(k, s) \
- if (isKeyPressed(&k, keystate) && (!k.ever_pressed ? (k.timer.start(), k.ever_pressed = true) : k.timer.restart() > 100)) \
- window.s();
-
-void KeybindingWorkerImpl::run() {
- BYTE keystate[256];
- while (!should_quit)
- {
- if (dinkeyboard->GetDeviceState(256, (LPVOID)keystate) != DI_OK) {
- qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError();
- Sleep(25);
- continue;
- }
-
- PROCESS_KEY(kCenter, shortcutRecentered);
- PROCESS_KEY(kToggle, shortcutToggled);
-
- Sleep(25);
- }
-}
-
-#else
-#endif
diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h
deleted file mode 100644
index 8e665211..00000000
--- a/facetracknoir/shortcuts.h
+++ /dev/null
@@ -1,83 +0,0 @@
-#pragma once
-#include <QWidget>
-#include <QElapsedTimer>
-#include <QThread>
-#include <QMessageBox>
-#include <QCheckBox>
-#include <QComboBox>
-#include <QSettings>
-#include "ui_ftnoir_keyboardshortcuts.h"
-
-class FaceTrackNoIR;
-
-class KeyboardShortcutDialog: public QWidget
-{
- Q_OBJECT
-public:
- KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent );
-private:
- Ui::UICKeyboardShortcutDialog ui;
- FaceTrackNoIR *mainApp;
-private slots:
- void doOK();
- void doCancel();
-};
-
-extern QList<QString> global_key_sequences;
-
-#if defined(_WIN32)
-extern QList<int> global_windows_key_sequences;
-# undef DIRECTINPUT_VERSION
-# define DIRECTINPUT_VERSION 0x0800
-# include <windows.h>
-# include <dinput.h>
-
-struct Key {
- BYTE keycode;
- bool shift;
- bool ctrl;
- bool alt;
- bool ever_pressed;
- QElapsedTimer timer;
-public:
- Key() : keycode(0), shift(false), ctrl(false), alt(false), ever_pressed(false)
- {
- }
-};
-#else
-typedef unsigned char BYTE;
-struct Key { int foo; };
-#endif
-
-#if defined(_WIN32)
-class KeybindingWorkerImpl {
-private:
- LPDIRECTINPUT8 din;
- LPDIRECTINPUTDEVICE8 dinkeyboard;
- Key kCenter;
- Key kToggle;
- FaceTrackNoIR& window;
-public:
- volatile bool should_quit;
- ~KeybindingWorkerImpl();
- KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter, Key keyToggle);
- void run();
-};
-#else
-class KeybindingWorkerImpl {
-public:
- KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter, Key keyToggle);
- void run() {}
-};
-#endif
-
-class KeybindingWorker : public QThread, public KeybindingWorkerImpl {
- Q_OBJECT
-public:
- KeybindingWorker(FaceTrackNoIR& w, Key keyCenter, Key keyToggle) : KeybindingWorkerImpl(w, keyCenter, keyToggle)
- {
- }
- void run() {
- KeybindingWorkerImpl::run();
- }
-};