1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Is this easy to do?

Discussion in 'SimConnect' started by Waugh, 25/1/08.

  1. Waugh

    Waugh

    Joined:
    3/10/06
    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
  2. beatle

    beatle

    Joined:
    28/9/06
    Messages:
    324
    Country:
    us-virginia
    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.
  3. Waugh

    Waugh

    Joined:
    3/10/06
    Messages:
    135
    Country:
    us-kentucky
    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.


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


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


    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: 26/1/08
  4. beatle

    beatle

    Joined:
    28/9/06
    Messages:
    324
    Country:
    us-virginia
    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.
  5. Pete Dowson

    Pete Dowson

    Joined:
    25/9/06
    Messages:
    315
    Country:
    unitedkingdom
    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
  6. Waugh

    Waugh

    Joined:
    3/10/06
    Messages:
    135
    Country:
    us-kentucky
    Tim,

    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.


    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

Share This Page