• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

[TO DELETE] Using SimConnect_RequestSystemState()

Messages
10
Country
france
Hi,
(sorry in advance for my english)
I'm trying to get the data according to the flying simulation state :
"If 1 is returned, the user is in control of the aircraft (he's playing), if 0 is returned, the user is navigating the UI (he's not playing)."

According to this very complete source : https://msdn.microsoft.com/en-us/library/cc526983.aspx ,
(the following indexes 4) 3) etc... were made for the indexed code at the bottom. Ignore those at the 1st reading.)
-----------------------------
4)This state can be acquired by using the SimConnect_RequestSystemState() funtion.

Prototype :
HRESULT SimConnect_RequestSystemState(
HANDLE hSimConnect,
SIMCONNECT_DATA_REQUEST_ID RequestID,
const char* szState,
);

RequestID - is the "variable" which is SIMCONNECT_DATA_REQUEST_ID typed, that I have to declare myself, and then give it to the funtion.
(I call it variable because it's not defined anywhere in the documentation)
szState - is the variable which is const char* typed, that I have to declare myself aswell (and initialize it with the value "Sim" in order to get the simulation flying state in real time), and then give it to the funtion.

"The information requested will be returned in a SIMCONNECT_RECV_SYSTEM_STATE structure.";

-----------------------------

3)So now, I guess I have to declare a SIMCONNECT_RECV_SYSTEM_STATE structure which will receive the data I'm interested in.
"This structure inherits the SIMCONNECT_RECV structure and is returned when the dwID parameter of SIMCONNECT_RECV is set to SIMCONNECT_RECV_ID_SYSTEM_STATE.";

2)So I guess now, that I have to declare a new SIMCONNECT_RECV structure too, in order to be able to change "its" dwID parameter setting to "SIMCONNECT_RECV_ID_SYSTEM_STATE";
dwID : "The ID of the returned structure. One member of SIMCONNECT_RECV_ID.";

1)Again, I guess now, that I have to declare a SIMCONNECT_RECV_ID structure in order to "choose" this "SIMCONNECT_RECV_ID_SYSTEM_STATE" setting.

-----------------------------

So, is this code correct according to all I just said ? (code lines are indexed according to the previous steps)
--
SIMCONNECT_DATA_REQUEST_ID d(7777); //4
const char* szState='Sim'; //4

SIMCONNECT_RECV_ID a="SIMCONNECT_RECV_ID_SYSTEM_STATE"; // 1)

SIMCONNECT_RECV b(); // 2)
b.dwID = a; //2)

SIMCONNECT_RECV_SYSTEM_STATE c(); // 3)
c.dwRequestID=d; // 3)

SimConnect_RequestSystemState(AlreadyDeclaredHandle, d, szState); //4)
--

And does my c.dwRequestID need to be the same ID I'm giving to the SimConnect_RequestSystemState() funtion (=d) so they can find eachothers ?
And do not &b and &c need to be related somehow ?
According to the following prototype, if this code is correct (or when this code will be correct), is the "flying" state (1 or 0) present and accessible in the c.dwInteger variable ?
--
typedef struct SIMCONNECT_RECV_SYSTEM_STATE : public SIMCONNECT_RECV {
DWORD dwRequestID;
DWORD dwInteger;
float fFloat;
char szString[MAX_PATH];
};
--

Thanks in advance for your answer(s).

Regards,

bas-tiras@hotmail.fr
 
Last edited:
Provide a little more actual code - we're not sure what you are doing. Review the DialogBoxMode example.

You don't declare any structures in this type of program (only enums). The RECV structures/data (memory blocks/packets) are sent to you via:

void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)

pData is the RECV data and you "decode" it via the:

pData->dwID

If it is SIMCONNECT_RECV_ID_EVENT do this.
if it is SIMCONNECT_RECV_ID_SYSTEM_STATE do something else based on the state.

Then you decode the pData memory block (for STATE data) by:

SIMCONNECT_RECV_SYSTEM_STATE *pState = (SIMCONNECT_RECV_SYSTEM_STATE*)pData;

Then you look at the pState memory block and decode the RequestID

pState->dwRequestID

If it matches the REQUEST0 from your enum- that's about the only thing you declare in your program.
static enum REQUEST_ID {
REQUEST0,
};

You do some other thing.
 
Back
Top