Jump to content
The simFlight Network Forums

How to use custom events?


Recommended Posts

Hello everybody

Hi everyone, I started developing software to execute MSFS2020 using C # and FSUIPC.dll.

I can use LVARs and HVARs as well.

 

 

But I have looked at FBW's website. They have custom events to use. These events are available in LVARs list such as A32NX.FCU_SPD_PUSH, A32NX.FCU_SPD_PULL.

Which I do not know how to use it. So I want to ask Anyone Know How can I use it?

best regards

Link to comment
Share on other sites

1 hour ago, PapaTus said:

But I have looked at FBW's website. They have custom events to use. These events are available in LVARs list such as A32NX.FCU_SPD_PUSH, A32NX.FCU_SPD_PULL.

Which I do not know how to use it. So I want to ask Anyone Know How can I use it?

The FBW events just control hvars/lvars.  If you are writing a FSUIPC client program and wish to use lvars, you are better off using the FSUIPC WASM module _ the WAPI (the WASM API) which will give you an API to access and control hvars and lvars. This is a C++ API, but there is also a c# wrapper dll. See 

 

I'll let @Paul Henty comment if using this with his .net client dll.

If you want to use custom events with FSUIPC, you can add these to FSUIPC by using event files (*.evt). There is a thread (or two) in the FSUIPC7 support forum on how to use the MobiFlight events/WASM with FSUIPC7 (but, as I said, you don't really need this for most things, as you can use the hvars/lvars directly).

P.S. No idea what that image you attached is, and its too small to read,

Link to comment
Share on other sites

3 minutes ago, John Dowson said:

These events are available in LVARs list such as A32NX.FCU_SPD_PUSH, A32NX.FCU_SPD_PULL.

To be clear, first try using those lvars directly (with the latest FSUIPC7.1.0 beta, soon to be released).
If you want to use events, create a file in your FSUIPC7 installation folder, called (say) FBW.evt, and add the following:
 

Quote

[Events]
0=A32NX.FCU_SPD_PUSH
1=A32NX.FCU_SPD_PULL

You can then see those events in FSUIPC's drop-down menus for assignment.
If you want to use them externally, you will need to know which control numbers are assigned to the events.

The control numbers for events in event files are determined as follows:
       control number = 32768 + (event file index)*256 + event index number
where event file index is the index number of the event file (in your FSUIPC7.ini, under [EventFiles]) and event index number is the index number if the event in the event file.
So, the first event in the first event file will have a control number of 32768, the second event 32769, first event in the second file as 33024. etc 

Link to comment
Share on other sites

3 hours ago, John Dowson said:

To be clear, first try using those lvars directly (with the latest FSUIPC7.1.0 beta, soon to be released).
If you want to use events, create a file in your FSUIPC7 installation folder, called (say) FBW.evt, and add the following:
 

You can then see those events in FSUIPC's drop-down menus for assignment.
If you want to use them externally, you will need to know which control numbers are assigned to the events.

The control numbers for events in event files are determined as follows:
       control number = 32768 + (event file index)*256 + event index number
where event file index is the index number of the event file (in your FSUIPC7.ini, under [EventFiles]) and event index number is the index number if the event in the event file.
So, the first event in the first event file will have a control number of 32768, the second event 32769, first event in the second file as 33024. etc 

Hi John Dowson 


I am very grateful for the advice, I am going to try your suggestion and will return the results of the experiment.

Best regards
Patcharaphon Phopan

Link to comment
Share on other sites

On 5/8/2021 at 6:58 PM, Paul Henty said:

My .NET Client DLL now has direct access to LVars/HVars in MSFS from managed code via the MSFSVariableServices class. See here:

This uses John's WAPI DLL in the background.

Paul

Hi,Paul henty

I have to thank you very much I am using your MSFSVariableServices class.
And It works great for many Lvar and Hvar. 
But I have a problem where it is on the Lvar and Hvar list. There are no values as follows

 

I am just beginning to learn software development.
Do you have any tips or example to help me use it?

Best regards
Patcharaphon Phopan

Link to comment
Share on other sites

I can't help much as I don't have MSFS. From what I know:

1. HVars need to be added to a file somewhere so that the WASM module knows about them.

2. You need to wait a few seconds after calling Start() as the WASM module needs time to discover the variables.

3. HVars do not have values. They are only actions that can be 'Set()'.

4. When you change aircraft or change the HVar files you need to call MSFSVariableServices.Reload() to discover the new variables for that aircraft.

If you've added these variables to the file and you've waited for the WASM module then @John Dowson may have some more suggestions.

Paul

Link to comment
Share on other sites

46 minutes ago, Paul Henty said:

I can't help much as I don't have MSFS. From what I know:

1. HVars need to be added to a file somewhere so that the WASM module knows about them.

2. You need to wait a few seconds after calling Start() as the WASM module needs time to discover the variables.

3. HVars do not have values. They are only actions that can be 'Set()'.

4. When you change aircraft or change the HVar files you need to call MSFSVariableServices.Reload() to discover the new variables for that aircraft.

If you've added these variables to the file and you've waited for the WASM module then @John Dowson may have some more suggestions.

Paul

 

Thank you very much for your advice. Best regards Patcharaphon Phophan

Link to comment
Share on other sites

5 hours ago, John Dowson said:

To be clear, first try using those lvars directly (with the latest FSUIPC7.1.0 beta, soon to be released).
If you want to use events, create a file in your FSUIPC7 installation folder, called (say) FBW.evt, and add the following:
 

You can then see those events in FSUIPC's drop-down menus for assignment.
If you want to use them externally, you will need to know which control numbers are assigned to the events.

The control numbers for events in event files are determined as follows:
       control number = 32768 + (event file index)*256 + event index number
where event file index is the index number of the event file (in your FSUIPC7.ini, under [EventFiles]) and event index number is the index number if the event in the event file.
So, the first event in the first event file will have a control number of 32768, the second event 32769, first event in the second file as 33024. etc 

Dear Mr. John Dowson

As your suggestion, I can now make it up on the list of fsuipc, but I don't know how to use it in any way for c #

 

Best regards

patcharapol Phophun

Link to comment
Share on other sites

59 minutes ago, PapaTus said:

I can now make it up on the list of fsuipc, but I don't know how to use it in any way for c #

I think you are confusing things a bit. As I said, the FBW events just activate hvars or set lvar values. You can do the same with the lvar/hvar facilities provided by the WAPI .lib and .dll, and in c# using Paul's  MSFSVariableServices class.

If you really want to use the FBW events, you have to add them to FSUIPC using event files, as I indicated earlier. And to then use them, you need to use the control numbers assigned, which I also explained earlier.

To start with, rather than using the FBW events, why don't you just look at the available lvars/hvars and see if you achieve the same via lvars/hvars.  Looking at the FCU, the following hvars should be available for you to try:

Quote

H:A320_Neo_FCU_MODE_MANAGED_SPEED
H:A320_Neo_EXPEDITE_MODE
H:A320_Neo_FCU_HDG_PUSH
H:A320_Neo_FCU_HDG_PULL
H:A320_Neo_FCU_HDG_INC
H:A320_Neo_FCU_HDG_DEC
H:A320_Neo_FCU_SPEED_INC
H:A320_Neo_FCU_SPEED_DEC
H:A320_Neo_FCU_VS_INC
H:A320_Neo_FCU_VS_DEC
H:A320_Neo_FCU_VS_PULL
H:A320_Neo_FCU_VS_PUSH
H:A320_Neo_FCU_ALT_PULL
H:A320_Neo_FCU_ALT_PUSH

and the following lvars are related:

Quote

L:A32NX_TRK_FPA_MODE_ACTIVE
L:A32NX_AUTOPILOT_LOC_MODE
L:A32NX_AUTOPILOT_APPR_MODE
L:A32NX_METRIC_ALT_TOGGLE
L:XMLVAR_Autopilot_Altitude_Increment

 

Note that hvars are only available if you add them to your A320.hvar file, located in the FSUIPC WASM modules folder. From what I can see, only the first two (H:A320_Neo_FCU_MODE_MANAGED_SPEED & H:A320_Neo_EXPEDITE_MODE) are currently included in the provided A320.hvar file. To use the others, you will need to add them to that file . Once added to the file, you need to reload (function available from Add-ons->WASM-Reload menu option) or restart MSFS (or reload the aircraft).

Link to comment
Share on other sites

51 minutes ago, John Dowson said:

I think you are confusing things a bit. As I said, the FBW events just activate hvars or set lvar values. You can do the same with the lvar/hvar facilities provided by the WAPI .lib and .dll, and in c# using Paul's  MSFSVariableServices class.

If you really want to use the FBW events, you have to add them to FSUIPC using event files, as I indicated earlier. And to then use them, you need to use the control numbers assigned, which I also explained earlier.

To start with, rather than using the FBW events, why don't you just look at the available lvars/hvars and see if you achieve the same via lvars/hvars.  Looking at the FCU, the following hvars should be available for you to try:

and the following lvars are related:

 

Note that hvars are only available if you add them to your A320.hvar file, located in the FSUIPC WASM modules folder. From what I can see, only the first two (H:A320_Neo_FCU_MODE_MANAGED_SPEED & H:A320_Neo_EXPEDITE_MODE) are currently included in the provided A320.hvar file. To use the others, you will need to add them to that file . Once added to the file, you need to reload (function available from Add-ons->WASM-Reload menu option) or restart MSFS (or reload the aircraft).

Thanks for the great advice, now I understand it all.  

Best regards,

Patcharapol Phophun.

Link to comment
Share on other sites

  • 2 months later...
13 hours ago, kingm56 said:

First, all the HVARs work great with the exception of H:A320_Neo_FCU_HDG_INC and H:A320_Neo_FCU_HDG_DEC.  Do you know if these have been tested?  

Best to check this type of thing with MobiFlight - see https://hubhop.mobiflight.com/#/presetview/a195f339-77e4-409d-a3a4-89fd192a2666

Searching for A320_Neo_FCU_HDG_INC gives the following:

Quote

Code: (L:A32NX_TRK_FPA_MODE_ACTIVE, bool) if{ (>H:A320_Neo_FCU_AP_INC_TRACK) } els{ 1 (>K:HEADING_BUG_INC) (>H:A320_Neo_CDU_AP_INC_HEADING) }
Description: Tested on A320 stable

So it looks like A320_Neo_FCU_HDG_INC and A320_Neo_FCU_HDG_DEC are presets, not hvars. So, to use them as-is you would need to use the MF WASM and make the MF events known to FSUIPC via event files. Alternatively, you can try using the calculator code that the preset calls. Initially try using the Add-ons->WASM->Execute Calculator Code... menu option, and if it works as expected you can then have a lua script to execute the code and assign to that.

Link to comment
Share on other sites

  • 2 weeks later...

After several months away from MSFS and FSUIPC and just started up again.

I have FSUIPC v7.2.8 installed with the WASM module active in MSFS's Community folder and fly the A32NX(flybywire v6.3)

I can't get the binding of H:Vars(Events) to work.

 

I have a fbw.evt file in the FSUIPC7 folder

 

[Events]
0 = A32NX.FCU_AP_1_PUSH
1 = A32NX.FCU_AP_2_PUSH
2 = A32NX.FCU_AP_DISCONNECT_PUSH
3 = A32NX.FCU_ATHR_PUSH
4 = A32NX.FCU_ATHR_DISCONNECT_PUSH
5 = A32NX.FCU_SPD_INC
6 = A32NX.FCU_SPD_DEC
7 = A32NX.FCU_SPD_SET
8 = A32NX.FCU_SPD_PUSH
9 = A32NX.FCU_SPD_PULL
10 = A32NX.FCU_SPD_MACH_TOGGLE_PUSH
11 = A32NX.FCU_HDG_INC
12 = A32NX.FCU_HDG_DEC
13 = A32NX.FCU_HDG_SET
14 = A32NX.FCU_HDG_PUSH
15 = A32NX.FCU_HDG_PULL
16 = A32NX.FCU_TRK_FPA_TOGGLE_PUSH
17 = A32NX_FCU_ALT_INC
18 = A32NX.FCU_ALT_DEC
19 = A32NX.FCU_ALT_SET
20 = A32NX.FCU_ALT_PUSH
21 = A32NX.FCU_ALT_PULL
22 = A32NX.FCU_ALT_INCREMENT_TOGGLE
23 = A32NX.FCU_ALT_INCREMENT_SET
24 = A32NX.FCU_VS_INC
25 = A32NX.FCU_VS_DEC
26 = A32NX.FCU_VS_SET
27 = A32NX.FCU_VS_PUSH
28 = A32NX.FCU_VS_PULL
29 = A32NX.FCU_LOC_PUSH
30 = A32NX.FCU_APPR_PUSH
31 = A32NX.FCU_EXPED_PUSH

 

I can't get any of these Events to trigger any FCU activity when I bind them to either Buttons or Keypresses

 

See attached image.

 

Anyone knows what I am doing wrong here?

 


 

 

flybywire-aircraft-a320-neo

Screenshot 2021-09-05 192838.png

Link to comment
Share on other sites

I can bind the new Custom Events to both Buttons and Keypresses with FSUIPC.

In my own WASM I can send HVars e.g.

command = "(>H:A32NX_RMP_L_VHF2_BUTTON_PRESSED)";
execute_calculator_code(command.c_str(), nullptr, nullptr, nullptr);

and it will trigger the VHF2 Button 

 

But, when I try to use the same code for one of the Custom Events in the list above,

e.g.  A32NX.FCU_AP_1_PUSH

 

command = "(>H:A32NX.FCU_AP_1_PUSH)";
execute_calculator_code(command.c_str(), nullptr, nullptr, nullptr);

it will not trigger the FCU button

 

I must miss something. Are these A320NX flybywire Custom Events not H Vars?

Link to comment
Share on other sites

  • 1 month later...

Custom events are added to FSUIPC, not the WASM, by adding event files (with extension .evt) to the main FSUIPC installation folder.
Some event files (for the MobiFlight WASM and FBW A320) are included in a sub-folder of your installation folder called EventFiles.

If you want to use hvars, you need to make these know to the FSUIPC WASM by adding a hvar file (extension .hvar) to the WASM include folders. Some are also provided under a folder called HvarFiles. Not necessary if you are executing them via the ipc.execCalcCode function.

Please see the FSUIPC7 Advanced User manual for details.

Note that there is a currently a minor issue with some of the hvar files: The FSUIPC WASM will only recognise hvars if preceded by 'H:', however this is missing in some of the provided hvar files. This has been corrected in the latest version of the WASM, which is available in a topic is this forum somewhere and will be released shortly.

@roarkr Sorry, seemed to have missed your post. Probably too late, but:

On 9/5/2021 at 11:29 PM, roarkr said:

But, when I try to use the same code for one of the Custom Events in the list above,

e.g.  A32NX.FCU_AP_1_PUSH

 

command = "(>H:A32NX.FCU_AP_1_PUSH)";
execute_calculator_code(command.c_str(), nullptr, nullptr, nullptr);

it will not trigger the FCU button

I must miss something. Are these A320NX flybywire Custom Events not H Vars?

No, a custom event is a K var, not a hvar. Try

command = "(>K:A32NX.FCU_AP_1_PUSH)";
 

See https://hubhop.mobiflight.com/#/presetview/17d6a1e6-e019-4d8f-8932-05dfcc236d93/

John

Link to comment
Share on other sites

  • 6 months later...

hi,

I followed this post carefully and tried to follow the suggested settings carefully.
I am using the same files relative to the 320neo FBW (.hvar and .evt) and I have inserted the references in the FUIPC7.INI.

I have really tried them all but the Hvar "A32NX FCU HDG PUSH" & "A32NX FCU HDG PULL" do not appear in the dropdownlist as below.
Can you help me understand why? Thanks

ddl.jpg.32e1ca029bbb544d45eb525131831866.jpg

 

Link to comment
Share on other sites

Your post/questions are slightly confused....Please be aware of the difference between hvars, presets and custom controls/events.

hvar: is a simulator HTML variable. These can be made know to FSUIPC7 via *.havr files. Once made known to FSUIPC7, they can be used in macros and in lua scripts. They never appear in drop-down menus. They can also be activated by (or used in) calculator code, by standard controls or via custom controls. They do not need to be made known to FSUIPC7 (via *.hvar files) for such use.

preset: a preset is just a name assigned to a calculator code string. These are made known to FSUIPC7 via the files events.txt and myevents.txt and all entries will be available for assignment, prefixed by 'Preset: ' in the controls drop-down menus (as in your picture).

Custom events/controls: these are additional events/controls whose implementation is provided by an add-on (usually either an aircraft itself, or a WASM module such as the MobiFlight Event module).  These are made known to FSUIPC7 via *.evt files, and will be available for assignments, prefixed by ':' in the controls drop-down menus (and therefore located at the top of these menus). Also note that these are only added once a connection is made to MSFS2020. Also, the total number of such events is controlled by the MaxNumberOfCustomEvents ini parameter, which has a default value of 1024.

9 hours ago, grigna said:

I am using the same files relative to the 320neo FBW (.hvar and .evt) and I have inserted the references in the FUIPC7.INI.

What have you inserted in the FSUIPC7.ini? You should not insert any files in the ini - the file sections (such as [EventFiles]) are managed by FSUIPC7 and should not be manually adjusted as this can cause issues.

9 hours ago, grigna said:

I have really tried them all but the Hvar "A32NX FCU HDG PUSH" & "A32NX FCU HDG PULL" do not appear in the dropdownlist as below.

Hvars never appear in drop-downs - only presets and custom events. Are you referring to the following custom events:
    A32NX.FCU_HDG_PUSH
    A32NX.FCU_HDG_PULL
?
If so, then these are located in the event file EventFiles\flybywire-aircraft-a320-neo.evt (under your FSUIPC7 installation folder). To use these, move that file up one folder level to the main FSUIPC7 installation folder. They will then be available for assignment (once FSUIPC7 is connected to MSFS) as ':A32NX. FCU HDG PUSH' and  ':A32NX. FCU HDG PULL'.

However, almost all events can be used as presets now. You can use the following presets:
    HDG_Pull#(>K:A32NX.FCU_HDG_PULL)
    HDG_Push#(>K:A32NX.FCU_HDG_PUSH)
    HDG_Push_Pull_Toggle#(A:AUTOPILOT HEADING SLOT INDEX, Number) 1 == if{ (>K:A32NX.FCU_HDG_PUSH) } els{ (>K:A32NX.FCU_HDG_PULL) }
which will be listed as 'Preset: HDG PULL', 'Preset: HDG PUSH' and 'Preset: HDG PUSH PULL TOGGLE'.

John
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.