Initial Version
This commit is contained in:
52
xpcPlugin/SDK/CHeaders/Wrappers/XPCProcessing.cpp
Executable file
52
xpcPlugin/SDK/CHeaders/Wrappers/XPCProcessing.cpp
Executable file
@@ -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(long 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;
|
||||
}
|
||||
Reference in New Issue
Block a user