diff options
Diffstat (limited to 'FaceTrackNoIR')
-rw-r--r-- | FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui | 217 | ||||
-rw-r--r-- | FaceTrackNoIR/FaceTrackNoIR.cpp | 35 | ||||
-rw-r--r-- | FaceTrackNoIR/FaceTrackNoIR.h | 1 | ||||
-rw-r--r-- | FaceTrackNoIR/FaceTrackNoIR.ui | 2 | ||||
-rw-r--r-- | FaceTrackNoIR/tracker.cpp | 136 | ||||
-rw-r--r-- | FaceTrackNoIR/tracker.h | 6 |
6 files changed, 359 insertions, 38 deletions
diff --git a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui index 783b2a0e..021c6ce6 100644 --- a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui +++ b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui @@ -6,12 +6,12 @@ <rect>
<x>0</x>
<y>0</y>
- <width>558</width>
- <height>415</height>
+ <width>672</width>
+ <height>438</height>
</rect>
</property>
<property name="windowTitle">
- <string>FaceTrackNoIR keyboard shortcuts</string>
+ <string>FaceTrackNoIR Keyboard and Mouse shortcuts</string>
</property>
<property name="windowIcon">
<iconset>
@@ -28,21 +28,21 @@ <layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout">
- <item row="3" column="6">
+ <item row="5" column="8">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Disables:</string>
</property>
</widget>
</item>
- <item row="2" column="6">
+ <item row="3" column="8">
<widget class="QLabel" name="label_5">
<property name="text">
<string>When OFF:</string>
</property>
</widget>
</item>
- <item row="0" column="0">
+ <item row="1" column="0">
<widget class="QLabel" name="textLabel2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@@ -58,14 +58,14 @@ </property>
</widget>
</item>
- <item row="3" column="0">
+ <item row="5" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Axis Inhibitor</string>
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item row="1" column="1">
<widget class="QCheckBox" name="chkCenterShift">
<property name="maximumSize">
<size>
@@ -78,7 +78,7 @@ </property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="3" column="1">
<widget class="QCheckBox" name="chkStartStopShift">
<property name="maximumSize">
<size>
@@ -91,7 +91,7 @@ </property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="5" column="1">
<widget class="QCheckBox" name="chkInhibitShift">
<property name="maximumSize">
<size>
@@ -104,7 +104,7 @@ </property>
</widget>
</item>
- <item row="0" column="2">
+ <item row="1" column="2">
<widget class="QCheckBox" name="chkCenterCtrl">
<property name="maximumSize">
<size>
@@ -117,7 +117,7 @@ </property>
</widget>
</item>
- <item row="2" column="2">
+ <item row="3" column="2">
<widget class="QCheckBox" name="chkStartStopCtrl">
<property name="maximumSize">
<size>
@@ -130,7 +130,7 @@ </property>
</widget>
</item>
- <item row="3" column="2">
+ <item row="5" column="2">
<widget class="QCheckBox" name="chkInhibitCtrl">
<property name="maximumSize">
<size>
@@ -143,7 +143,7 @@ </property>
</widget>
</item>
- <item row="2" column="3">
+ <item row="3" column="3">
<widget class="QCheckBox" name="chkStartStopAlt">
<property name="maximumSize">
<size>
@@ -156,7 +156,7 @@ </property>
</widget>
</item>
- <item row="3" column="3">
+ <item row="5" column="3">
<widget class="QCheckBox" name="chkInhibitAlt">
<property name="maximumSize">
<size>
@@ -169,7 +169,7 @@ </property>
</widget>
</item>
- <item row="0" column="4">
+ <item row="1" column="4">
<widget class="QComboBox" name="cbxCenterKey">
<property name="minimumSize">
<size>
@@ -185,7 +185,7 @@ </property>
</widget>
</item>
- <item row="2" column="4">
+ <item row="3" column="4">
<widget class="QComboBox" name="cbxStartStopKey">
<property name="minimumSize">
<size>
@@ -195,7 +195,7 @@ </property>
</widget>
</item>
- <item row="3" column="4">
+ <item row="5" column="4">
<widget class="QComboBox" name="cbxInhibitKey">
<property name="minimumSize">
<size>
@@ -205,7 +205,7 @@ </property>
</widget>
</item>
- <item row="3" column="7">
+ <item row="5" column="9">
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
@@ -278,7 +278,7 @@ </widget>
</widget>
</item>
- <item row="2" column="7">
+ <item row="3" column="9">
<widget class="QGroupBox" name="groupBox_2">
<property name="minimumSize">
<size>
@@ -320,7 +320,7 @@ </widget>
</widget>
</item>
- <item row="2" column="0">
+ <item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Start/stop</string>
@@ -330,7 +330,7 @@ </property>
</widget>
</item>
- <item row="3" column="8">
+ <item row="5" column="10">
<widget class="QGroupBox" name="groupBox_3">
<property name="styleSheet">
<string notr="true">color: rgb(0, 0, 0);</string>
@@ -397,7 +397,7 @@ </widget>
</widget>
</item>
- <item row="2" column="8">
+ <item row="3" column="10">
<widget class="QGroupBox" name="groupBox_4">
<property name="minimumSize">
<size>
@@ -439,7 +439,7 @@ </widget>
</widget>
</item>
- <item row="1" column="0">
+ <item row="2" column="0">
<widget class="QLabel" name="textLabel2_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@@ -455,7 +455,7 @@ </property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="2" column="1">
<widget class="QCheckBox" name="chkGameZeroShift">
<property name="maximumSize">
<size>
@@ -468,7 +468,7 @@ </property>
</widget>
</item>
- <item row="1" column="2">
+ <item row="2" column="2">
<widget class="QCheckBox" name="chkGameZeroCtrl">
<property name="maximumSize">
<size>
@@ -481,7 +481,7 @@ </property>
</widget>
</item>
- <item row="0" column="3">
+ <item row="1" column="3">
<widget class="QCheckBox" name="chkCenterAlt">
<property name="maximumSize">
<size>
@@ -494,7 +494,7 @@ </property>
</widget>
</item>
- <item row="1" column="3">
+ <item row="2" column="3">
<widget class="QCheckBox" name="chkGameZeroAlt">
<property name="maximumSize">
<size>
@@ -507,7 +507,7 @@ </property>
</widget>
</item>
- <item row="1" column="4">
+ <item row="2" column="4">
<widget class="QComboBox" name="cbxGameZeroKey">
<property name="minimumSize">
<size>
@@ -523,6 +523,165 @@ </property>
</widget>
</item>
+ <item row="0" column="4">
+ <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>Keyboard</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="6">
+ <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>Mouse</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="6">
+ <widget class="QComboBox" name="cbxCenterMouseKey">
+ <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="6">
+ <widget class="QComboBox" name="cbxGameZeroMouseKey">
+ <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="3" column="6">
+ <widget class="QComboBox" name="cbxStartStopMouseKey">
+ <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="5" column="6">
+ <widget class="QComboBox" name="cbxInhibitMouseKey">
+ <property name="minimumSize">
+ <size>
+ <width>90</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="5">
+ <widget class="Line" name="line_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="5">
+ <widget class="Line" name="line_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="5">
+ <widget class="Line" name="line_6">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="5">
+ <widget class="Line" name="line_7">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="7">
+ <widget class="Line" name="line_9">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="7">
+ <widget class="Line" name="line_8">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="7">
+ <widget class="Line" name="line_10">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="7">
+ <widget class="Line" name="line_11">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="Line" name="line_12">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
</layout>
diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 9c89c13a..d4549a10 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -23,6 +23,7 @@ *********************************************************************************/
/*
Modifications (last one on top):
+ 20120917 - WVR: Added Mouse-buttons to ShortKeys.
20120717 - WVR: FunctionConfig is now used for the Curves, instead of BezierConfig.
20120427 - WVR: The Protocol-code was already in separate DLLs, but the ListBox was still filled ´statically´. Now, a Dir() of the
EXE-folder is done, to locate Protocol-DLLs. The Icons were also moved to the DLLs
@@ -1530,16 +1531,19 @@ QWidget( parent , f) connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
connect(ui.cbxCenterKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int )));
+ connect(ui.cbxCenterMouseKey, 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.cbxGameZeroKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int )));
+ connect(ui.cbxGameZeroMouseKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int )));
connect(ui.chkGameZeroShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int)));
connect(ui.chkGameZeroCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int)));
connect(ui.chkGameZeroAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int)));
connect(ui.cbxStartStopKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int )));
+ connect(ui.cbxStartStopMouseKey, 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)));
@@ -1547,6 +1551,7 @@ QWidget( parent , f) connect(ui.radioSetEngineStop, SIGNAL(toggled(bool)), this, SLOT(keyChanged(bool)));
connect(ui.cbxInhibitKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int )));
+ connect(ui.cbxInhibitMouseKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int )));
connect(ui.chkInhibitShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int)));
connect(ui.chkInhibitCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int)));
connect(ui.chkInhibitAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int)));
@@ -1701,6 +1706,28 @@ QWidget( parent , f) ui.cbxInhibitKey->addItem(stringList.at(i));
}
+ //
+ // Clear the Lists with key-descriptions and keycodes and build the Lists
+ // The strings will all be added to the ListBoxes for each Shortkey
+ //
+ stringListMouse.clear();
+ stringListMouse.append("NONE");
+ stringListMouse.append("LEFT");
+ stringListMouse.append("RIGHT");
+ stringListMouse.append("MIDDLE");
+ stringListMouse.append("BACK");
+ stringListMouse.append("FORWARD");
+
+ //
+ // Add strings to the Listboxes.
+ //
+ for ( int i = 0; i < stringListMouse.size(); i++) {
+ ui.cbxCenterMouseKey->addItem(stringListMouse.at(i));
+ ui.cbxGameZeroMouseKey->addItem(stringListMouse.at(i));
+ ui.cbxStartStopMouseKey->addItem(stringListMouse.at(i));
+ ui.cbxInhibitMouseKey->addItem(stringListMouse.at(i));
+ }
+
// Load the settings from the current .INI-file
loadSettings();
}
@@ -1775,6 +1802,7 @@ int keyindex; iniFile.beginGroup ( "KB_Shortcuts" );
// Center key
+ ui.cbxCenterMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_Center", 0 ).toInt() );
keyindex = keyList.indexOf ( iniFile.value ( "Keycode_Center", 1 ).toInt() );
if ( keyindex > 0 ) {
ui.cbxCenterKey->setCurrentIndex( keyindex );
@@ -1787,6 +1815,7 @@ int keyindex; ui.chkCenterAlt->setChecked (iniFile.value ( "Alt_Center", 0 ).toBool());
// GameZero key
+ ui.cbxGameZeroMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_GameZero", 0 ).toInt() );
keyindex = keyList.indexOf ( iniFile.value ( "Keycode_GameZero", 1 ).toInt() );
if ( keyindex > 0 ) {
ui.cbxGameZeroKey->setCurrentIndex( keyindex );
@@ -1799,6 +1828,7 @@ int keyindex; ui.chkGameZeroAlt->setChecked (iniFile.value ( "Alt_GameZero", 0 ).toBool());
// Start/stop key
+ ui.cbxStartStopMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_StartStop", 0 ).toInt() );
keyindex = keyList.indexOf ( iniFile.value ( "Keycode_StartStop", 1 ).toInt() );
if ( keyindex > 0 ) {
ui.cbxStartStopKey->setCurrentIndex( keyindex );
@@ -1815,6 +1845,7 @@ int keyindex; ui.radioSetKeepTracking->setChecked(!ui.radioSetEngineStop->isChecked());
// Axis-inhibitor key
+ ui.cbxInhibitMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_Inhibit", 0 ).toInt() );
keyindex = keyList.indexOf ( iniFile.value ( "Keycode_Inhibit", 1 ).toInt() );
if ( keyindex > 0 ) {
ui.cbxInhibitKey->setCurrentIndex( keyindex );
@@ -1859,16 +1890,19 @@ void KeyboardShortcutDialog::save() { QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
iniFile.beginGroup ( "KB_Shortcuts" );
+ iniFile.setValue ( "MouseKey_Center", ui.cbxCenterMouseKey->currentIndex());
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 ( "MouseKey_GameZero", ui.cbxGameZeroMouseKey->currentIndex());
iniFile.setValue ( "Keycode_GameZero", keyList.at( ui.cbxGameZeroKey->currentIndex() ) );
iniFile.setValue ( "Shift_GameZero", ui.chkGameZeroShift->isChecked() );
iniFile.setValue ( "Ctrl_GameZero", ui.chkGameZeroCtrl->isChecked() );
iniFile.setValue ( "Alt_GameZero", ui.chkGameZeroAlt->isChecked() );
+ iniFile.setValue ( "MouseKey_StartStop", ui.cbxStartStopMouseKey->currentIndex());
iniFile.setValue ( "Keycode_StartStop", keyList.at( ui.cbxStartStopKey->currentIndex() ) );
iniFile.setValue ( "Shift_StartStop", ui.chkStartStopShift->isChecked() );
iniFile.setValue ( "Ctrl_StartStop", ui.chkStartStopCtrl->isChecked() );
@@ -1876,6 +1910,7 @@ void KeyboardShortcutDialog::save() { iniFile.setValue ( "SetZero", ui.radioSetZero->isChecked() );
iniFile.setValue ( "SetEngineStop", ui.radioSetEngineStop->isChecked() );
+ iniFile.setValue ( "MouseKey_Inhibit", ui.cbxInhibitMouseKey->currentIndex());
iniFile.setValue ( "Keycode_Inhibit", keyList.at( ui.cbxInhibitKey->currentIndex() ) );
iniFile.setValue ( "Shift_Inhibit", ui.chkInhibitShift->isChecked() );
iniFile.setValue ( "Ctrl_Inhibit", ui.chkInhibitCtrl->isChecked() );
diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index 789fa683..d2b9cdde 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -219,6 +219,7 @@ private: FaceTrackNoIR *mainApp;
QList<QString> stringList; // List of strings, that describe the keyboard-keys
QList<BYTE> keyList; // List of keys, with the values of the keyboard-keys
+ QList<QString> stringListMouse; // List of strings, that describe the mouse-keys
private slots:
void doOK();
diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index e1bd7c15..bd4356c3 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -2188,7 +2188,7 @@ background:none;</string> </action>
<action name="actionKeyboard_Shortcuts">
<property name="text">
- <string>Keyboard Shortcuts</string>
+ <string>Keyboard and Mouse Shortcuts</string>
</property>
</action>
<action name="actionPreferences">
diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 3a7eb4f9..e28fd7d7 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -23,6 +23,7 @@ *********************************************************************************/
/*
Modifications (last one on top):
+ 20120917 - WVR: Added Mouse-buttons to ShortKeys.
20120827 - WVR: Signal tracking = false to Curve-widget(s) when quitting run(). Also when Alternative Pitch curve is used.
20120805 - WVR: The FunctionConfig-widget is used to configure the Curves. It was tweaked some more, because the Accela filter now also
uses the Curve(s). ToDo: make the ranges configurable by the user. Development on the Toradex IMU makes us realize, that
@@ -102,15 +103,20 @@ THeadPoseDOF Tracker::X("X","", 50, 180); THeadPoseDOF Tracker::Y("Y","", 50, 180);
THeadPoseDOF Tracker::Z("Z","", 50, 180);
-TShortKey Tracker::CenterKey; // ShortKey to Center headposition
-TShortKey Tracker::StartStopKey; // ShortKey to Start/stop tracking
-TShortKey Tracker::InhibitKey; // ShortKey to inhibit axis while tracking
-TShortKey Tracker::GameZeroKey; // ShortKey to Set Game Zero
-//TShortKey Tracker::AxisReverseKey; // ShortKey to start/stop axis reverse while tracking
+TShortKey Tracker::CenterKey; // ShortKey to Center headposition
+TShortKey Tracker::StartStopKey; // ShortKey to Start/stop tracking
+TShortKey Tracker::InhibitKey; // ShortKey to inhibit axis while tracking
+TShortKey Tracker::GameZeroKey; // ShortKey to Set Game Zero
+//TShortKey Tracker::AxisReverseKey; // ShortKey to start/stop axis reverse while tracking
-//ITrackerPtr Tracker::pTracker; // Pointer to Tracker instance (in DLL)
-IProtocolPtr Tracker::pProtocol; // Pointer to Protocol instance (in DLL)
-IFilterPtr Tracker::pFilter; // Pointer to Filter instance (in DLL)
+int Tracker::CenterMouseKey; // ShortKey to Center headposition
+int Tracker::StartStopMouseKey; // ShortKey to Start/stop tracking
+int Tracker::InhibitMouseKey; // ShortKey to inhibit axis while tracking
+int Tracker::GameZeroMouseKey; // ShortKey to Set Game Zero
+
+//ITrackerPtr Tracker::pTracker; // Pointer to Tracker instance (in DLL)
+IProtocolPtr Tracker::pProtocol; // Pointer to Protocol instance (in DLL)
+IFilterPtr Tracker::pFilter; // Pointer to Filter instance (in DLL)
/** constructor **/
@@ -297,14 +303,25 @@ void Tracker::setup() { /** QThread run method @override **/
void Tracker::run() {
/** Direct Input variables **/
+//
+// The DirectX stuff was found here: http://www.directxtutorial.com/tutorial9/e-directinput/dx9e2.aspx
+//
LPDIRECTINPUT8 din; // the pointer to our DirectInput interface
LPDIRECTINPUTDEVICE8 dinkeyboard; // the pointer to the keyboard device
+LPDIRECTINPUTDEVICE8 dinmouse; // the pointer to the mouse device
BYTE keystate[256]; // the storage for the key-information
+DIMOUSESTATE mousestate; // the storage for the mouse-information
HRESULT retAcquire;
bool lastCenterKey = false; // Remember state, to detect rising edge
bool lastStartStopKey = false;
bool lastInhibitKey = false;
bool lastGameZeroKey = false;
+
+bool lastCenterMouseKey = false; // Remember state, to detect rising edge
+bool lastStartStopMouseKey = false;
+bool lastInhibitMouseKey = false;
+bool lastGameZeroMouseKey = false;
+
bool waitAxisReverse = false;
bool waitThroughZero = false;
double actualYaw = 0.0f;
@@ -343,16 +360,22 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL) != DI_OK) {
qDebug() << "Tracker::setup CreateDevice function failed!" << GetLastError();
}
+ // create the mouse device
+ din->CreateDevice(GUID_SysMouse, &dinmouse, NULL);
// set the data format to keyboard format
if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) {
qDebug() << "Tracker::setup SetDataFormat function failed!" << GetLastError();
}
+ // set the data format to mouse format
+ dinmouse->SetDataFormat(&c_dfDIMouse);
// set the control you will have over the keyboard
if (dinkeyboard->SetCooperativeLevel(mainApp->winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) {
qDebug() << "Tracker::setup SetCooperativeLevel function failed!" << GetLastError();
}
+ // set the control you will have over the mouse
+ dinmouse->SetCooperativeLevel(mainApp->winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND);
forever
{
@@ -376,6 +399,76 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); return;
}
+
+ //
+ // Check the mouse
+ //
+ // get access if we don't have it already
+ retAcquire = dinmouse->Acquire();
+ if ( (retAcquire != DI_OK) && (retAcquire != S_FALSE) ) {
+ qDebug() << "Tracker::run Acquire function failed!" << GetLastError();
+ }
+ else {
+ if (dinmouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate) != DI_OK) {
+ qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError();
+ }
+ else {
+ //
+ // Check the state of the StartStop MouseKey
+ //
+ if ( isMouseKeyPressed( &StartStopMouseKey, &mousestate ) && (!lastStartStopMouseKey) ) {
+ Tracker::do_tracking = !Tracker::do_tracking;
+
+ //
+ // To start tracking again and to be at '0', execute Center command too
+ //
+ if (Tracker::do_tracking) {
+ Tracker::confid = false;
+ pTracker->StartTracker( mainApp->winId() );
+ }
+ else {
+ if (setEngineStop) { // Only stop engine when option is checked
+ pTracker->StopTracker( false );
+ }
+ }
+ qDebug() << "Tracker::run() says StartStop pressed, do_tracking =" << Tracker::do_tracking;
+ }
+ lastStartStopMouseKey = isMouseKeyPressed( &StartStopMouseKey, &mousestate ); // Remember
+
+ //
+ // Check the state of the Center MouseKey
+ //
+ if ( isMouseKeyPressed( &CenterMouseKey, &mousestate ) && (!lastCenterMouseKey) ) {
+ Tracker::do_center = true;
+ qDebug() << "Tracker::run() says Center MouseKey pressed";
+ }
+ lastCenterMouseKey = isMouseKeyPressed( &CenterMouseKey, &mousestate ); // Remember
+
+ //
+ // Check the state of the GameZero MouseKey
+ //
+ if ( isMouseKeyPressed( &GameZeroMouseKey, &mousestate ) && (!lastGameZeroMouseKey) ) {
+ Tracker::do_game_zero = true;
+ qDebug() << "Tracker::run() says GameZero MouseKey pressed";
+ }
+ lastGameZeroMouseKey = isMouseKeyPressed( &GameZeroMouseKey, &mousestate ); // Remember
+
+ //
+ // Check the state of the Inhibit MouseKey
+ //
+ if ( isMouseKeyPressed( &InhibitMouseKey, &mousestate ) && (!lastInhibitMouseKey) ) {
+ Tracker::do_inhibit = !Tracker::do_inhibit;
+ qDebug() << "Tracker::run() says Inhibit MouseKey pressed";
+ //
+ // Execute Center command too, when inhibition ends.
+ //
+ if (!Tracker::do_inhibit) {
+ Tracker::do_center = true;
+ }
+ }
+ lastInhibitMouseKey = isMouseKeyPressed( &InhibitMouseKey, &mousestate ); // Remember
+ }
+ }
//
// Check the keyboard
@@ -807,12 +900,14 @@ int sensX, sensY, sensZ; iniFile.beginGroup ( "KB_Shortcuts" );
// Center key
+ CenterMouseKey = iniFile.value ( "MouseKey_Center", 0 ).toInt();
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
+ StartStopMouseKey = iniFile.value ( "MouseKey_StartStop", 0 ).toInt();
StartStopKey.keycode = iniFile.value ( "Keycode_StartStop", 0 ).toInt();
StartStopKey.shift = iniFile.value ( "Shift_StartStop", 0 ).toBool();
StartStopKey.ctrl = iniFile.value ( "Ctrl_StartStop", 0 ).toBool();
@@ -821,6 +916,7 @@ int sensX, sensY, sensZ; setEngineStop = iniFile.value ( "SetEngineStop", 1 ).toBool();
// Inhibit key
+ InhibitMouseKey = iniFile.value ( "MouseKey_Inhibit", 0 ).toInt();
InhibitKey.keycode = iniFile.value ( "Keycode_Inhibit", 0 ).toInt();
InhibitKey.shift = iniFile.value ( "Shift_Inhibit", 0 ).toBool();
InhibitKey.ctrl = iniFile.value ( "Ctrl_Inhibit", 0 ).toBool();
@@ -833,6 +929,7 @@ int sensX, sensY, sensZ; InhibitKey.doZ = iniFile.value ( "Inhibit_Z", 0 ).toBool();
// Game Zero key
+ GameZeroMouseKey = iniFile.value ( "MouseKey_GameZero", 0 ).toInt();
GameZeroKey.keycode = iniFile.value ( "Keycode_GameZero", 0 ).toInt();
GameZeroKey.shift = iniFile.value ( "Shift_GameZero", 0 ).toBool();
GameZeroKey.ctrl = iniFile.value ( "Ctrl_GameZero", 0 ).toBool();
@@ -885,3 +982,26 @@ bool alt; return false;
}
}
+
+//
+// Determine if the MouseKey is pressed.
+//
+bool Tracker::isMouseKeyPressed( int *key, DIMOUSESTATE *mousestate ){
+
+ //
+ // If key == NONE, or invalid: ready!
+ //
+ if ((*key <= 0) || (*key > 5)) {
+ return false;
+ }
+
+ //
+ // Now, check if the right key is pressed.
+ //
+ if (mousestate->rgbButtons[*key-1] & 0x80) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index ce34f6d2..df259708 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -192,6 +192,11 @@ private: static TShortKey GameZeroKey; // ShortKey to Set Game Zero
// static TShortKey AxisReverseKey; // ShortKey to reverse axis during tracking
+ static int CenterMouseKey; // ShortKey to Center headposition
+ static int StartStopMouseKey; // ShortKey to Start/stop tracking
+ static int InhibitMouseKey; // ShortKey to disable one or more axis during tracking
+ static int GameZeroMouseKey; // ShortKey to Set Game Zero
+
// Flags to start/stop/reset tracking
static bool confid; // Tracker data is OK
static bool do_tracking; // Start/stop tracking, using the shortkey
@@ -238,6 +243,7 @@ public: 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 );
+ bool isMouseKeyPressed( int *key, DIMOUSESTATE *mousestate );
static bool getTrackingActive() { return do_tracking && confid; }
static bool getAxisReverse() { return do_axis_reverse; }
|