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

Using simconnect with third party airplane

Messages
5
Country
us-utah
I'm trying to do a project with PMDG 737 is FS2020.

How does one get a list of all the LVARS and KVARS supported by the airplane. Read somewhere you have to go thru the airplane xml files - but wasn't clear.

Also, can I read set them using simconnect?

The Simconnect api docs for `SimConnect_AddToDataDefinition` seems to suggest one can interact with the built-in fs2020 LVARS.
For example, i'd like to process RPN like `(L:switch_7461_73X, number) 0 >`
 
How does one get a list of all the LVARS and KVARS supported by the airplane.
Ideally, the model's author/publisher provides API documentation for their model. Barring that, then yea, you're on the hunt... besides the model definitions, there's also the sim's Dev mode Behaviors inspector window. There's no built-in way to programmatically get lists of variables/events a model uses, never mind explanations of what they may be used for.

Also, can I read set them using simconnect?
L vars, yes. For `SimConnect_AddToDataDefinition` simply prefix the variable name with "L:" when adding it -- eg. SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, "L:switch_7461_73X", "number");
The rest is the same as for Sim ("A") Vars.

"K vars" are actually a.k.a "key events" so they can be triggered ("set") via SimConnect as usual, including any custom events a model may provide. There's no way to "read" a K var at all. And again there's no way to determine what events a model may react to besides published docs or "manual discovery."

"H vars" (or "HTML Events") are model-specific and similar to K/key events (they can be "set" but not read), but there's no way to trigger them via SimConnect at all.

HTH,
-Max
 
Thanks.

I was able to set/trigger an event using SimConnect_SetDataOnSimObject() - is that correct?

But how do I trigger an event and also pass a parameter value also - e.g. below



LOGO_LIGHTS_SET[0]: state, either on (1) or off (0)

[1]: light index
Set logo lights on/off (1,0)
 
But how do I trigger an event and also pass a parameter value also - e.g. below
To use Key Events you'd map your own ID to an event ("K var") by name using MapClientEventToSimEvent(), once, and then actually trigger the event, as many times as you want, with optional parameters using TransmitClientEvent_EX1(). See those doc links for basic examples.

I was able to set/trigger an event using SimConnect_SetDataOnSimObject()
Interesting.... how? You were able to `AddToDataDefinition()` a Key event by name? Never tried that.

Cheers,
-Max
 
Yes - something like

`SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_LIGHT,
"LOGO_LIGHTS", "bool", SIMCONNECT_DATATYPE_INT32);`

and then

`SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_LIGHT, SIMCONNECT_OBJECT_ID_USER, 0);`

I'm setting an MSFS var -without parameters - maybe that's why it works.

I'd eventually like to get it working with third party airplanes and passing parameters. I'll try your suggestion in a few days.

This simconnect api is confusing, convoluted and not well designed.

I guess ms2024 will deprecate this whole interface.
 
I'm setting an MSFS var -without parameters - maybe that's why it works.
I'm curious what you mean by "works..." does it actually affect the logo lights somehow? Always turns them off? Assuming you mean "LOGO_LIGHTS_SET". Anyway, I've never seen this way of triggering events.

SIMCONNECT_RECV_EXCEPTION messages must be monitored to get actual errors from SimConnect. The functions like `AddToDataDefinition()`, `SetDataOnSimObject()`, et al, will accept any input, including invalid data, and return HRESULT of OK.

I'll try your suggestion in a few days.
That's the documented way to trigger key events via SimConnect. :)

This simconnect api is confusing, convoluted and not well designed.

A realistic flight simulator at the level of MSFS is a very complicated beast. It would stand to reason that the API for interacting with it will have a learning curve as well. 🤷‍♂️

Cheers,
-Max
 
Miscommunication - I meant with `SimConnect_AddToDataDefinition` I can get a callback when someone toggles the lights using LOGO_LIGHTS.

I'd like to send an event to set the lights using LOGO_LIGHTS_SET and I'll try your suggestion.

How does one decipher SIMCONNECT_RECV_EXCEPTION callbacks - I understand that there's 3 parameters sent back.


I'm trying to set the toggle light programmtically

SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_LOGO, "LOGO_LIGHTS_SET");
SimConnect_TransmitClientEvent_EX1(hSimConnect, 0, EVENT_LOGO,
SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY, 1, 1);
Above doesn't work - any help?
 
Last edited:
Enter 'simconnect_exception' in the Learning Center and select 'Structures and Enumerations'. On the main page, ctrl+F and search 'SIMCONNECT_RECV_EXCEPTION'. That gives you the whole shooting match. Alternatively, I packaged it all into a clickable PDF for reference when I was first learning SimConnect and making a mess of it (attached).
 

