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

Is this easy to do?

Messages
135
Country
us-kentucky
What would I need to do to make a C boolean variable visible to a SimConnect app?

I have not yet programmed with SimConnect and am wondering if there is anything special I would need to do to allow SimConnect to control a simple switch.

Patrick
 
Hi Patrick,

A little more info on what exactly you want to do would make it easier to answer :-> Are you trying to interface between a real external hardware switch and the sim? Are you trying to toggle an existing bool/panel var within the sim? Do you want to create your own panel gauge with associated variable (in which case you probably want to create a gauge, not a SimConnect client)? Etc...

SimConnect can be used to do those. Some sim vars aren't actually set as variables but are set by mapping and sending an event, others are set by sending data to a var, etc.

If you haven't yet, look through the sample code included in the SimConnect portion of the SDK. There are examples of doing things like toggling the landing gear, retrieving various types of data, creating AI objects, etc.
 
Hi Patrick,

A little more info on what exactly you want to do would make it easier to answer :-> Are you trying to interface between a real external hardware switch and the sim?

Basically, I've created a C gauge that has a switch that doesn't exist in FSX (a new instrument). As I want it to be operated by a physical button, I want SimConnect to be able to see/change the state of a BOOL/bool var within the C gauge .dll.


Are you trying to toggle an existing bool/panel var within the sim?

If by existing, you mean a var within the gauge, yes. However, this is a user created switch that has no existing FSX equivilent.


Do you want to create your own panel gauge with associated variable (in which case you probably want to create a gauge, not a SimConnect client)? Etc...

I want SimConnect to be able to control a user create switch on a user created gauge.


SimConnect can be used to do those. Some sim vars aren't actually set as variables but are set by mapping and sending an event, others are set by sending data to a var, etc.

If you haven't yet, look through the sample code included in the SimConnect portion of the SDK. There are examples of doing things like toggling the landing gear, retrieving various types of data, creating AI objects, etc.

Yes, I'm trying to find the example code as the SDK text didn't really clue me in to the process. But, what I guess I'm asking is what do I do in the C++ code to make a bool visible/settable by SimConnect. =)

For example, while my altimeter can be easily adjusted with SimConnect without any changes to my code as I use the standard INC/DEC c vars, for something where their does not exist a sim var I need to know how I can setup my bool switch in a way SimConnect can push/release it with a real button vs. the mouse as I currently code it.

I'm going to have another look for any SimConnect example code in the SDK, but if you can point me to which example code might be the one to look at that would be great.
 
Last edited:
Hey Patrick,

OK, one way to do what you want is to have both the gauge and the hardware interfacing module (either .DLL or .EXE) both use SimConnect. The gauge can use the Client Data area functions to create space for a variable in the Client Data area and set a data request to trigger whenever the data changes, and the hardware interfacing code can write to that area when the hardware switch changes state, causing the trigger to fire in the gauge side code and it can retrieve the new value from there. The gauge side code can also update the Client Data variable, say when the user uses the mouse to click on the gauge's switch, so other modules can sync with its current state. I haven't done anything with the client data area stuff myself yet, so can only offer the generalities above, but they should point you at the right parts of the SimConnect API to look at (AddToClientDataDefinition for starters).

I've sent off an email to Dave to see if there's an easier way to do what you want and will post if he has an alternative method, but the above should work fairly well.
 
Hi Tim, Happy New Year to you!

OK, one way to do what you want is to have both the gauge and the hardware interfacing module (either .DLL or .EXE) both use SimConnect. The gauge can use the Client Data area functions to create space for a variable in the Client Data area and set a data request to trigger whenever the data changes ...

Yes, all rather complex for a mechanism that is already there much more flexibly for recognised FS switches (Sim Events and Sim Vars) -- excepting of course those where MS too omitted to supply them, as in the EFIS ND control switches in the Boeings -- range, mode, etc.

What is really wanted is a way for user- or gauge-defined Events and Variables to be created and thereafter used (and even assigned) just like the built-in ones.

This especially applies to any switch or knob which is "mouse-clickable" in the cockpit. These should always automatically have events and/or variables associated with them. There are too many mouse-only functions, and the Gauge construction system currently allows this to proliferate.

I've made these requests / suggestions time and time again. Maybe one day ...

Best Regards

Pete
 
Tim,

Hey Patrick,

OK, one way to do what you want is to have both the gauge and the hardware interfacing module (either .DLL or .EXE) both use SimConnect. The gauge can use the Client Data area functions to create space for a variable in the Client Data area and set a data request to trigger whenever the data changes, and the hardware interfacing code can write to that area when the hardware switch changes state, causing the trigger to fire in the gauge side code and it can retrieve the new value from there. The gauge side code can also update the Client Data variable, say when the user uses the mouse to click on the gauge's switch, so other modules can sync with its current state. I haven't done anything with the client data area stuff myself yet, so can only offer the generalities above, but they should point you at the right parts of the SimConnect API to look at (AddToClientDataDefinition for starters).

I've sent off an email to Dave to see if there's an easier way to do what you want and will post if he has an alternative method, but the above should work fairly well.

Excellent. I see now my confusion was caused by seeing FSX as the server and the SimConnect .exe as "the" client, when it appears that from what you are saying, I should write the gauge as a .dll "client" and the two clients can then interface via the above.

Thanks fro pointing me in the general direction.


Hi Tim, Happy New Year to you!

Yes, all rather complex for a mechanism that is already there much more flexibly for recognised FS switches (Sim Events and Sim Vars) -- excepting of course those where MS too omitted to supply them, as in the EFIS ND control switches in the Boeings -- range, mode, etc.

What is really wanted is a way for user- or gauge-defined Events and Variables to be created and thereafter used (and even assigned) just like the built-in ones.

This especially applies to any switch or knob which is "mouse-clickable" in the cockpit. These should always automatically have events and/or variables associated with them. There are too many mouse-only functions, and the Gauge construction system currently allows this to proliferate.

I've made these requests / suggestions time and time again. Maybe one day ...

Best Regards

Pete

I have to agree with Pete completely. In fact, I spent some time figuring out how to easily let a user-defined switch be clickable, and user-assignable to any key or button and still have the gauge "know" it was being pressed or release, even if you switch input device mid-throw.

Since the user could not use the standard options to assign a key or button to my switch, I did it through the panel.cfg 5th parameter.

Patrick
 
Back
Top