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

Triggering xml event with a hardware button instead of mouse

This code is the closest I have gotten. It operates by inputting the letter A as it should
but I cannot understand why it is doing it without me switching my Lvar to 1. Even after
this code resets it to 0, when it loops it reads it as 1 and operates again? All without me touching
my assigned joystick button.
Code:
<Update id="GCU477">
(L:Stinger2k2_A,bool) 1 ==
if
<Script>65 chr (&gt;@c:IcaoSearchEnterChar) 0 (>L:Stinger2k2_A,bool)</Script>
</Update>


Ok. You're very close, but the if statement is done a little bit incorrectly - you didn't use brackets. As you have written it, you are telling the gauge to enter A continuously.

Try something like this:

XML:
<Update>
 <Script>
  (L:Stinger2k2_A,bool) if{ 'A' (>C:fs9gps:IcaoSearchEnterChar) 0 (>L:Stinger2k2_A,bool) }
 </Script>
</Update>

or

<Update>
 <Script>
  (L:Stinger2k2_A,bool) 1 == if{ 'A' (>C:fs9gps:IcaoSearchEnterChar) 0 (>L:Stinger2k2_A,bool) }
 </Script>
</Update>

Place that code block toward the top of the gauge.

Maybe this will get it to finally work.

Bob
 
Last edited:
I forgot about the copyright issues, can't do that then as it's a Carenado gauge.
Sorry, yes, I am using FSX.
Further clue......I just tried the above code without the script loop, instead of the script loop I tried it inside ,{ }, and it won't work at all?should I replace the script lop
with ( ) ?

Keith
 
Let me know if
XML:
<Update>
 <Script>
  (L:Stinger2k2_A,bool) 1 == if{ 'A' (>C:fs9gps:IcaoSearchEnterChar) 0 (>L:Stinger2k2_A,bool) }
 </Script>
</Update>

works ...
 
Let me know if
XML:
<Update>
<Script>
  (L:Stinger2k2_A,bool) 1 == if{ 'A' (>C:fs9gps:IcaoSearchEnterChar) 0 (>L:Stinger2k2_A,bool) }
</Script>
</Update>

works ...

No........................but this did !!!!!!!!!!!! Weyhey. whoop whoop. !!!!

Code:
<Update>
 <Script>
  (L:Stinger2k2_A,bool) 1 == if{ 65 chr (&gt;@c:IcaoSearchEnterChar) 0 (>L:Stinger2k2_A,bool) }
 </Script>
</Update>

I can't thank you enough for sticking with me.
All have to do now is get the other 25 letters working :)

I hope this thread can help others too that maybe wish to do a similar thing.

All the best
Keith
 
Keith,

Very glad it's finally working for you. As you complete the gcu 477 key assignments, remember that only the gps variables like IcaoSearchEnterChar need to be addressed in the Carenado addon gauge. L:Vars like the buffer button are shared across the panel set so they don't need to be addressed in the addon gauge.

You're using FSX, and you're sure that
XML:
<Update>
    <Script>
        (L:Stinger2k2_A,bool) 1 == if{ 'A' (>C:fs9gps:IcaoSearchEnterChar) 0 (>L:Stinger2k2_A,bool) }
    </Script>
</Update>

doesn't work?

Does anybody know why the XML parser might not like the above? It works for me...

Thx in advance,

Bob
 
Keith,

Very glad it's finally working for you. As you complete the gcu 477 key assignments, remember that only the gps variables like IcaoSearchEnterChar need to be addressed in the Carenado addon gauge. L:Vars like the buffer button are shared across the panel set so they don't need to be addressed in the addon gauge.

You're using FSX, and you're sure that
XML:

doesn't work?

Does anybody know why the XML parser might not like the above? It works for me...

Thx in advance,

Bob
It's possible that when i tried it that i messed up the syntax but i think i copied and pasted. My code referenced a macro
That was written earlier in that same gauges code, could that be the difference?

Keith

Sent from my SM-G935F using Tapatalk
 
It wouldn't be the macro. It defines what @c means: <MacroValue>C:fs9gps</MacroValue>

In my example, I just use C:fs9gps rather than @c
 
It wouldn't be the macro. It defines what @c means: C:fs9gps

In my example, I just use C:fs9gps rather than @c
My macro looks like this...
C:fs9gps:7


Does that 7 make a difference?

