MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

05/03/2024 - This forum is read-only

The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!

See you on our MobiFlight Community Discord server.

A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.

The forum is still providing a lot of good content, hence we keep this information accessible.

Posts: 12
Is there a way we can setup one rotary encoder for multiple functions.

For eg, one push button activates AS1000_MFD_HEADING_INC and AS1000_MFD_HEADING_DEC and
push button again deactivates heading adjustment but activate AS1000_AP_ALT_INC_100 and AS1000_AP_ALT_DEC_100

2021-11-13 13:29
From: ETSI, Germany
Posts: 6010
YES..... "Via PRECONDITIONS" (And in FS2020 Events pretty sure also via code within the Scripts...: But this is advanced and not needed here)

Easy logic....
You create a Input Config for each situation..... In Your case you create 2 Configs..... Both use the SAME Device (the Encoder e.g.) ...... One is set for Function 1..... The other for Function 2.

If you NOW use it directly, then a turn of Encoder would execute BOTH functions same time.... It would increase eg. the heading AND the Altitude in one run..... Cause Both Configs work and we not already define a Condition !!!

In Precondition Tab ( of these 2 Configs) we can say "Only work aslong the value of Config XXXX is e.g. 1"

In your case..... Your Selector (Button e.g.) must write a Output Config to e.g. 1 or 0 .....
We do this by make a INPUT for that Button and write a Mobiflight Varriable ..... Syntax if($=1,0,1) So we "toggle" this Variable with every press between 1,0,1,0,1,0 and so on.
Next Step.... We make a OUTPUT Config that read this Variable...... Cause (for now) we can use only a existing Output Config for a Precondition indication . ( In the future we plan to directly use Variables.... so this step can be left out in the future).

Last Step: You say in your Input Configs for the Encoders E.g. Headfing Encoder: Precondition : ONLY WORK aslong the Output Config "Var status" = 1 ...... In the Altitdue Encoder you say "ONLY WORK if Config "Var Status" = 0

NOW Encoder only do one thing.... Related to the current Value of your Variable..... If you toggle the Var by press the Button then the Other Encoder Config start working and do the other thing !
Good Luck !
2021-11-13 16:09
Posts: 12
Thank you. Worked like charm.
In the button input (MobiFlight Variable), I had given value as if($=1,0,1)
Could you please elaborate on that syntax?
2021-11-13 19:51
From: ETSI, Germany
Posts: 6010
This is a easy IF Statement..... Means IF(Condition,THEN,ELSE)
So you say ..... if($=1......) this means IF the Current Value of the Config you read or wright (So in Your case the Input Config of the Mobiflight Variable) is currently "1"
The second part say if(Condition,then,else) ..... if($=1,0,1) ..... So you say.... If Value i currently 1 THEN set to "0" .... ELSE ( So if Value is currently NOT 1) set to 1

In easy words.... If you press the button then MF check if the Target $ (Your variable) is currently "1" ... if Yes it set to "0" .... if Not it set to "1" ..... So it toggle it !


Just a example.... You like to "toggle" a variable above multiple values.... Lets say it should swap between 0,1,2,3,...0,1,2,3, and so on.
Her Formula for Input button would be : if($=3,0,$+1)
It means.... If Value is currently 3 at button press THEN move back to "0" .... ELSE ( So value is NOT 3 ... means its currently 0,1, or 2 then Add 1 to the current Value ).
Example: Value is currently 3 .... So Formula use THEN and set to 0 ..... If value is currently 1 formula use ELSE and say "$+1" or here "1+1" Result is 2.... it write 2 to the Variable.

