summaryrefslogtreecommitdiffhomepage
path: root/X-Plane-SDK/CHeaders/Wrappers/XPCProcessing.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-08-18 05:02:34 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-09 10:27:50 +0200
commit24e37795d2db8fdc6f7809e793dadbae80211d26 (patch)
treef2fd152fb44518222e290e555f0274af18d877bd /X-Plane-SDK/CHeaders/Wrappers/XPCProcessing.cpp
parent9a87e2cb6e588641e3cff52655013594c492e033 (diff)
add SDKs
Diffstat (limited to 'X-Plane-SDK/CHeaders/Wrappers/XPCProcessing.cpp')
-rwxr-xr-xX-Plane-SDK/CHeaders/Wrappers/XPCProcessing.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/X-Plane-SDK/CHeaders/Wrappers/XPCProcessing.cpp b/X-Plane-SDK/CHeaders/Wrappers/XPCProcessing.cpp
new file mode 100755
index 0000000..352c05f
--- /dev/null
+++ b/X-Plane-SDK/CHeaders/Wrappers/XPCProcessing.cpp
@@ -0,0 +1,52 @@
+#include "XPCProcessing.h"
+#include "XPLMUtilities.h"
+
+XPCProcess::XPCProcess() :
+ mInCallback(false),
+ mCallbackTime(0)
+{
+ XPLMRegisterFlightLoopCallback(FlightLoopCB, 0, reinterpret_cast<void *>(this));
+}
+
+XPCProcess::~XPCProcess()
+{
+ XPLMUnregisterFlightLoopCallback(FlightLoopCB, reinterpret_cast<void *>(this));
+}
+
+void XPCProcess::StartProcessTime(float inSeconds)
+{
+ mCallbackTime = inSeconds;
+ if (!mInCallback)
+ XPLMSetFlightLoopCallbackInterval(
+ FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast<void *>(this));
+}
+
+void XPCProcess::StartProcessCycles(int inCycles)
+{
+ mCallbackTime = -inCycles;
+ if (!mInCallback)
+ XPLMSetFlightLoopCallbackInterval(
+ FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast<void *>(this));
+}
+
+void XPCProcess::StopProcess(void)
+{
+ mCallbackTime = 0;
+ if (!mInCallback)
+ XPLMSetFlightLoopCallbackInterval(
+ FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast<void *>(this));
+}
+
+
+float XPCProcess::FlightLoopCB(
+ float inElapsedSinceLastCall,
+ float inElapsedTimeSinceLastFlightLoop,
+ int inCounter,
+ void * inRefcon)
+{
+ XPCProcess * me = reinterpret_cast<XPCProcess *>(inRefcon);
+ me->mInCallback = true;
+ me->DoProcessing(inElapsedSinceLastCall, inElapsedTimeSinceLastFlightLoop, inCounter);
+ me->mInCallback = false;
+ return me->mCallbackTime;
+} \ No newline at end of file