diff options
author | Wim Vriend <facetracknoir@gmail.com> | 2010-05-31 20:03:34 +0000 |
---|---|---|
committer | Wim Vriend <facetracknoir@gmail.com> | 2010-05-31 20:03:34 +0000 |
commit | 2625fe5af6bf71a627dcf10ff813574f8a61f994 (patch) | |
tree | 9e7dca458bcad3f40059b70b271b1cf0bb38125b | |
parent | 88f347a6160c1f1b79840c6489fb963a4b6a8cad (diff) |
Implementing DirectInput voor keyboard afhandeling.
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@3 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
19 files changed, 81 insertions, 10 deletions
diff --git a/FaceTrackNoIR.ncb b/FaceTrackNoIR.ncb Binary files differindex 6cb4526c..90482f62 100644 --- a/FaceTrackNoIR.ncb +++ b/FaceTrackNoIR.ncb diff --git a/FaceTrackNoIR.suo b/FaceTrackNoIR.suo Binary files differindex b0e584f8..de359e17 100644 --- a/FaceTrackNoIR.suo +++ b/FaceTrackNoIR.suo diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 95ef6e97..c9e1e76d 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -23,6 +23,7 @@ *********************************************************************************/
#include "FaceTrackNoIR.h"
+#include "tracker.h"
using namespace sm::faceapi;
using namespace sm::faceapi::qt;
diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index d09641d2..16a432a3 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -25,6 +25,7 @@ #ifndef FaceTrackNoIR_H
#define FaceTrackNoIR_H
+#include <tchar.h>
#include <QtGui/QMainWindow>
#include <QApplication>
#include <QFileDialog>
@@ -34,14 +35,14 @@ #include <QDialog>
#include "ui_FaceTrackNoIR.h"
-#include "tracker.h"
-
#include <sm_api_qt.h>
#include <Dshow.h>
using namespace sm::faceapi;
using namespace sm::faceapi::qt;
+class Tracker; // pre-define class to avoid circular includes
+
class FaceTrackNoIR : public QMainWindow
{
Q_OBJECT
diff --git a/FaceTrackNoIR/Release/BuildLog.htm b/FaceTrackNoIR/Release/BuildLog.htm Binary files differindex 0677d9b0..18bd1e16 100644 --- a/FaceTrackNoIR/Release/BuildLog.htm +++ b/FaceTrackNoIR/Release/BuildLog.htm diff --git a/FaceTrackNoIR/Release/FGServer.obj b/FaceTrackNoIR/Release/FGServer.obj Binary files differindex a297f793..c1189299 100644 --- a/FaceTrackNoIR/Release/FGServer.obj +++ b/FaceTrackNoIR/Release/FGServer.obj diff --git a/FaceTrackNoIR/Release/FaceApp.obj b/FaceTrackNoIR/Release/FaceApp.obj Binary files differindex ae7857c8..c5d5a9e4 100644 --- a/FaceTrackNoIR/Release/FaceApp.obj +++ b/FaceTrackNoIR/Release/FaceApp.obj diff --git a/FaceTrackNoIR/Release/FaceTrackNoIR.obj b/FaceTrackNoIR/Release/FaceTrackNoIR.obj Binary files differindex 9e35aada..3c1d59bf 100644 --- a/FaceTrackNoIR/Release/FaceTrackNoIR.obj +++ b/FaceTrackNoIR/Release/FaceTrackNoIR.obj diff --git a/FaceTrackNoIR/Release/main.obj b/FaceTrackNoIR/Release/main.obj Binary files differindex c9810785..5d8e5ce0 100644 --- a/FaceTrackNoIR/Release/main.obj +++ b/FaceTrackNoIR/Release/main.obj diff --git a/FaceTrackNoIR/Release/moc_FaceApp.obj b/FaceTrackNoIR/Release/moc_FaceApp.obj Binary files differindex 34d6862d..2e13f0a8 100644 --- a/FaceTrackNoIR/Release/moc_FaceApp.obj +++ b/FaceTrackNoIR/Release/moc_FaceApp.obj diff --git a/FaceTrackNoIR/Release/moc_FaceTrackNoIR.obj b/FaceTrackNoIR/Release/moc_FaceTrackNoIR.obj Binary files differindex 718584f8..b9dfed7e 100644 --- a/FaceTrackNoIR/Release/moc_FaceTrackNoIR.obj +++ b/FaceTrackNoIR/Release/moc_FaceTrackNoIR.obj diff --git a/FaceTrackNoIR/Release/moc_tracker.obj b/FaceTrackNoIR/Release/moc_tracker.obj Binary files differindex b6dea113..e2db08f7 100644 --- a/FaceTrackNoIR/Release/moc_tracker.obj +++ b/FaceTrackNoIR/Release/moc_tracker.obj diff --git a/FaceTrackNoIR/Release/mt.dep b/FaceTrackNoIR/Release/mt.dep index 965c3d3a..b12f071f 100644 --- a/FaceTrackNoIR/Release/mt.dep +++ b/FaceTrackNoIR/Release/mt.dep @@ -1 +1 @@ -Manifest resource last updated at 20:44:54,75 on vr 28-05-2010
+Manifest resource last updated at 21:17:07,84 on ma 31-05-2010
diff --git a/FaceTrackNoIR/Release/tracker.obj b/FaceTrackNoIR/Release/tracker.obj Binary files differindex 8ef0b52a..1feae14e 100644 --- a/FaceTrackNoIR/Release/tracker.obj +++ b/FaceTrackNoIR/Release/tracker.obj diff --git a/FaceTrackNoIR/Release/vc90.idb b/FaceTrackNoIR/Release/vc90.idb Binary files differindex f645e021..b3f2574f 100644 --- a/FaceTrackNoIR/Release/vc90.idb +++ b/FaceTrackNoIR/Release/vc90.idb diff --git a/FaceTrackNoIR/Release/vc90.pdb b/FaceTrackNoIR/Release/vc90.pdb Binary files differindex b729977b..432b1e6a 100644 --- a/FaceTrackNoIR/Release/vc90.pdb +++ b/FaceTrackNoIR/Release/vc90.pdb diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 327d9f49..30247cd9 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -30,6 +30,10 @@ #include "tracker.h"
#include "FaceTrackNoIR.h"
+void initDInput(HINSTANCE hInstance, HWND hWnd); // sets up and initializes DirectInput
+void detect_input(void); // gets the current input state
+void cleanDInput(void); // closes DirectInput and releases memory
+
using namespace sm::faceapi;
using namespace sm::faceapi::qt;
@@ -138,13 +142,6 @@ void Tracker::setup(QWidget *head, FaceTrackNoIR *parent) { headRotYLine = headPoseWidget->findChild<QLineEdit *>("headRotYLine");
headRotZLine = headPoseWidget->findChild<QLineEdit *>("headRotZLine");
- // Let's start smoothing with 10 samples...
- intMaxYawItems = 10;
- intMaxPitchItems = 10;
- intMaxRollItems = 10;
- intMaxXItems = 10;
- intMaxYItems = 10;
- intMaxZItems = 10;
//
// Check if the Freetrack Client DLL is available
@@ -163,6 +160,47 @@ void Tracker::setup(QWidget *head, FaceTrackNoIR *parent) { /** QThread run method @override **/
void Tracker::run() {
+ /** Direct Input variables **/
+ LPDIRECTINPUT8 din; // the pointer to our DirectInput interface
+ LPDIRECTINPUTDEVICE8 dinkeyboard; // the pointer to the keyboard device
+ BYTE keystate[256]; // the storage for the key-information
+ HRESULT retAcquire;
+
+ //
+ // Setup the DirectInput for keyboard strokes
+ //
+ // create the DirectInput interface
+ if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8,
+ (void**)&din, NULL) != DI_OK) { // COM stuff, so we'll set it to NULL
+ qDebug() << "Tracker::setup DirectInput8 Creation failed!" << GetLastError();
+ }
+ else {
+ qDebug() << "Tracker::setup DirectInput8 Creation OK!";
+ }
+
+ // create the keyboard device
+ if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL) != DI_OK) {
+ qDebug() << "Tracker::setup CreateDevice function failed!" << GetLastError();
+ }
+ else {
+ qDebug() << "Tracker::setup CreateDevice function OK!";
+ }
+
+ // set the data format to keyboard format
+ if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) {
+ qDebug() << "Tracker::setup SetDataFormat function failed!" << GetLastError();
+ }
+ else {
+ qDebug() << "Tracker::setup SetDataFormat function OK!";
+ }
+
+ // 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();
+ }
+ else {
+ qDebug() << "Tracker::setup SetCooperativeLevel function OK!";
+ }
forever
{
@@ -175,6 +213,27 @@ void Tracker::run() { return;
}
+ //
+ // Check the keyboard
+ //
+ // get access if we don't have it already
+ retAcquire = dinkeyboard->Acquire();
+ if ( (retAcquire != DI_OK) && (retAcquire != S_FALSE) ) {
+ qDebug() << "Tracker::run Acquire function failed!" << GetLastError();
+ }
+ else {
+ // get the input data
+ if (dinkeyboard->GetDeviceState(256, (LPVOID)keystate) != DI_OK) {
+ qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError();
+ }
+ else {
+ qDebug() << "Tracker::run GetDeviceState function OK!";
+ if(keystate[DIK_HOME] & 0x80) {
+ qDebug() << "Tracker::run() says HOME pressed";
+ }
+ }
+ }
+
//if the confidence is good enough the headpose will be updated **/
if(Tracker::confid) {
diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index 5405b0e7..a5126818 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -31,9 +31,19 @@ #include <QPoint>
#include <QWaitCondition>
#include <QList>
+
+#define DIRECTINPUT_VERSION 0x0800
+#include <Dinput.h>
+
#include "FTServer.h" // Freetrack-server
#include "FGServer.h" // FlightGear-server
+// include the DirectX Library files
+//#pragma comment (lib, "d3d9.lib")
+//#pragma comment (lib, "d3dx9.lib")
+#pragma comment (lib, "dinput8.lib")
+#pragma comment (lib, "dxguid.lib")
+
using namespace sm::faceapi;
using namespace sm::faceapi::qt;
diff --git a/bin/FaceTrackNoIR.exe b/bin/FaceTrackNoIR.exe Binary files differindex 05ce7bba..d41c98b4 100644 --- a/bin/FaceTrackNoIR.exe +++ b/bin/FaceTrackNoIR.exe |