You see.... All is posible, aslong you know the syntax !
LAST NOTE: This is working but this is not the "only truth" .... You can use many other formulas with the same Result. Pro Users e.g. work mostly with a Modulo% instead of the IF.
Good Luck !
2021-11-14 00:07
Posts: 7
I am trying to do something similar with 1 Dual concentric encoder being used for Com1/Com2 and Nav1/Nav2 so inner and outer control the Mhz and Khz. and the center button on encoder does the swap. I will be using 2 momentary buttons to activate the mode eg, Com1 or Nav1 and a 2nd press for Com2 and Nav2. I have a varable input for com and nav, each having if($1,0,1). In turn there is an output for COM_Status and NAV_Status. My issue is if I set a precon for COM_Status to be anything but 0 or1 to prevent the Dual encoder from changing the Nav Mhz/Khz, then I get Precondition not satisfied. I also have a precon on the NAV encoder inputs to check for NAV_Status, which is satisfied but the COM_Status is blocking. How can I make the Com swap button and Variable turn of the encoder to the coms when I push the Nav button?
[Last edited by Planker1010, 2022-09-04 09:12]
2022-09-04 07:43
From: ETSI, Germany
Posts: 6010
Hi Planker

As deeper and more complex the situation is build, as more advanced the code and logic must be.

You like to controll FOUR things with ONE Device (Technical 3 devices cause the Dual Encoder represent 2 Single Encoders and a Push Button.)
Means you have 4 Situations : COM1, COM2, NAV1 and NAV2.
Each Situation need 3 Input Configs .... One for Mhz on one Encoder, One for Khz on the other Encoder and one for the right Swap Signal on the Button.
So overall 12 Input Configs !

If i understand right you have 2 Buttons.... One should controll COM/NAV Toggle..... The Other Controll 1/2 Toggle.

Means you need 2 More Input Configs.... Each Button make a own Variable toggle between 0/1.
You need as explaned above 2 Output Configs also that Read these Variables again to use them later for the Preconditions!

NOW we need a logical Table to understand what happen..... For example these i would use....

Variable A = 0 .... Variable B = 0 ---> COM1
Variable A = 0 .... Variable B = 1 ---> COM2
Variable A = 1 .... Variable B = 0 ---> NAV1
Variable A = 1 .... Variable B = 1 ---> NAV2

Means you need to use that logic in the Preconditions!
Here we work with the AND Option!
You say e.g. in the Encoder COM1 as precondition : Only work if Config VarA = 0 AND Config VarB = 0


As said above. There is no perfect way. In Theory you could also do this with one Var by write it to 0,1,10,11
This avoid the AND and the 2 Config usage.
And as said above... Also Modulo instead if IF can be used.
Good Luck !
2022-09-04 14:11
Posts: 7
Thank you for your reply. Yes I thought about doing it that way, but what I was hoping to do was 1 button is Com1/com2 and the other is Nav1/Nav2. The issue I was having I found a work around.

In order for the encoder configs to work for just the Com1/2 button I needed it to send a variable that would tell the Nav1/2 configs not to operate. And the same for Nav with coms.

So on the Coms button I have on press the assignment of 0,1 for the com1/com2, on release of push it sets Nav to value 3. This allows the encoder configs for com1/2 to have to precondition of var=3 for Nav_State and var =0 work for Com1. If condition is var=3 for Nav_State and var=1 work for com2.

This has allowed pressing of the Com button to disable the Nav encoder configs. I have done the same but opposite for the pushing of Nav button for disabling Coms.
I’m fearful that once I add let’s say 3-4 more buttons the preconditions list and the on release of each button may get long but making all other buttons that are “off” be a var=3.
[Last edited by Planker1010, 2022-09-04 20:53]
2022-09-04 20:46
From: ETSI, Germany
Posts: 6010
I´m Sorry.

Its hard to me to understand this.
Basically we normaly try to rebuild systems, that exist in real aircrafts.... Whatever the sim not allow this directly!
E.g. in a real Aircraft you woul never find a Encoder that is used for COM and NAV. Simply its dangerous to use 2 different things with one Input devicee in case of possible issues.

Whatever.... I would say.... All ( or better said most of the things) are possible.... I just need to know WHAT you like to do. Then i can think about the right Config and logic to make this possible.

