• 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

Messages
1,564
Country
thailand
Any time you press a joystick button, move the slider, move the joystick handle, you are triggering an event. The Event is the means by which the sim software interprets the joystick action. When you move the HAT switch on the joystick, you are triggering the PAN_VIEW event. On my joystick, when I press button 7, I trigger the RELEASE_DROPPABLE_OBJECTS event.

If you use an event logging app like XMLTOOLS you will be able to see the name of the event you trigger when you press any joystick button. Then, a simple gauge that includes the On Event traps, the event name, and your XML script should do the trick for you. This gauge would not need an <Update> section or L:Vars.

If your XML gauge does not include the "c" macro definition, then the 'A' assignment will not work, not as your XML is currently written. Your gauge needs to define what @c means. Include <Macro Name="c">C:fs9gps</Macro> or, more simply, just write the A assignment as 'A' (>C:fs9gps:IcaoSearchEnterChar)

There are always different ways to do things and I believe that if you keep working the L:Var, bool approach you will get it to work to your satisfaction. That said, your objective is to run a very simple XML script when a certain joystick button is pressed. That's the definition of an event trap, and the On Event approach should be the most efficient way.

Anyway, it's obvious that you are very active testing your xml script and that's great! Keep at it. You definitely will get this to work, one way or another.

Bob
 
Messages
1,564
Country
thailand
Additionally, if you know the hex code of the event, you can specify that rather than the event name:

XML:
<Keys>       
 <On Event="0x10462">'A' (>C:fs9gps:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number)</On>
</Keys>

is equivalent to

<Keys>       
 <On Event="RELEASE_DROPPABLE_OBJECTS">'A' (>C:fs9gps:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number)</On>
</Keys>

I assume you can determine hex code from FSUIPC. XMLTOOLS and event loggers by Doug Dawson can also tell you the hex code.

Bob
 
Messages
300
Country
unitedkingdom
Additionally, if you know the hex code of the event, you can specify that rather than the event name:

XML:
'A' (>C:fs9gps:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number)


is equivalent to

 
'A' (>C:fs9gps:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number)

I assume you can determine hex code from FSUIPC. XMLTOOLS and event loggers by Doug Dawson can also tell you the hex code.

Bob
Bob,
I trued xmltools but it seems to clash with another Sode process and FSX crashes to desktop. So for the moment i am persevering with the other method.

Cheers
Keith

Sent from my SM-G935F using Tapatalk
 
Messages
300
Country
unitedkingdom
Ok, so whats wrong with this?

Heres my gauge xml code. It is operating the second part (L:BUFFER_BTN_FMC) , which is the button click sound,
but still not the first part even though I have included the macro copied from the original from the mouse operated gauge.

<Gauge Name="Custom_GCU477" Version="1.0">
<Macro id="c" Name="c">
<MacroValue>C:fs9gps:7</MacroValue>
</Macro>
<Update>
(L:Stinger2k2_A,bool) 1 ==
if{ 65 chr (&gt;@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number) }
</Update>
</Gauge>

I have also tried this with the same result.......

<Gauge Name="Custom_GCU477" Version="1.0">
<Macro Name="c">C:fs9gps</Macro>
<Update>
(L:Stinger2k2_A,bool) 1 ==
if{ 65 chr (&gt;@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number) }
</Update>
</Gauge>

Any clues folks?

cheers
Keith
 
Messages
1,564
Country
thailand
Any clues folks?

Yeah ... I should have spotted it at the beginning. The gps variable, IcaoSearchEnterChar is local to the host gauge - your xml gauge - and not shared across the panel set. That is, it is not shared with the Carenado addon gauge that contains the gps code that drives the FMC.

On the other hand, L:Vars are always shared across the panel set, so the L:BUFFER_BTN_FMC,number part works.

As a remedy, try this:

Remove the 65 chr (&gt;@c:IcaoSearchEnterChar) from your gauge and put it in the <Update> section of the Carenado addon gauge:

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

or

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


The bottom example pulls the L:BUFFER_BIN_FMC part over to the Carenado addon gauge as well, although that isn't necessary.

