Triggering xml event with a hardware button instead of mouse

#41
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:
#42
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
 
#43
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 ...
 
#44
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
 
#46
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
 
#47
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
 
#48
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
 
#50
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
 

n4gix

Resource contributor
#51
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
 
#54
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
 
#55
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:
#56
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
 
Top