So tell me please... How does your panel look like ?
How many Encoders do you got.... How many Bottons, How many Displays ?
What do you like to controll? (I expect COM1, COM2, NAV1 and NAV2 )
What system should be shown on the Output ? ( I expect you have 2 Displays , one for ACT and 1 vor STBY)
What action should "swap" the System ?

In easy words.... Tell me exactly what you expect! Then i can guide you to the right way to build it !
Good Luck !
2022-09-06 00:10
Posts: 7
No problem, thank you for helping. I understand that modeling things in a way that mirror a real craft is preferred, and if I wasn't using VR, displays or even a cockpit would be what I would build. My goal however Is to use this controller box in VR, I want each button to control the most commonly things used in VR as to not break the immersion and not needing to fumble around looking for multiple encoders and potentiometers.

So here is what I am doing, The setup will have 1 dual encoder mounted above 9 buttons. in rows of 3 for easy usage. The list below are the button functions.
Button 1= Com1/Com2 toggle
Button 2= Nav1/Nav2 toggle
Button 3= HDG
Button 4= Alt
Button 5 =Vert Speed/Baro
Button 6= OBS1/OBS2
Button 7 = G1000 PFD FMS
Button8 = G1000 MFD FMS
Button 9 = Auto Pilot

So you can see with the encoder I am using it to increase and decrease and the the push part of encoder to swap or set for each of these functions. I have it currently setup and working where if Coms are being used it has a value of 0= Com1 and 1=Com2 on press of button 1. The Variable is set by an input and the button push controls the action (2 separate input items). There is then the 3 Encoder configs respectively for each Com1 and Com2 with preconditions to read the value. In the output there is a "Com_State" setup to read the value for the variable. Now when I want to use Nav features (or any other button) with the setup set to the same above configuration. However, I have to make another additional input to change the Coms Variable to 3 (On button release) so that a precondition can be set for Nav functions to only work if (NAV1 =0 and COM1/2= 3) that makes it so it disables the Com configs since the value isn't a 0 or 1 and that the NAV has successfully set it to a 3 or it wont change over.

Now for the part I'm hoping for some tweaking if there is any, as I'm scaling this controller, each new button (or function ie Alt, AP etc) is requiring me to make more inputs for each button so that releases of buttons make the variables for Com, Nav, Hdg etc a variable of 3, so that my preconditions for values to only be 0 or 1 will not trigger items other then the current button. I hope this makes sense, below is an example.

Button - Coms
Com1 Encoder Outer. Allows MHz Increase and Decrease. Has precondition for Com_State to be 0
Com 1 Encoder Inner. Allows KHz increase and Decrease. Has precondition for Com_State to be 0
Com 1 Encoder Push. Allows swap of Stby to active. Has precondition for Com_State to be 0
Com 2 Encoder Outer. Allows MHz Increase and Decrease. Has precondition for Com_State to be 1
Com 2 Encoder Inner. Allows KHz increase and Decrease. Has precondition for Com_State to be 1
Com 2 Encoder Push. Allows swap of Stby to active. Has precondition for Com_State to be 1
Input- Com1/Com2 swap. This pulls the generic com swap feature from MSFS2020 custom dropdown.
Input- Com1/Com2 Variable. This sets the if($=1,0,1)
Input- Coms Value 3. This variable sets the on release of (Button 2 Nav) to set value 3.
Input- Coms Value 3HDG. This set the on release of (Button 3 HDG) to set a value 3.
ETC ETC for the next 6 buttons on setting value to 3 on release to ensure that COMs value is 3 if any other button than COMs is pushed.

So as you can see when I add a new button I have to add a new release for that button to set coms to value 3. So I will have 9 in total for just coms. Which means each button will have 9 as well. On top of that I have to go into the Encoder configs for each and tell it to only read Value 0 or 1 for the selected button and to make sure that all other buttons values are set to 3. I can keep doing it this way, but with 4 buttons done I have 23 inputs. (I was hoping there would be a way to add multiple events to the push/release of an input so that is can do for my example, change the value to 3 for 7 other inputs.)

