diff options
author | Wim Vriend <facetracknoir@gmail.com> | 2010-11-26 19:55:00 +0000 |
---|---|---|
committer | Wim Vriend <facetracknoir@gmail.com> | 2010-11-26 19:55:00 +0000 |
commit | 4c04337f46470180312812634beb0e39a04bcf9f (patch) | |
tree | 4cc03adabe80bf576f396659f2bef52046e30597 /FaceTrackNoIR/SCServer.cpp | |
parent | ab77b86507c65c56ec8aeda181bb43cc96cebc18 (diff) |
Changed update-sequence for FSX and FS2004. No data is written, if the headpose-data has not changed. This way, it is possible to use the HAT-switch, if tracking is OFF.
The FTIRServer now also starts the dummy TrackIR.exe process, which is required by some clients, like EZCA.
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@29 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FaceTrackNoIR/SCServer.cpp')
-rw-r--r-- | FaceTrackNoIR/SCServer.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/FaceTrackNoIR/SCServer.cpp b/FaceTrackNoIR/SCServer.cpp index 30b0b2e9..fbbd92a3 100644 --- a/FaceTrackNoIR/SCServer.cpp +++ b/FaceTrackNoIR/SCServer.cpp @@ -76,6 +76,8 @@ importSimConnect_Open simconnect_open; // SimConnect function(s) in DLL importSimConnect_Close simconnect_close;
importSimConnect_CameraSetRelative6DOF simconnect_set6DOF;
+float prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ;
+
//
// Get the SimConnect_Open function from the DLL and use it!
//
@@ -97,6 +99,13 @@ importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; qDebug() << "SCServer::run() says: SimConnect functions resolved in DLL!";
+ prevPosX = 0.0f;
+ prevPosY = 0.0f;
+ prevPosZ = 0.0f;
+ prevRotX = 0.0f;
+ prevRotY = 0.0f;
+ prevRotZ = 0.0f;
+
forever
{
// Check event for stop thread
@@ -122,10 +131,22 @@ importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; //
// Write the 6DOF-data to FSX
//
- if (S_OK == simconnect_set6DOF(hSimConnect, virtPosX, virtPosY, virtPosZ, virtRotX, virtRotZ, virtRotY)) {
-// qDebug() << "SCServer::run() says: SimConnect data written!";
+ // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF.
+ //
+ if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) ||
+ (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) {
+ if (S_OK == simconnect_set6DOF(hSimConnect, virtPosX, virtPosY, virtPosZ, virtRotX, virtRotZ, virtRotY)) {
+// qDebug() << "SCServer::run() says: SimConnect data written!";
+ }
}
+ prevPosX = virtPosX;
+ prevPosY = virtPosY;
+ prevPosZ = virtPosZ;
+ prevRotX = virtRotX;
+ prevRotY = virtRotY;
+ prevRotZ = virtRotZ;
+
// just for lower cpu load
msleep(15);
yieldCurrentThread();
|