• 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
300
Country
unitedkingdom
Hi all,
I need to trigger the following xml gauge code via an external button press rather than mouse click. Is there a way of doing this? Fsuipc does not show any lvar activity when doing a trace.

Heres the code.....

<MouseArea id="Letter A">
<FloatPosition>16.000,151.000</FloatPosition>
<Size>45,30</Size>
<CursorType>Hand</CursorType>
<MouseClick id="MouseClick">
<Script>65 chr (&gt;@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number)</Script>
<ClickType>LeftSingle</ClickType>
<ClickRepeat>True</ClickRepeat>
</MouseClick>
</MouseArea>

Cheers
Stinger
 

TurboCompound

Resource contributor
Messages
190
Try writing an XML gauge that performs the same actions in that mouse script when a custom boolean LVar is activated. Assign your hardware button to that LVar in FSUIPC.
 
Messages
1,564
Country
thailand
I need to trigger the following xml gauge code via an external button press rather than mouse click


That can also be done with simple XML when you know the name of the event triggered by the button push. As an example, the following will run your script when joystick button 7 is pressed:

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


To find out which event is triggered when a button is pressed on my joystick, I use XMLTOOLS XMLEvents Logger - that's what I just did to prepare this response. Download and install XMLTOOLS (from FSDeveloper Resources page), then take a look at the XMLTools_Examples.pdf.

Hope this helps,

Bob
 
Messages
300
Country
unitedkingdom
Try writing an XML gauge that performs the same actions in that mouse script when a custom boolean LVar is activated. Assign your hardware button to that LVar in FSUIPC.
That sounds exactly what i need. If only i knew how! Assigning Lvars in Fsuipc i can do. Write custom xml gauges i cant. Thanks for the info though.

Sent from my SM-G935F using Tapatalk
 
Messages
300
Country
unitedkingdom
That can also be done with simple XML when you know the name of the event triggered by the button push. As an example, the following will run your script when joystick button 7 is pressed:

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


To find out which event is triggered when a button is pressed on my joystick, I use XMLTOOLS XMLEvents Logger - that's what I just did to prepare this response. Download and install XMLTOOLS (from FSDeveloper Resources page), then take a look at the XMLTools_Examples.pdf.

Hope this helps,

Bob
Thanks Bob, I'll try that. Not sure if will work as what i am trying to trigger is not an event as such. The xml script i am trying to trigger is for typing the letter A into an FMS flightplan.(the mouse click is on an on screen garmin gcu477 scratchpad. On the Carenado Phenom 300) the XML script is this.....



The L:BUFFER etc part is merely a local variable to produce the sound of the button, I'm more interested in triggering the first part of the script.

Cheers
Keith

Sent from my SM-G935F using Tapatalk
 

TurboCompound

Resource contributor
Messages
190
That sounds exactly what i need. If only i knew how! Assigning Lvars in Fsuipc i can do. Write custom xml gauges i cant. Thanks for the info though.

Sent from my SM-G935F using Tapatalk
This website is the Bible of FS9 XML, which works in FSX/P3D and is easier to write. I didn't know any XML when I read these, but they do a pretty good job of explaining. Go through the tutorials and look at some existing gauges and you'll have what you need in no time.
 