BTW, why do you want to assign IcaoSearchEnterChar to a joystick button? The FMC keypad has 26 characters plus 10 numbers. A joystick doesn't have that many buttons.

Bob
 
Last edited:
Messages
300
Country
unitedkingdom
I put this line into the Carenado gauge and it operates even without me operating my
Lvar "Stinger2k2_A" via an assigned switch.

Where do I go from here?


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

Keith
 
Messages
300
Country
unitedkingdom
Yeah ... I should have spotted it at the beginning. The gps variable, IcaoSearchEnterChar is local to the host gauge - your xml gauge - and not shared across the panel set. That is, it is not shared with the Carenado addon gauge that contains the gps code that drives the FMC.

On the other hand, L:Vars are always shared across the panel set, so the L:BUFFER_BTN_FMC,number part works.

As a remedy, try this:

Remove the 65 chr (>@c:IcaoSearchEnterChar) from your gauge and put it in the section of the Carenado addon gauge:

XML:
Carenado addon Gauge:

(L:Stinger2k2_A, bool)
if{
'A' (>C:fs9gps:IcaoSearchEnterChar)
0 (>L:Stinger2k2_A. bool)
}


or


(L:Stinger2k2_A, bool)
if{
'A' (>C:fs9gps:IcaoSearchEnterChar)
1 (>L:BUFFER_BIN_FMC, number)
0 (>L:Stinger2k2_A. bool)
}


The bottom example pulls the L:BUFFER_BIN_FMC part over to the Carenado addon gauge as well, although that isn't necessary.

BTW, why do you want to assign IcaoSearchEnterChar to a joystick button? The FMC keypad has 26 characters plus 10 numbers. A joystick doesn't have that many buttons.

Bob
A joystick like mine has 52 buttons! As i said its a home made Garmin Gcu477(google images will show you what it is).

Ive given up for the day now. I'll try again tomorrow.

Cheers
Keith

Sent from my SM-G935F using Tapatalk
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
A joystick like mine has 52 buttons! As i said its a home made Garmin Gcu477(google images will show you what it is).
This should help folks understand what you are speaking about:

CU6RV.png


By the way, please use the CODE box feature when pasting xml scripts. It will make it ever so much easier to read Note how Bob's replies are in an XML Box and have an orange line on the left edge, and the XML script is formatted properly:
CU6VL.png
 
Messages
300
Country
unitedkingdom
This should help folks understand what you are speaking about:

CU6RV.png


By the way, please use the CODE box feature when pasting xml scripts. It will make it ever so much easier to read Note how Bob's replies are in an XML Box and have an orange line on the left edge, and the XML script is formatted properly:
CU6VL.png
Will do. Unfortunately i am often replying using Tapatalk which doesn't show those features as far as I can see.

Cheers
Keith

Sent from my SM-G935F using Tapatalk
 
Messages
300
Country
unitedkingdom
And here is mine...basically the unit is seen by FSUIPC as a joystick and
each letter button etc as a joystick button. So what I am trying to achieve is this...
By pressing the letter A button on my unit, it triggers the same event as the
mouse click code at the start of this thread (a long way back, i know!) to input
a letter A into the MFD flightplan popup screen and search the ICAO database for
all destination waypoints etc that start with the letter A. If that makes sense, it's hard
to describe to those that don't use this aircraft!

gcu477.jpg


Cheers
Keith
 
Messages
300
Country
unitedkingdom
Me again!,

Is this the correct XML code to set my local variable to "0" ? I can't seem to stop it
entering the letter A now every time the gauge code updates. It is not even waiting
for me to press my button to operate the Lvar assignment.
Code:
0 ("Stinger2k2_A",bool)
 
Messages
300
Country
unitedkingdom
The correct syntax is shown in #25.

Bob,

