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

Quote

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

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

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

John,

Sorry to resurrect a 3-month old thread; however, I have a related question.  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?  

Link to comment
Share on other sites

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

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.