Messages
1,564
Country
thailand
What i am trying to trigger is not an event as such. The xml script i am trying to trigger is for typing the letter A into an FMS flightplan.(the mouse click is on an on screen garmin gcu477 scratchpad

Keith,

Thanks for the clarification. You're not talking about physical external hardware like a joystick. The word "external" threw a couple of us off track I think.

To see if I understand - the action is done via keyboard keystroke (typing the letter A) and not by mouse click somewhere on the on-screen image of the garmin gcu477?

Bob

[edit] either way, you can trap that user input action and run your script. I think the problem may be that Carenado code originally run as a result of that action may be overridden by the trap code
 
Last edited:
Messages
300
Country
unitedkingdom
Keith,

Thanks for the clarification. You're not talking about physical external hardware like a joystick. The word "external" threw a couple of us off track I think.

To see if I understand - the action is done via keyboard keystroke (typing the letter A) and not by mouse click somewhere on the on-screen image of the garmin gcu477 scratchpad?

Bob
The existing action is done by a mouse click. I have built a replica gcu477 with buttons which appear as assignable joystick buttons to fsuipc. I want to trigger the action by pressing one of the joystick buttons instead of clicking a mouse.

Keith

Sent from my SM-G935F using Tapatalk
 

TurboCompound

Resource contributor
Messages
190
I took a stab at it, can't test it since I'm lazy, don't have the Carenado addon, and haven't bought FSUIPC for P3Dv4 yet.
XML:
<Gauge Name="FMS Controller Assignments" Version="1.0">
    <Update>
        (L:Stinger2k2_A,bool) 1 ==
            if{ 65 chr (&gt;@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number) }
    </Update>
</Gauge>

Just keep following that format, add new entries before the "</Update>"

To translate this code to English:
XML:
<Gauge Name="FMS Controller Assignments" Version="1.0">
    <Start of script that will be run 18 times per second>
        Check if ("Stinger2k2_A," a custom variable that can only be 0 or 1), is equal to 1
            if that is the case, then execute this code: { 65 chr (&gt;@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number) }
    </End of script that will be run 18 times per second>
</Gauge>

Add more button actions like this:
XML:
<Gauge Name="FMS Controller Assignments" Version="1.0">
    <Update>
        (L:Stinger2k2_A,bool) 1 ==
            if{ 65 chr (&gt;@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number) }
        (L:Stinger2k2_B,bool) 1 ==
            if{ logic for B button }
        (L:Stinger2k2_C,bool) 1 ==
            if{ logic for C button }
    </Update>
</Gauge>
 
Messages
300
Country
unitedkingdom
I took a stab at it, can't test it since I'm lazy, don't have the Carenado addon, and haven't bought FSUIPC for P3Dv4 yet.
XML:
(L:Stinger2k2_A,bool) 1 ==
if{ 65 chr (>@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number) }

Just keep following that format, add new entries before the ""

To translate this code to English:
XML:
Check if ("Stinger2k2_A," a custom variable that can only be 0 or 1), is equal to 1
if that is the case, then execute this code: { 65 chr (>@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number) }

Add more button actions like this:
XML:
(L:Stinger2k2_A,bool) 1 ==
if{ 65 chr (>@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number) }
(L:Stinger2k2_B,bool) 1 ==
if{ logic for B button }
(L:Stinger2k2_C,bool) 1 ==
if{ logic for C button }
Sir, you are a star. I will check it later(still in bed at the mo!) and report back. It looks like just what i need.

Much appreciated
Keith

Sent from my SM-T813 using Tapatalk
 
Messages
300
Country
unitedkingdom
I took a stab at it, can't test it since I'm lazy, don't have the Carenado addon, and haven't bought FSUIPC for P3Dv4 yet.
XML:
<Gauge Name="FMS Controller Assignments" Version="1.0">
    <Update>
        (L:Stinger2k2_A,bool) 1 ==
            if{ 65 chr (&gt;@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number) }
    </Update>
</Gauge>

Not quite there yet for some reason. Here's what I did.
In Notepad I wrote the code then saved it to my gauges folder as ......Custom_GCU477.xml
The code in the XML file looks like this....
<?xml version="1.0"?>
-<Gauge Version="1.0" Name="Custom_GCU477">
<Update>(L:Stinger2k2_A,bool) 1 ==if{ 65 chr (>@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number) } </Update>
</Gauge>

I then created a new Lua function and assigned it to a button. Here's the Lua code....
function GCULetterA()
ipc.writeLvar("Stinger2k2_A", 1)
end

It's not working. I am missing something. I saved the xml file directly in the gauges folder, should I have
included it in the EMB505_Gauge.cab file perhaps as this is where the original gauge for the mouse action resides.?

cheers
Keith
 

tgibson

Resource contributor
Messages
11,327
Country
us-california
At the least the xml file needs to be located inside a folder that is inside the Gauges folder. Then you specify it in the panel.cfg file (if needed) as:

gaugenn=foldername!xml_filename (etc.)
 
Messages
300
Country
unitedkingdom
I took a stab at it, can't test it since I'm lazy, don't have the Carenado addon, and haven't bought FSUIPC for P3Dv4 yet.
XML:
<Gauge Name="FMS Controller Assignments" Version="1.0">
    <Update>
        (L:Stinger2k2_A,bool) 1 ==
            if{ 65 chr (&gt;@c:IcaoSearchEnterChar) 1 (>L:BUFFER_BTN_FMC,number) }
    </Update>
</Gauge>

Ok, got it partially working using TurboCompound's code. (I had not added it to the panel.cfg. It is operating the second part of the code (BUFFER_BTN_FMS) which is a local variable to
produce the click of the on-screen button. It constantly clicks so I now need the xml to enter the number 0 in that variable to get it to stop clicking.

Also the first part of the code doesn't type the letter A into the flightplan as it should?

I've been at this all day today, going round in circles. I got the button to just click once at one stage then lost the code again when trying to sort out the typing part !!! :rolleyes:

appreciate your patience with me
Keith
 
Messages
1,564
Country
thailand
Hi Keith,

Going the On Event route as in #5 would avoid the need to reset your bools. Regarding the letter A issue, does your gauge include the "c" macro? If not, write it as shown in #5

'A' (>C:fs9gps:IcaoSearchEnterChar)

Bob

[edit] in #7 you said, "what i am trying to trigger is not an event as such ", but, pressing a joystick button is exactly that, triggering an event.
 
Last edited:
Messages
300
Country
unitedkingdom
Hi Keith,

Going the On Event route as in #5 would avoid the need to reset your bools. Regarding the letter A issue, does your gauge include the "c" macro? If not, write it as shown in #5

'A' (>C:fs9gps:IcaoSearchEnterChar)

Bob

[edit] in #7 you said, "what i am trying to trigger is not an event as such ", but, pressing a joystick button is exactly that, triggering an event.
What i meant by "not triggering an event" was not a listed fsx event, it's a custom event written by Carenado and does not show up in any fsuipc trace.

I realise that i can write a separate lua funtion to turn the lvar to 0, i was just trying to do it in the gauge.( not wishing to sound ungrateful !)

As far as the letter A issue, i used the code exactly as Turbo Compound had written it
So on the face of it it should work as its the same as in the original mouse triggered xml code. I wonder if there is something else in the original gauge that it needs to relate to and hence my code should be embedded in the original gauge. Although i think i tried this during todays trials.

Trouble is, when you've been at it for hours on end you tend to forget what you've tried!.

I will try the syntax you suggest in #5 when i can next face it .

Thanks
Keith

Sent from my SM-G935F using Tapatalk
 
Last edited:

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Trouble is, when you've been at it for hours on end you tend to forget what you've tried!..
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! :wave:
 
Top