So, here is the code which I put into the carenado gauge (which is hopefully the same as yours in #25)
Code:
<Update>
        (L:Stinger2k2_A,bool) 1 ==
            if
{'A'(>C:fs9gps:IcaoSearchEnterChar)
0 (>L:Stinger2k2_A,bool)}
</Update>

And here is my Lua code for my button

Code:
function GCULetterA ()
 ipc.writeLvar("Stinger2k2_A", 1)
 ipc.writeLvar("BUFFER_BTN_FMC", 1)
end
function GCULetterA_Off ()
 ipc.writeLvar("Stinger2k2_A", 0)
 ipc.writeLvar("BUFFER_BTN_FMC", 0)
end

Unfortunately it no longer types an "A" and doesn't react to my button press. (The button press is working
as far as "BUFFER_BTN_FMC" goes because I can hear the button click sound in FSX.

Sorry, I know this is frustrating.

cheers
Keith
 
Messages
1,564
Country
thailand
which is hopefully the same as yours in #25

Not exactly. Your brackets, }, need spaces as shown in #25. Look carefully.

Also, where did you place that code? Hopefully, in the Carenado addon gauge, but where in that gauge? Did it already have an <Update> section? Did you put it in there? Did you create another <Update>? You don't want to do that.

Bob

[edit] This will be more clear ... written on one line. Take a look at the pink spaces:

(L:Stinger2k2_A, bool) if{ 'A' (>C:fs9gps:IcaoSearchEnterChar) 0 (>L:Stinger2k2_A, bool) }

1551620808157.jpeg


If you placed this within the existing <Update> section of the Carenado addon, then fixing the syntax errors (spaces) should solve the problem.

As you know, you'll need to add lines for all 36 characters, A-Z, 0-9, that are possible in an Ident, which is what you're entering when you use IcaoSearchEnterChar
 
Last edited:
Messages
300
Country
unitedkingdom
Not exactly. Your brackets, }, need spaces as shown in #25. Look carefully.

Also, where did you place that code? Hopefully, in the Carenado addon gauge, but where in that gauge? Did it already have an <Update> section? Did you put it in there? Did you create another <Update>? You don't want to do that.

Bob

[edit] This will be more clear ... written on one line. Take a look at the pink spaces:

(L:Stinger2k2_A, bool) if{ 'A' (>C:fs9gps:IcaoSearchEnterChar) 0 (>L:Stinger2k2_A, bool) }

View attachment 48122

If you placed this within the existing <Update> section of the Carenado addon, then fixing the syntax errors (spaces) should solve the problem.

As you know, you'll need to add lines for all 36 characters, A-Z, 0-9, that are possible in an Ident, which is what you're entering when you use IcaoSearchEnterChar

I tried it to no avail. Should the "if" have a "1 ==" before it?

Also I created a new Update loop as there are multiple update loops already in the gauge, i gave it an id.

Keith
 
Messages
1,564
Country
thailand
Should the "if" have a "1 ==" before it?

You could put it in if you want, but it's not necessary as the L:Var is a bool

Also I created a new Update loop as there are multiple update loops already in the gauge, i gave it an id.
Don't use a new <Update>. To be frank, at this point, we're just guessing about what your addon code looks like, and that's always a waste of time in the end.

Bob
 
Messages
300
Country
unitedkingdom
You could put it in if you want, but it's not necessary as the L:Var is a bool


Don't use a new . To be frank, at this point, we're just guessing about what your addon code looks like, and that's always a waste of time in the end.

Bob
I'd put the entire gauge code on here if it would help but it's massive.

I tried leaving my extra code in there without the update loop but the gauge would not show at all.

Keith

Sent from my SM-G935F using Tapatalk
 
Messages
300
Country
unitedkingdom
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>

Keith
 
Messages
1,564
Country
thailand
I'd put the entire gauge code on here if it would help but it's massive.

Well ... just post the first <Update> section, in its entirety, and we'll see if that's enough. Hopefully, it is. But before you do that, please review the copyright info for that gauge, if any exists. People in here don't want to tread on others' copyrighted property.

I tried leaving my extra code in there without the update loop but the gauge would not show at all.

Could be because of mixing FS9 and FSX XML schema. Impossible to tell at the moment.

Bob
 
Top