Attachments

  • simconnect exceptions.pdf
    66.8 KB · Views: 201
Last edited:
How does one get a list of all the LVARS and KVARS supported by the airplane
I hope I'm not too late to the party but PMDG provides an SDK with their 737 located in the documentation folder in your 737 package folder. It includes a header file called PMDG_NG3_SDK.h as well as a pdf document describing the process of getting and setting data in the 737. The files include everything you will need to interact with the 737 through SimConnect. So setting the logo lights can be done using the following event definitions:

Code:
#define THIRD_PARTY_EVENT_ID_MIN                0x00011000      // equals to 69632
#define EVT_LOGO_LIGHTS_TOGGLE                            (THIRD_PARTY_EVENT_ID_MIN + 14018)
 
I dunno where the term "KVARS" came from... but, it's a truly inaccurate term.. sim events are not variables. They are defined, known constant values that the sim will respond to. I think the term "KVAR" needs to die a rather painful developmental death. :p
 
I dunno where the term "KVARS" came from... but, it's a truly inaccurate term.. sim events are not variables. They are defined, known constant values that the sim will respond to. I think the term "KVAR" needs to die a rather painful developmental death. :p
They're referred-to as such in the SimConnect docs a few times, most notably in the "variable types" list which is lumped in with the rest of the RPN docs. I agree that referring to them as variables is inaccurate (and often confusing), and same with "H" types which are just another type of event. OTOH there are read-only var types, like Environment, so maybe it's fair game to have "write-only variables" also... :)


SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_LOGO, "LOGO_LIGHTS_SET");
SimConnect_TransmitClientEvent_EX1(hSimConnect, 0, EVENT_LOGO,
SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY, 1, 1);
Above doesn't work - any help?

I'm presuming that's because the PMDG737 logo lights are controlled by a custom event as @FoxtrotScenery just kindly pointed out. Otherwise, more details on what "doesn't work" means would be helpful. (Sorry, didn't see this question part earlier since you added it as an edit.)

In general, don't assume that just because an event or sim var is listed in the SimConnect docs that it will always work with any particular model, 3rd-party or stock. The docs just list all the built-in vars/events (not always 100% accurate, either). Whether any particular one works with a model is usually a trial-and-error process. Personally I find it a huge time saver to have a GUI tool which can be used to test these things in real-time... rebuilding code just to test the next thing gets old quickly.

Cheers,
-Max
 
@FoxtrotScenery - thanks for the response. Yes I'm somewhat familiar with that file. They use a different simconnect api.

I wanted to use `SimConnect_TransmitClientEvent_EX1` because it seems more generic - with those KVARS.

@MaxPaperno - I have both the calls successively in a keyboard event callback. By "not working" I mean that it doesn't toggle the logo lights - switch switch doesn't move.

I tried 1, 0 and 1, 1 for the parameters at the end. First is 1 for toggle on. The second is the index.
 
I wanted to use `SimConnect_TransmitClientEvent_EX1` because it seems more generic - with those KVARS.
I'm not familiar with the PMDG SDK, but there's a way to map/transmit custom events like this. Read the MapClientEventToSimEvent() docs, specifically the 2nd paragraph of the `EventName` parameter. So the "name" for the custom logo lights event quoted earlier (0x11000 + 14018) would be "#0x146C2" or "#83650". After mapping the event name to your enum ID, you can then use `TransmitClientEvent()/TransmitClientEvent_EX1()` to actually trigger it, as with any other built-in Event ID.

I have both the calls successively in a keyboard event callback. By "not working" I mean that it doesn't toggle the logo lights - switch switch doesn't move.
I'm not sure what a keyboard event callback is, but since there's a custom event for toggling the logo lights (vs. the standard TOGGLE_LOGO_LIGHTS), I'd guess that the standard LOGO_LIGHTS_SET isn't going to work either. Maybe there's another custom one for SET as well? Of course I have no idea why they wouldn't just use the standard events in the first place... 🤷‍♂️

To test that your code actually works I'd try a different model or event... like one of the simpler included aircraft and NAV/PANEL/LANDING lights (which they all should have). Anyway the fact that one particular event doesn't seem to work isn't definitive. What you're trying seems like it should work in general.

I tried 1, 0 and 1, 1 for the parameters at the end. First is 1 for toggle on. The second is the index.
FWIW, there is no circuit index zero (0), it will always default to index 1 if zero is passed as a parameter (so in the older `TransmitClientEvent()` with only one parameter value it still works w/out passing any index at all). It's possible the 737 uses some other circuit (> 1), but that's a guessing game w/out docs or digging into model files/dev mode Behaviors.

HTH,
-Max
 
Back
Top