Sync of latched ON-OFF toggle switch to simulator - how hard?

Hi all!

I’m wondering how hard it is to get latched ON-OFF toggle switches to automatically sync with some states of the simulator. Example below. It could be just a piece of software/extension to FS2020, or maybe it requires an arduino. Either way, just wondering how you would do it. Here’s what I mean:

I have a Thrustmaster Warthog Throttle. I would like the bottom left toggle switch on the base, that latches up or down, to control the battery master switch in the aircraft. If the switch is up, master is on, if down, it’s off. I would like this setting to automatically happen when i start a flight. It should initialize. E.g., i shouldn’t have to use a joystick gremlin macro to simulate a single button push that toggles the master battery when i move it up or down.

I can see that some piece of software could need to periodically measure the state of the Thrustmaster button that corresponds to that toggle switch being up, and if so set the sim var, and if it’s off, it infers that the switch is down and sets it off. It could just do this at 1hz or something.

This must exist? Can mobiflight do it? I know it has an Auto_Sync feature, but i see warnings to use that with ON-OFF-ON switches (or ON-ON here). Anyone tried it? FSUIPC?

Be grateful for any guidance! Thank you!

so wait. If you start in a plane hot and on the runway, but your physical battery switch is set to off, you want the sim to recognize the battery is off and update the plane as required? Or if you’re at the gate and you left your physical battery switch in the “on” position from last time, you want the plane to automatically recognize this and flip the battery on when you click “start flight” after loading in. Am i understanding this?

I would think you’d have to hack the startup state for each plane to read a particular input when you first load in and then adjust the plane as required based on that input. I don’t think what you’re trying to do is as easy as a piece of software that does it all for you.

yep! so that it’s realistic - the plane is set by the hardware.

i figured out a piece of it - i wrote a joystick gremlin python plugin that sets a virtual vjoy button ON when, for example, this toggle switch is off. so now i have one button ON when the switch is ON, and a different button ON when the switch is off.

then i was goign to map these to, e.g., BATTERY_ON, and BATTERY_OFF in the SIM, and hope that it updates based on those button pressed states which will be set going on.

come to think, i don’t htink this will work because

  1. i dont’ think the sim checks these vars, they are only seen when they are pressed/activated, and
  2. there are a bunch of things that only have TOGGLE inputs, not ON and OFF.

i think you’d have to go deeper and look for sim variables and set them directly. ugh!

I think you’re onto something with this. If the sim were checking variables constantly, it would probably run like doody.

You may be able to jerry rig something using Spad.Next to at least bind on/off for that switch but i think given the limitations of the game it might be a while before plane states can be set based on hardware states of peripherals.

yup thanks @Portalearth420 !

Actually right now I have an even more basic question - can you even set/read all of the switch states with SimConnect and the MSFS2020 SDK? I’m assuming that’s gotta be a yes… but i’m still seeing lists of variables (at offsets etc. in FSUIPC world) that look the same as the in game mappings.

E.g., maybe it’s just not possible to directly read or set the, e.g., “Alternator switch” state on the Asobo C172, because even at the lowest, most direct level (writing a C++ app with the SDK and SimConnect API) you just don’t have access to that.

i think you must… that’s the current dive.

This is totally do-able. As you have recognised the sim has to follow the hardware. I do this in Air Manager but I guess it should be possible in other apps if they have read/write and logic/scripting capabilities. It’s a simple case of sending the appropriate event if the current sim switch state does not match the hardware switch position. This always forces the sim to stay in sync.

You’re right sling! Found a few videos on SimConnect, and got the SimVarViewer sample app to change flaps.

I see a lot of things are driven by events rather than changes of vars (or the vars dont allow setting, so the event must be how you toggle).

Does Air Manager already do this?

I’m just kind of amazed a solutiom doesnt exist for at least the common hardware out there. Or maybe Mobiflight does it, and i havent realized.

Thanks!

Air Manager can read or write to vars that allow it. It also supports the sending of events to which you enquire. This is nothing special over what a few other apps can also do. What it also offers is a way of adding whatever logic you want into the mix. It will also interface with game controllers if needed. Other apps may also offer this but I personally find it the most flexible and easiest to use if you don’t mind a bit of scripting to achieve what you want. It’s not for everyone but IMHO opinion the most complete all round 3rd party app for communicating with the sim. Interfacing with almost any hardware is just a small part of what it can do and what people use it for but it does so much more than just hardware.

I can’t speak for the latest versions of the other apps as I tried them all a few versions back now and I now only use AM for all my sim communication needs. One single app does all for me.

That sounds good! Ill look at AM!

But gah. Already found a limit in the form of missing simvars.

I thought I would test the plan by seeing if i could at least read the state and/or change the state of the toggle switches on the NX Cub using a SimConnect solution.

I fired up SimVarViewer and ugh - theres no var for the fuel pump switch! None of them toggle with it.

Now it may be that there are events to turn it on and off, so it would be ok, but i doubt thats the only switch with no var.

The switch toggles in the game (actually i havent checked if it affects the engine!). But assuming it functions in the engine system then exposing these vars must require extra code.

I hear mobiflight made a WASM module to get access to more G1000 vars. Sounds like a ton of work?

With AM are there things you cant access?

It’s very un-likely that there is no associated var. Let me have a look at that one specifically and I’ll come back with my findings.

Amazing thx!

As I suggested there is one. Try “GENERAL ENG FUEL PUMP SWITCH:1”, “Bool”.

It returns true when the switch is on and false when off.

It’s a standard SDK documented variable. Nothing fancy.

Genius! Thank you @Sling380 so much! It works.

I had not specified an index. Needs that.

I dont see vars for the cabin air source or hot air knobs, but im guessing those are dummies in the sim so probably dont have one.

Ill work my way through the gps and Autopilot, to see how far we could get!

Thanks again!

1 Like

Hmm also not seeing glareshield lights and placard lights in simvars.

As a rule, whats the process for finding these, including index and data type?

Obviously the docs is first place to check. But for glareshield for example, i see the LIGHTS GLARE var, but obvious combinations of index and data type (1, percent) dont yield a response.

Is there any way to do this without exhaustive search? EG read the Asobo source code?

Ty!

This is one of the area’s where MSFS is very weak. Unfortunately because they chose to base this on the old FSX methods it’s so un friendly to use it often needs a lot of investigation to track down the var or event required. There is no one place that lists them all out like Xplane has. There are multiple places to start your search but ultimately you will be having to dig into files to find what you want. It shouldn’t be this way but it is. Even then a lot of them are not accessible right now. There is a big votable topic in these forums asking for access to all these currently in-accessible ones. If something moves in the cockpit but doesn’t do much else there will be a var for it but almost every time the var will be one of the ones we can’t currently get at.

Found and up voted! I see it has been adopted and should get done at some point!

1 Like

We haven’t heard anything for a while and in true Asobo style I wonder if they actually understand what it is we actually want. I have a suspicion that we will end up with something that is not what’s required. I hope I’m wrong.