summaryrefslogtreecommitdiffhomepage
path: root/FaceTrackNoIR/PPJoyServer.cpp
diff options
context:
space:
mode:
authorWim Vriend <facetracknoir@gmail.com>2010-06-12 09:34:27 +0000
committerWim Vriend <facetracknoir@gmail.com>2010-06-12 09:34:27 +0000
commit513d1c8521aad3cd5ba7db3b87349553a793c151 (patch)
tree2f6fca2568d243ad716afaf62d7b1e5ac1214df2 /FaceTrackNoIR/PPJoyServer.cpp
parenta0feb94b670a150e4574f1921cfcfe59049be822 (diff)
PPJoy working
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@11 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FaceTrackNoIR/PPJoyServer.cpp')
-rw-r--r--FaceTrackNoIR/PPJoyServer.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/FaceTrackNoIR/PPJoyServer.cpp b/FaceTrackNoIR/PPJoyServer.cpp
index 46a66c44..53b6322b 100644
--- a/FaceTrackNoIR/PPJoyServer.cpp
+++ b/FaceTrackNoIR/PPJoyServer.cpp
@@ -95,25 +95,32 @@ void PPJoyServer::run() {
Digital= JoyState.Digital; // Keep a pointer to the digital array for easy updating
JoyState.NumDigital= NUM_DIGITAL; // Number of digital values
+ /* Make sure we could open the device! */
+ /* MessageBox in run() does not work! (runtime error...)*/
+ if (h == INVALID_HANDLE_VALUE) {
+ return;
+ }
forever
{
// Check event for stop thread
- if(::WaitForSingleObject(m_StopThread, 0) == WAIT_OBJECT_0)
- {
+ if(::WaitForSingleObject(m_StopThread, 0) == WAIT_OBJECT_0) {
// Set event
::SetEvent(m_WaitThread);
return;
}
- Analog[0] = scale2AnalogLimits( virtRotX, -90.0f, 90.0f ); // Pitch
+ // The effective angle for faceTracking will be < 90 degrees, so we assume a smaller range here
+ Analog[0] = scale2AnalogLimits( virtRotX, -50.0f, 50.0f ); // Pitch
qDebug() << "PPJoyServer says: Pitch =" << Analog[0] << " VirtRotX =" << virtRotX ;
- Analog[1] = scale2AnalogLimits( virtRotY, -90.0f, 90.0f ); // Yaw
- Analog[2] = scale2AnalogLimits( virtRotZ, -90.0f, 90.0f ); // Roll
- Analog[3] = virtPosX + analogDefault; // X
+ Analog[1] = scale2AnalogLimits( virtRotY, -50.0f, 50.0f ); // Yaw
+ Analog[2] = scale2AnalogLimits( virtRotZ, -50.0f, 50.0f ); // Roll
+
+ // The effective movement for faceTracking will be < 50 cm, so we assume a smaller range here
+ Analog[3] = scale2AnalogLimits( virtPosX, -40.0f, 40.0f ); // X
- Analog[5] = virtPosY + analogDefault; // Y (5?)
- Analog[6] = virtPosZ + analogDefault; // Z (6?)
+ Analog[5] = scale2AnalogLimits( virtPosY, -40.0f, 40.0f ); // Y (5?)
+ Analog[6] = scale2AnalogLimits( virtPosZ, -40.0f, 40.0f ); // Z (6?)
checkAnalogLimits();