2022-09-06 22:57
From: ETSI, Germany
Posts: 6010
You have a thinking issue.....
Your way work, but its to Difficult at the end !

The advanced Factor in your build is that you have 9 Modes BUT some of the Modes ( e.g. COM1/COM2) have a Sub Mode with another 2 different things)

Lets split this up more easy.....
Lets say hypothetical .... All 9 Modes include only ONE Thing. ( So lets say COM's only include COM1)
NOW we would need only one single Mode Variable.
Every of your 9 Buttons would write the SAME Variable....
COM set it to 0 On Press..... NAV set it to 1 .... HDG set it to 2 ... Alt set it to 3 and so on.
Means you not need this "Set to 3" stuff in case if you press another Mode Button then Your in THAT Mode already!
Lets say you Press HDG Button .... Mode Change to "2"
So The Encoder Input Configs for Inner, Outer and Pushbutton work for the HDG Function cause all have PRecondition "Only work if MasterMode =2"
Your Com Inpout Configs would not work now cause those have "Only work if MAsterMode = 0"

Now we need to include the Double Function of the COM .NAV and OBS Buttons.... So they change the MODE and also change the Sub Mode!
The Key is the AND Operator.

Lets say.... If we press the COM Button we write as written above the MasterMode to "0" AND we also like to Toggle the Sub Mode.
So we build another Variable ( And for sure another Output Config that read it to handle it in MF later). Lets call it "SubMode"
The COM Button On PRESS will now write "MasterMode" to "0" ( To Define COM is active). And the Release will write the "SubMode" with if($=1,0,1)

Your COM1 Inputs now say "Only work if MasterMode=0 AND Only work if SubMode=0"
Your COM2 Inputs say Onlay work if MAsterMode=0 AND Submode=1

Means if you press later a other Button ( e.g. HDG) then your COM Inputs stop working ( Cause MasterMode is now no longer 0)
If you press the COM Button while still in COM Mode then it again write the MasterMode to 0 ( No effect its still 0) but the Release would do another toggle between COM1 and COM2.

More advanced ideas.....

1. The Sub Mode can be shared.
You not need a own Sub Mode System for COM NAV and OBS. When you toggle COM1/COM2 your not same time in NAV or OBS. So we not care if also those would be swap same time in case we not see or handle them. So you can "share" this system for all 3

2. Avoid the first toggle.
With the upper technics the first press on the Mode Button of COM would set the COM Mode BUT!!! It would also on Release execute a toggle.
We could avoid this by create 2 Configs for that Button....
One Only work if Mode is currently NOT Com already (So Value of MAsterMode is NOT 0)
In that Mode we only say on Press "Set Master Mode to 0"
The Other Config only work if MAsterMode is STILL "0" (So we are right in COM)
This Config say "Toggle Submode"
This avoid us from this unless toggle we not want by itself.

3. Reset the Mode to "0"
If your in NAV Mode and Your in NAV2 Selection and then you press the COM Button you would be now in COM2 ( Cause Mode is shared and remain)
If you not like this you can use the idea"2" and use there a release command.
You say.... IF i press COM Button and Mode is currently NOT Com then at first i like to Reset the SubMode to "0" by the Press..... And the Release will now set the Master Mode to 0
Press COM first time set Mode to COM and set Submode to COM1 ..... Second Press just toggle SubMode between COM1/COM2
And like always.... Using a other Button change system completly!

What you need at the End:
1 Set of Input Configs ( Inner, Outer and Pushbutton of the Encoder) for each System and 2 Sets for the Double Systems for sure!
9 Configs for the 9 Mode Buttons
2 Output Configs for the Master and Sub Mode.
And Optional 3 Duplicated Configs for the MultiMode buttons if you like to make the more advanced ideas above !
Good Luck !
2022-09-11 02:41
Posts: 7
Thank you for this sorry for so long on the reply. I am confused how I can have only 1 output config for MasterMode. I am trying to configure for MSFS. So where can I define it to look for all values.
2022-10-03 09:04
From: ETSI, Germany
Posts: 6010
You not "look" for something in the Sim.
Technical we not care about the Sim Radio at all.....

The "Master Mode" is generated by Ourself !

Your 9 Mode Buttons all write a "Mobiflight Variable" ( all the same) ... Lets name it e.g. ModeVar
Each button send another Value.... beginning with "0" !!!
So The Mode you like to see after Systemstart ( I expect COM) have On Press : Mobiflight Variable "ModeVar" Value 0
Means always when you press THIS Button the Var is set to "0"
Next Mode ... e.g. NAV use for the Button also the same Var "ModeVar" but value is "1".
So if we press this button the Variable is set to 1
Same for other Buttons.... 2,3,4,5 and so on.

Finally you read one time in a Output Config the Mobiflight Variable "ModeVar"
So we can use this data in other configs e.g. for the preconditions.
Output Config (lets call it MAster-Mode) read Mobiflight Variable "ModeVar".

And thats it.... Now you can use the Config "Master-Mode" as a precondition in all of your Encoder Input Configs.
If you say there .... Precondition "Only work if Master-Mode = 0 then it only work if COM is active !

Same Idea for the SubMode....
Here your Input write another Var .... Call it e.g. SubmodeVar
To reset it value would be 0 .... If you just like to toggle it, value is : if($=1,0,1)
You also must readout it with a Output Config to be able to handle it later for Preconditions.
Same like above.... Create a Output... Call it e.g. SubMode and read the used Variable "SubmodeVar"
Good Luck !
2022-10-03 15:50
From: ETSI, Germany
Posts: 6010
Hi Again.

Its hard to me to solve this without see what you do....


Com MasterMode=0
Nav MasterMode=1

Why do we have again 2 Master modes for COM and NAV..... I Still explane that the one MasterMode is used for all Systems....:
So COM, NAV and all the others work with the ONE Master Mode!

Problem is.... I not understand from your reports what you exactly doing wrong and also not 100% what you expect.


So now I have the input and output for the 2 modes of the Com button. I have 3 configs for the encoder for Com1 and 3 for Com2. But now i am missing a way for MSFS2020 to take the mode and apply it. Do I need a 3rd input config for the Com button to tell the Sim to recognize it for com_stby_swap?

I still tell you HOW you setup the 3 Configs for Inner, Outer and Swap Button ..... Each config will need a Precondition..... And THERE you define in what situation it should work.
In your case e.g. COM1 Configs ( Inner, Outer and Button) should only work if "Master Mode" Config show value for COM (0) "AND" "Submode" config show value for ModeA / COM1 (0)
For COM2 the Configs also use "MasterMode" = 0 (Cause they are also a part of the COM Mode) But those have AND SubMode = 1 Cause now We like to handle COM2 So Mode B from our Submode System.

I explane the loogic already in a former posting.....

NOW we need a logical Table to understand what happen..... For example these i would use....

Variable A = 0 .... Variable B = 0 ---> COM1
Variable A = 0 .... Variable B = 1 ---> COM2
Variable A = 1 .... Variable B = 0 ---> NAV1
Variable A = 1 .... Variable B = 1 ---> NAV2

If you not be able to do this, then we need a personal meeting.
Please Joind DISCORD and prepare a Headset and run Discord App on the Computer, where FS2020 and MF is running.
Then you can share screen to me and we can talk.
I can see what you do, and we can build/rework your Configs together.
I´m Online normaly every WED and THR at 20.00 UTC+2
Good Luck !
2022-10-08 14:14
Posts: 7
I dont think that will be necessary, I was able to figure it out after a few tries from your previous post. But thank you again for all of your help.
2022-10-13 06:30