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

P3D v4 Pausing, slewing & sim rate detection

Messages
5
Country
hungary
Hey everyone! My first post here because I'm at a loss with a problem. I'm very much a beginner when it comes to programming and I've used the Simconnect SDK's example as a starting point to make an ACARS-like software in C#. Everything went well with requesting variables, but events seem to be a problem. I tried changing "Managed Client Event" code to trigger with pausing & slewing events. However, out of the listed events regarding these, I found that for example PAUSE_ON and PAUSE_OFF never triggered. PAUSE_TOGGLE only triggered when the actual "P" button was pressed, but not when the add-on's pause at top of descent function triggered it. SIM_RATE_INCR and its pair for decrease never triggered for me when using the menu either.
An example of registering to such an event:
C#:
simconnect.MapClientEventToSimEvent(EVENTS.PAUSE_ON, "PAUSE_ON");
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.PAUSE_ON, false);
etc.
What I'd like is the ability to detect if the sim is paused or not and disallow slewing / sim rate increase while the program is running. I tried to dabble with subscribing to the SLEW_SET system event and set the system event state to SIMCONNECT_STATE.ON or OFF but nothing happened in either case.
I found a few posts on google, some even from this forum, but nothing I tried worked so far. I'd really, really appreciate if someone could help me with this (:
 
You need to be paying attention to SIM STATE... not key input events. Read up on SimConnect_SubscribeToSystemEvent.
 
Thank you very much for the reply, I managed to get the pausing event to work correctly using this page: http://www.prepar3d.com/SDKv3/Learn...onnect.html#SimConnect_SubscribeToSystemEvent. I found "Frame" as well which is supposed to give information about the sim rate and have subscribed to it like every other system event:
C#:
simconnect.SubscribeToSystemEvent(EVENTS.FRAME, "FRAME");
but it never triggers (neither does PauseFrame), am I missing something here?
 
The FRAME event triggers for every visual frame rendered. It does NOT tell you the sim rate.
 
Hmmm, that's good to know, since the documentation says "Frame: Request notifications every visual frame. Information is returned in a SIMCONNECT_RECV_EVENT_FRAME structure."
and the returned structure is
C#:
struct SIMCONNECT_RECV_EVENT_FRAME : public SIMCONNECT_RECV_EVENT {
  float  fFrameRate;
  float  fSimSpeed;
};
where "fSimSpeed: The simulation rate. For example if the simulation is running at four times normal speed -- 4X -- then 4.0 will be returned."
 
Ah... thus one must read ALL of the SDK... that's not in the description of the actual API call. LOL :oops:

I will test this in C++.
 
The FRAME event DOES tell you both the frame rate and the sim speed. Here is a C++ implementation, if you can make any use of it:

Code:
        case SIMCONNECT_RECV_ID_EVENT_FRAME:
        {
            SIMCONNECT_RECV_EVENT_FRAME *evt = (SIMCONNECT_RECV_EVENT_FRAME*)pData;
            switch(evt->uEventID)
            {
                case EVENT_RECUR_FRAME:
                    SystemVars->fFrameRate = evt->fFrameRate;
                    SystemVars->fFrameDuration = 1.0f/evt->fFrameRate;
                    SystemVars->fSimSpeed = evt->fSimSpeed;

                    break;

                default:
                   break;
            }
            break;
        }

As for FRAME not being triggered, "Frame" system event doesn't fall under the same event ID group as Pause. Pause belongs to SIMCONNECT_RECV_ID_EVENT, and Frame belongs to SIMCONNECT_RECV_ID_EVENT_FRAME (as in the above code snippet).

Make sure you have a case statement for SIMCONNECT_RECV_ID_EVENT_FRAME, where you listen for "Frame" event.
 
Thank you very much, this is exactly what I was missing! Took me all of five minutes to get it to work now, really really appreciate it :)
 
Back
Top