Sent from my SM-G935F using Tapatalk
 
Yup. 'A' (>C:fs9gps:7:IcaoSearchEnterChar) would have worked. You actually posted the macro in #24 but I missed it. I need to read more carefully. Kudos also to Roman Stoviak for pointing out to me the way the macro was written.

Bob
 
Bob, I actually noticed the 'spurious' 7 in that macro, but was reluctant to stir the pot by sticking my 2 cents in. Now I wish I had... :scratchch
 
Bill - I wish you had, too. I just overlooked it. Fortunately, Keith tried using @c.

Bob
 
Out of interest, is that 7 referring to region 7 of the gps or something like that?
Keith

Sent from my SM-G935F using Tapatalk
 
you can have different iterations of the GPS, each one doing it's own thing whether a full gps or using internal calculations for AP or other stuff. The 7 is the index to apply code instructions to GPS #7
 
I highly recommend taking a few days and let it marinate a bit, then come back to the task refreshed and perhaps with a better chance of achieving your goal. It works for me 90% of the time!
Insomnia can help too! :scratchch :stirthepo In a "ah hah!" moment as the coffee is brewing as there is no chance of getting any measurable sleep -

Just thought of something that may help since you are using FSUIPC and lua. This will reduce coding and variable use by factors.
In a lua script one can have flags that can be listened to for changes, numbered 1-255. Perfect for the ASCII number codes needed. ( REFERENCE )
On the event.flag listener the flag number gets passed to the function - this means only one function is needed!
In FSUIPC, start the following lua automatically (via profiles would be ideal), then for each button use the FSUIPC command "LuaToggle <my lua name>" with the parameter being the ASCII number. (reference above and below)
Note - not all are accepted by the GPS input, provided anyway. Also, there is no error handling if the wrong parameter is given - shouldn't be a problem as the GPS system will probably just ignore.

A thru Z = 65 thru 90
space = 32
backspace = 8
plus = 43
minus = 45
decimal = 46

This is all that is needed on the FSUIPC side of things -
Code:
function sendToGps(flag)
    ipc.writeLvar("Stinger2k2_ASCII_Num", flag)
end

event.flag("sendToGps")

Then... On the XML gauge side of things -
XML:
<Update>
    <!-- NO MACRO USED TO KEEP FROM ANY MISUNDERSTANDING -->
    <!-- ONLY PERFORM IF A FLAG HAS BEEN TOGGLED ON THE FSUIPC SIDE, IE THE VAR IS NOT ZERO -->
    (L:Stinger2k2_ASCII_Num, number) 0 != if{

        <!-- THE ASCII CODE NUMBER HELD IN THE VAR TO BE CONVERTED TO CHAR AND SENT TO GPS SEARCH, PERFORM THE SOUND -->
        (L:Stinger2k2_ASCII_Num, number) chr (>C:fs9gps:7:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number)
  
        <!-- RESET THE VAR TO LISTEN FOR THE NEXT BUTTON PUSH -->
        0 (>L:Stinger2k2_ASCII_Num, number)
    }
</Update>

There you have it, a max of 15 lines of total code versus 100s (?) and only 1 variable versus 26+.
Not tested live but all code has been previously used successfully in other things.
The key for success will be assigning the buttons properly in FSUIPC.
 
Last edited:
Insomnia can help too! :scratchch :stirthepo In a "ah hah!" moment as the coffee is brewing as there is no chance of getting any measurable sleep -

Just thought of something that may help since you are using FSUIPC and lua. This will reduce coding and variable use by factors.
In a lua script one can have flags that can be listened to for changes, numbered 1-255. Perfect for the ASCII number codes needed. ( REFERENCE )
On the event.flag listener the flag number gets passed to the function - this means only one function is needed!
In FSUIPC, start the following lua automatically (via profiles would be ideal), then for each button use the FSUIPC command "LuaToggle " with the parameter being the ASCII number. (reference above and below)
Note - not all are accepted by the GPS input, provided anyway. Also, there is no error handling if the wrong parameter is given - shouldn't be a problem as the GPS system will probably just ignore.

A thru Z = 65 thru 90
space = 32
backspace = 8
plus = 43
minus = 45
decimal = 46

This is all that is needed on the FSUIPC side of things -
Code:
function sendToGps(flag)
ipc.writeLvar("Stinger2k2_ASCII_Num", flag)
end

