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

FSX Remote Control for G1000

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
I'm trying to script a remote control keypad/panel for a G1000.

All of the edge buttons and most of the knobs on the MFD have been moved to the remote control unit, so I need an (easy?) way to accomplish my goal.

Unfortunately, because of the absolute horror of all the inter-dependent @macros it is becoming a bit of a nightmare.

I was doing fine until I got the the ENT button. In the remote unit's <Mouse> section, I have the following script:

Code:
    <!-- =========================== ENTER Button ========================================= -->
    <Area Name="ENT Button" Left="170" Top="106" Width="34" Height="25">
      <Click Kind="LeftSingle+Leave">
        (M:Event) 'LeftSingle' scmp 0 == if{ 2 (>L:RmtENT,enum) }
        (M:Event) 'Leave' scmp 0 == if{ 1 (>L:RmtENT,enum) }
      </Click>
      <Cursor Type="Hand"/>
      <Tooltip>GPS_ENTER_BUTTON</Tooltip>
    </Area>
As you can see, left clicking on the button sets (L:RmtENT,enum) = 2 and releasing the button (either release/leave) will set (L:RmtENT,enum) = 1.

In the G1000_MFD, I'm capturing the remote buttons in the <Update> section:
Code:
    (L:RmtENT,enum) 2 == (@g:entButtonDown) 0 == and if{ 1 (>@g:entButtonDown) @ENTButton }
    (L:RmtENT,enum) 1 == (@g:entButtonDown) 1 == and if{ 0 (>@g:entButtonDown) 0 (>L:RmtENT,enum) }
All this does is replicate the original <Click> section. When (L:RmtENT,enum) is 2, the @ENTButton macro is loaded. When (L:RmtENT,enum) is 1 (button released), (L:RmtENT,enum) is set to 0 to prevent the script from firing again.

So far, so good. The problem comes when I try to place the @ENTButton macro with the rest of the @macros at the top (above the <Update> section. Apparently there are some calculations that are dependent on having had the <Update> section run first, as the gauge will instantly CRASH... :eek:

If I move the @ENTButton macro below the <Update> section the gauge will load and run without crashing, but the script will not execute properly...

Does anyone know of a "easier" way to do this?
 

Attachments

  • Garmin MFD Controls.jpg
    Garmin MFD Controls.jpg
    26.2 KB · Views: 649
Bill, where in FSX is G1000_MFD.xml ? I only have MFD for Baron, C172 and Mooney (SP2-not Acceleration) and cannot find (@g:entButtonDown) on them.

If FSX crashes, the problem may be in the DLL (something from your code that makes trouble there); if it hungs could be the DLL or a recursive FS event (an endless loop). XML pure code shouldn't make a crash (at least with FS9 schema, and I suspect neither in FSX native one).

Tom
 
Bill, where in FSX is G1000_MFD.xml ? I only have MFD for Baron, C172 and Mooney (SP2-not Acceleration) and cannot find (@g:entButtonDown) on them.

You will find the G1000_MFD.xml on my hard drive, as it is my own custom version I scripted for Eaglesoft's Diamond DA-42. Because it was developed to be both FS9 and FSX compatible, it was based loosely on the FS9 default G500 gauge. :cool:

In any case, (@g:entButtonDown) is used only to animate the 2d and 3d buttons on the visual model, and is unrelated to the actual problem as far as I can tell.

For practical purposes, consider the G500 default as a basis for evaluation, since it's mouse operations are nearly 100% identical to my G1000_MFD.xml script.

<!--
This gauge code is based on the FS9 default GPS500, but has been recreated using 98% vector graphic elements.
All vector drawing code is copyrighted by: Eaglesoft Development Group (2011-2018) & Bill Leaming, Programmer.
The basic code and logic are copyrighted by: Microsoft Corporation as the primary developers.
All Rights are Reserved by the respective parties.
-->

In any case, in the simplest terms possible, what I seek to accomplish is a reliable method to trigger a mouse event in the core G1000 script from a remote keypad/panel, or at the very least trigger the same scripted actions that each button push represents.

For simple things, this works quite well, but as you no doubt are aware, most of the buttons are multi-function, and what occurs when pressed is dependent on just where in the system one happens to be at any given time, hence the heavy reliance on complex @macro scripts that are present. :eek:

I hope this clairifies my goals adequately.
 
You will find the G1000_MFD.xml on my hard drive...

Well, thank you Bill, I've already found it in your drive...:D:D:D

Now seriously, I think the simplest way to accomplish what you want is:

In the remote unit:

Code:
<Click>
    (>K:GPS_ENTER_BUTTON)
    ...any other relevant code...
</Click>
And in the G1000 MFD

Code:
<On Event="GPS_ENTER_BUTTON">
     @ENTButton
     etc
</On>
which I understand is already coded in default GPS500

Hmm, maybe too simple to be true?

Tom
 
No, not to simple to be true, just too simple for me to remember from all those years ago when I first noticed those special key_events, then promptly dismissed them from mind since I didn't have a use for 'em!

Well, now I feel like a right fool! I used the G1000_MFD_keyevents and they work just fine, thank you very much...

...although I may will have to use the GPS_keyevents to keep FS9 compatibility. I can simply remove the <Key> event list from the PFD so it won't respond to the remote's signals. :)

