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

Detecting Playback mode

Messages
4
Country
germany
Hi everybody,

does anybody have an idea how to detect if the sim is in playback mode?
I'm working on a simple autosave function. It works fine so far, except that it keeps saving even when in playback mode :(.

Thanks for any suggestions
Wolfgang
 
Wolfgang,

I assume you are recording a flight video. You could intercept the SimStart and SimStop events along with the esc key to trigger your program to figure out what to do. Menu Items will trigger only a SimStop SimStart event pair.

What "playback" mode are you referring too. Flight video or flight analysis?

Here is some code to intercept Esc key.

Code:
//------------------------------------------------------------------------------
//
//  SimConnect System Event Sample
//  
//	Description:
//  Request a FlightLoaded system event
//------------------------------------------------------------------------------

#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>

#include "SimConnect.h"

int     quit = 0;
HANDLE  hSimConnect = NULL;


static enum EVENT_ID2 {
    EVENT_SIM_START,
    EVENT_SIM_STOP,
	EVENT_ESC,
};
static enum GROUP_ID {
	GROUP_ESC,
};

static enum INPUT_ID {
	INPUT_ESC,
};


void CALLBACK MyDispatchProc2(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
{
	HRESULT hr;
    switch(pData->dwID)
    {
        case SIMCONNECT_RECV_ID_EVENT:
        {
            SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;
            switch(evt->uEventID)
            {
                case EVENT_SIM_START:

					printf("\nSim Start"); 
					hr = SimConnect_SetInputGroupState(hSimConnect, INPUT_ESC, SIMCONNECT_STATE_ON);


                    break;
                case EVENT_SIM_STOP:

					printf("\nSIM Stop"); 
					hr = SimConnect_SetInputGroupState(hSimConnect, INPUT_ESC, SIMCONNECT_STATE_OFF);


                    break;

                case EVENT_ESC:

					printf("\nESC pressed - do something"); 

                    break;

                default:
                   break;
            }
            break;
        }


        case SIMCONNECT_RECV_ID_QUIT:
        {
            quit = 1;
            break;
        }

        default:
            break;
    }
}

void testSystemEvent()
{
    HRESULT hr;

    if (SUCCEEDED(SimConnect_Open(&hSimConnect, "System Event", NULL, 0, 0, 0)))
    {
        printf("\nConnected to Flight Simulator!");   
        // Create some private events
        hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_ESC);

        // Link the private events to keyboard keys, and ensure input events are off
        hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT_ESC, "Esc", EVENT_ESC);

        hr = SimConnect_SetInputGroupState(hSimConnect, INPUT_ESC, SIMCONNECT_STATE_OFF);

        // Sign up for notifications
        hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP_ESC, EVENT_ESC);

        hr = SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_SIM_START, "SimStart");
        hr = SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_SIM_STOP, "SimStop");
  
        while( 0 == quit )
        {
            SimConnect_CallDispatch(hSimConnect, MyDispatchProc2, NULL);
            Sleep(1);
        } 

        hr = SimConnect_Close(hSimConnect);
    }
}

int __cdecl _tmain(int argc, _TCHAR* argv[])
{
	testSystemEvent();

	return 0;
}
 
Thanks Ron and sorry for not being precise:

I mean the "Instant replay function", which i often use to view landings etc.
Though I thing the same problem will occur for video playback.

I tried the USER INPUT ENABLED variable (the aircraft does not accept user input during replay), but it remains TRUE.

Any other idea?

Thanks

Wolfgang
 
Whenever you enter a dialog - the sim event SimStop is triggered. Do you need to only figure out if you are in replay mode?

There is a sim variable SIM DISABLED that is BOOL, but I have not been able to get a proper response yet. Thought that if you are in replay then Sim Disabled would be true. But my code does not work.


***********************

My mistake SIM DISABLED really means SIM OBJECT DISABLED - and I have not figured out how to disable the user aircraft. - so this variable is not good to usde in this case.

I' back to suggesting SimStart and SimStop. Also SimConnect_SubscribeToSystemEvent where event=Sim - a 0 or 1 - when in dialog mode = 0, when in record mode = 1, when in instant replay = 0 when in regular flying mode = 1.
 
Last edited:
Hi Ron,

I tried both USER INPUT ENABLED and SIM DISABLED, but - as you mentioned - none of these have any effect.
I'll try what you suggested (SimStart, SimStop and SubscribeToSystemEvent).


... I tried it and it works fine: SimStart/Stop and the Sim event perfectly mask both video playback and the instant replay.

Thanks for your help, you saved my day :-).

Regards
Wolfgang
 
Last edited:
Hi Simon,

while trying Ron's suggestion, I suscribed to the Sim event, which worked perfectly. But the SIM DISABLED variable still keeps returning FALSE.

But monitoring the Sim event does the trick anyway, so I will forget about SIM DISABLED.

Thanks anyway.
Regards
Wolfgang
 
I can confirm that. It seems, perhaps that USER INPUT DISABLED and SIM DISABLED are for AI aircraft (I have not tested). I cannot get these variables to change for USER Aircraft. In my testing I know my code works in that SIM ON GROUND returns proper information.

I did see an error in the SDK example for TAGGED DATA. A bool is SIMCONNECT_DATATYPE_INT32 not SIMCONNECT_DATATYPE_FLOAT32. The managed code example MANAGED_AI shows a bool as INT32. So FYI anyone.
 
I have a program at work that uses SIM DISABLED. But I think I just write to it to set the status and use the "Sim" event to read the status.

And that's for the user aircraft. I use it to freeze the flight model so I can drive it from an external physics engine.

Si
 
Back
Top