From 24e37795d2db8fdc6f7809e793dadbae80211d26 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 18 Aug 2015 05:02:34 +0200 Subject: add SDKs --- X-Plane-SDK/CHeaders/Wrappers/XPCProcessing.cpp | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 X-Plane-SDK/CHeaders/Wrappers/XPCProcessing.cpp (limited to 'X-Plane-SDK/CHeaders/Wrappers/XPCProcessing.cpp') 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(this)); +} + +XPCProcess::~XPCProcess() +{ + XPLMUnregisterFlightLoopCallback(FlightLoopCB, reinterpret_cast(this)); +} + +void XPCProcess::StartProcessTime(float inSeconds) +{ + mCallbackTime = inSeconds; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + +void XPCProcess::StartProcessCycles(int inCycles) +{ + mCallbackTime = -inCycles; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + +void XPCProcess::StopProcess(void) +{ + mCallbackTime = 0; + if (!mInCallback) + XPLMSetFlightLoopCallbackInterval( + FlightLoopCB, mCallbackTime, 1/*relative to now*/, reinterpret_cast(this)); +} + + +float XPCProcess::FlightLoopCB( + float inElapsedSinceLastCall, + float inElapsedTimeSinceLastFlightLoop, + int inCounter, + void * inRefcon) +{ + XPCProcess * me = reinterpret_cast(inRefcon); + me->mInCallback = true; + me->DoProcessing(inElapsedSinceLastCall, inElapsedTimeSinceLastFlightLoop, inCounter); + me->mInCallback = false; + return me->mCallbackTime; +} \ No newline at end of file -- cgit v1.2.3