Odd that we can configure up to two separate GPS units (dual 430's anyone?), but MS ACES never provided a way to :index the GPS_keyevents... :rolleyes:

Now I get to tackle the chore of scripting the alpha-numeric keypad. Oh joy! :rotfl:
 
No, not to simple to be true, just too simple for me to remember from all those years ago when I first noticed those special key_events, then promptly dismissed them from mind since I didn't have a use for 'em!

Well, now I feel like a right fool! I used the G1000_MFD_keyevents and they work just fine, thank you very much...

...although I may will have to use the GPS_keyevents to keep FS9 compatibility. I can simply remove the <Key> event list from the PFD so it won't respond to the remote's signals. :)

Odd that we can configure up to two separate GPS units (dual 430's anyone?), but MS ACES never provided a way to :index the GPS_keyevents... :rolleyes:

Now I get to tackle the chore of scripting the alpha-numeric keypad. Oh joy! :rotfl:

Honestly, I haven't tried any of those GPS events myself, so I wasn't sure what I suggested you would work :o

Regarding what I highlighted in blue, there is a way to prevent any event executes twice when issued by code and captured in any gauge:

Code:
<Update> or <Element>
  1 (>L:EventName_byCode,bool)
  (>K:EVENT)


And in the Event handler

Code:
<On Event="EVENT">
     (L:EventName_byCode,bool) !
     if{ Do something }
     els{ 0 (>L:EventName_byCode,bool) }
</On>
Just a nice protection.

Tom
 
Yeah Tom, that's pretty similar to what I was doing originally. I can use such a scheme to allow only the MFD to respond to the single-purpose GPS_keyevent commands so it will remain FS9/FSX compatible.

This is necessary of course because the PFD has it's own inset map, as well as the ability to call up Flight Plan, DirectTo, etc. with its own set of hot keys.
 
If FSX crashes, the problem may be in the DLL .... XML pure code shouldn't make a crash (at least with FS9 schema, and I suspect neither in FSX native one).

I correct myself. The crash is another FS "issue" with the space assigned to script text. If the entire script is greater than (+-) 50 kb and doesn't contain macros, the XML interpreter will pass only those 50 kb and the rest is discarded; then the parser will parse the resulting text entirely and the gauge will work (although the portion of script discarded would obviously lead to errors)
Now, if the script contains macros, during the replacement of macro ids with actual code if the updated script exceeds (+-) 50 kb FS crashes. How nice!:cool:

Tom
 
I correct myself. The crash is another FS "issue" with the space assigned to script text. If the entire script is greater than (+-) 50 kb and doesn't contain macros, the XML interpreter will pass only those 50 kb and the rest is discarded; then the parser will parse the resulting text entirely and the gauge will work (although the portion of script discarded would obviously lead to errors)
Now, if the script contains macros, during the replacement of macro ids with actual code if the updated script exceeds (+-) 50 kb FS crashes. How nice!:cool:

Tom

Does this 50kb limit also apply to FSX, or does FSX have a higher, but finite limit as well ? If so, any idea what the size limit is for FSX ?

This might explain an issue I am having with a big FSX XML gauge !!

Geoff
 
Does this 50kb limit also apply to FSX, or does FSX have a higher, but finite limit as well ? If so, any idea what the size limit is for FSX ?

This might explain an issue I am having with a big FSX XML gauge !!

Geoff

Yes, happens in FSX, with FS9 schema and surely with FSX schema as well. The advantage with this last one is that multiple <Update> are allowed, and considering that every script (from <Update>, <Value>,<Visible>, etc) can hold 50 kb of text, this enhances the whole area available for calculations.

Tom
 
Yes, happens in FSX, with FS9 schema and surely with FSX schema as well. The advantage with this last one is that multiple <Update> are allowed, and considering that every script (from <Update>, <Value>,<Visible>, etc) can hold 50 kb of text, this enhances the whole area available for calculations.

Tom

I agree with Geoff - this explains a problem I had been running into over the last few days. I was using the string macros (that generate 16 L:Vars each to hold a string up to 64 characters) to store over 100 separate strings. It didn't look overwhelming at first, but I guess after the macros were substituted, each section grew too big. As an example, I found myself having to break up <On Key="Ascii"> into many separate, smaller <On> sections to get all the code to work.

Use of XMLVARS instead of the string macros has taken care of that problem.

Bob
 
Back
Top