event.flag("sendToGps")

Then... On the XML gauge side of things -
XML:
(L:Stinger2k2_ASCII_Num, number) 0 != if{


(L:Stinger2k2_ASCII_Num, number) chr (>C:fs9gps:7:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number)


0 (>L:Stinger2k2_ASCII_Num, number)
}

There you have it, a max of 20 lines of code versus 100s (?) and only 1 variable versus 26+.
Not tested live but all code has been previously used successfully in other things.
The key for success will be assigning the buttons properly in FSUIPC.
Ok thanks, i'll give it a go although having spent 3 days on the code i have i shan't spend too long on it if it does work!

Appreciate it, thanks
Keith

Sent from my SM-G935F using Tapatalk
 
Hi guys,
I have almost the same project as shown here,. I am creating a G1000 panel with all its buttons, but I am a little bit confused.
How do I know which is the L:Var or the Event that is triggered when I click a button on the panel.
I think this is the first step to program a code to trigger all the button on my G1000 panel in the Carenado aircraft so after that I can create the code as shown here to link the button on my hardware to the Event/L:Var.
 
Hi guys,
I have almost the same project as shown here,. I am creating a G1000 panel with all its buttons, but I am a little bit confused.
How do I know which is the L:Var or the Event that is triggered when I click a button on the panel.
I think this is the first step to program a code to trigger all the button on my G1000 panel in the Carenado aircraft so after that I can create the code as shown here to link the button on my hardware to the Event/L:Var.
Hi,

It depends which aircraft you are basing your G1000 on. If you are using P3d it will be much easier for you because with P3d you can create mouse macros for each switch and button. In FSX this is not possible.

To trace Lvars you will need a registered copy of FSUIPC. There is an addon interface called LINDA (you can download this for free on the Avsim/Linda forum) which makes the tracing of Lvars much easier.

If you are using a stock aircraft then it should be fairly easy to map the buttons. If you are using an addon aircraft it may be trickier. Have a look on the Avsim/Linda forum where you can find Linda modules for some aircraft which already have some of the buttons mapped for you.

Regards
Stinger




Sent from my SM-T813 using Tapatalk
 
Hello stinger2k2. This is how I used a CDU keypad (FS sees as a joystick).
1) I assign the joystick buttons to an FSUIPC spare offset, say (66CB);

730=P67,16,Cx010066CB,x01 ;A
731=P67,17,Cx010066CB,x02 ;B
etc.

2) I assign the offset to a lvar; keypad.lua:

function AlphaNum(offset, val)
val = ipc.readSB(0x66CB)
ipc.WriteLvar("L:AlphaChar", val)
end
--
event.offset(0x66CB,"SB","AlphaNum")

3) Then I inserted into the default gps500.xml:

<Element><Select><Value>
(L:AlphaNumb, number) 1 == if{ 'A' (>C:fs9gps:IcaoSearchEnterChar) }
(L:AlphaNumb, number) 2 == if{ 'B' (>C:fs9gps:IcaoSearchEnterChar) }
etc.
Perhaps there is a more efficient way but it works for me and is simple.
 
Hello stinger2k2. This is how I used a CDU keypad (FS sees as a joystick).
1) I assign the joystick buttons to an FSUIPC spare offset, say (66CB);

730=P67,16,Cx010066CB,x01 ;A
731=P67,17,Cx010066CB,x02 ;B
etc.

2) I assign the offset to a lvar; keypad.lua:

function AlphaNum(offset, val)
val = ipc.readSB(0x66CB)
ipc.WriteLvar("L:AlphaChar", val)
end
--
event.offset(0x66CB,"SB","AlphaNum")

3) Then I inserted into the default gps500.xml:


(L:AlphaNumb, number) 1 == if{ 'A' (>C:fs9gps:IcaoSearchEnterChar) }
(L:AlphaNumb, number) 2 == if{ 'B' (>C:fs9gps:IcaoSearchEnterChar) }
etc.
Perhaps there is a more efficient way but it works for me and is simple.
Nice, i like that.

Thanks for posting, it may well come in useful at some stage. I had to stop programming the CDU in my system because my pc cannot handle using the Carenado navpack extension so it had limited use for me. I use the cdu panel in other ways, like to anwer the FSX atc etc.

Chers
Stinger

Sent from my SM-T813 using Tapatalk
 
Back
Top