• 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.

Reading state of simulation using SimConnect_RequestSystemState

Messages
5
Country
brazil
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:


C++:
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!
 
Can't help you beyond what the FSX SDK says. Notice it says when running in Full Screen mode so this may not be the method to determine if the user is in the menus in MSFS. Have you tried reading any of the camera variables? I have found these can change depending on the menu (for example, in the main menu and not flying at all) but I don't know the particulars off the top of my head.

SimConnect
The dwInteger parameter should be set to 1 to turn Dialog mode on, or 0 to turn it off. Dialog mode enables the display of dialogs when the simulation is running in Full Screen mode. When in dialog mode the 3D area of the screen will turn black, and will only revert to the simulation view when Dialog mode is turned off (not automatically when the dialog is closed). See the Working Sample for a simple example.
It is safe to set and reset Dialog mode when the simulation is being run in Windows mode.
 
Just a thought:
1 - Is is possible to get your desired information outof the MSFS2020 sim via FSUIPC.DLL as well, in case the current SimConnect_API isn't providing what you are looking for ?
-http://www.fsuipc.com/ - Pete Downson FSUIPC.DLL website

2 - Is it technically possible to design and implement your own native C, C++, C# "interface" DLL into MSFS2020?

Why? "MSFS.2020" aka "The Flightsimlator" simple is - seen from an Windows Operating system / Application Developer viewpoint - just another "Win32" / "Win64" bits application that runs on the Windows OS
So if you can not achieve your goals from within the MSFS2020 "SDK"and tools, find a way outside those limiting factors to get it done.
Here are some getting-started resources on that path (if you want to do so):
-https://docs.microsoft.com/en-us/windows/win32/api/ - Get started with desktop Windows apps that use the Win32 API
-https://docs.microsoft.com/en-us/windows/win32/desktop-programming - Get started with desktop Windows apps that use the Win32 API-
-https://docs.microsoft.com/en-us/windows/win32/apiindex/windows-api-list - Windows API index
-https://docs.microsoft.com/en-us/windows/win32/winprog64/programming-guide-for-64-bit-windows - Programming Guide for 64-bit Windows


3 - Or even go an API level deeper - Directly onto the Win32/64 in Intel Assembler language
:
-https://www.intel.com/content/www/us/en/support/articles/000006715/processors.html - Intel (32/64) Assembler developer guides
- https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html - Intel (32/64) Assembler developer guides
-https://www.winasm.org/index.html - Win32 IDE
-https://www.davidgrantham.com/ - Win32/64 code-examples

Some free Win32/64 assembler tutorials:
-https://www.deinmeister.de/asmgen.htm -
-https://cs.lmu.edu/~ray/notes/nasmtutorial/
-https://hackr.io/tutorials/learn-assembly-language
-https://www.cs.uaf.edu/2017/fall/cs301/reference/x86_64.html
-https://www.tutorialspoint.com/assembly_programming/index.htm
-https://bakarabu.wordpress.com/2021/10/01/nasm-x64-assembly-programming-in-windows/

fsd_bit_streams.png

Why? since @ the end of the day - Every "App", "Application" and/or "Program" is just a limited series of bits and bytes, flowing through your CPU and GPU...
 
Back
Top