Hi all,
I am trying to read the simulation state using SimConnect_RequestSystemState. The intention is to know when the user is actually flying the aircraft or navigating the UI. Code is as follows:
MSFS_CALLBACK bool GaugeCallback(FsContext ctx, int service_id, void* pData)
{
switch (service_id)
{
case PANEL_SERVICE_PRE_UPDATE:
{
SimConnect_RequestSystemState(hSimConnect, REQ_SYSTEM_STATE, "Sim");
}
break;
default:
break;
}
}
void CALLBACK SimconnectDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContext)
{
switch (pData->dwID)
{
case SIMCONNECT_RECV_ID_SYSTEM_STATE:
{
const auto pState = static_cast<SIMCONNECT_RECV_SYSTEM_STATE*>(pData);
if (pState->dwRequestID != SIMCONNECT_RECV_ID_NULL)
{
switch (pState->dwRequestID)
{
case REQ_SYSTEM_STATE:
{
const bool value = pState->dwInteger != 0 ? true : false;
int a = 0;
if (value)
a = 10;
else
a = 20;
}
break;
default:
break;
}
}
}
default:
break;
}
}
int a stuff was just added to check if value was set/cleared appropriately. There’s also more code on these functions - I have removed unrelated calls from the code snippets above.
No matter what I do the value boolean is never cleared. It remais true whatever I do.
What am I doing wrong? Any insights will be much appreciated.
Thanks!