Page 2 of 2

Re: PMDG Events and Variables - Success!

Posted: 04 Mar 2013, 01:09
by Aeroworx
For hardware controllers you might want to have a look at OpenCockpits

http://www.opencockpits.com/index.php/en/

Johan

Re: PMDG Events and Variables - Success!

Posted: 06 Oct 2013, 06:58
by DougRamirez
ryhoo2 wrote:]First of all, MANY MANY MANY thanks to the author of this wonderful tool, Great job Petr!!!

I just figured how to use PMDG 737NGX specific events/variables and I wanted to share.

PMDG events:
You can use for this purpose FSXEvents, but PMDG's events are not defined on the list, so... we need to script it using custom event numbers that are defined in PMDG's SDK.[color=#000000
To find the correct values open this file: <FSX main folder>\PMDG\PMDG 737 NGX\SDK\PMDG_NGX_SDK.h
You can find the values there, for ex. to switch on the A/T ARM you have this event:
#define EVT_MCP_AT_ARM_SWITCH (THIRD_PARTY_EVENT_ID_MIN + 380)

THIRD_PARTY_EVENT_ID_MIN is a constant and always equals to 69632, so if you do the math we get the value of 70012.

And here's how to use it in script:
HIDMacros.FSXEvent "#70012", 0

One more thing needs to be done to make it work. You need to enable PMDG data broadcasting. Add the following 2 lines to this file: <FSX main folder>\PMDG\PMDG 737 NGX\737NGX_Options.ini
[SDK]
EnableDataBroadcast=1

Voila!

PMDG Variables:
There are also variables that will tell you what is the current state of the particular component, for ex. is the [/color]led lights on or off, what's the heading, etc.
To be able to read from PMDG variables you need to enable PMDG data broadcast as above and also you need to have the FSUIPC library installed (at least version 4.8 as far as I know).
All variables are defined in the PDF file that comes with the FSUIPC library in here:
<FSX main folder>\Modules\FSUIPC Documents\Offset Mapping for PMDG 737NGX.pdf
If you can't find this document your version is probably too old.
Putting together events and variables enables you to make more advanced actions for your keys.
Below is the example for the Landing lights which you want to toggle. As you know they are divided into 2 types of light: Retract and Fixed. To decide which position they should be changed to you first need to know their current position. That's what I do in this example. I first read the state of both parts of light and based on that information I turn them all ON or OFF.

Code: Select all

' Put this in the global script routines
' Constants - PMDG Events & Variables
Const LTS_LandingLtRetractableSw = &H64F4   ' values from FSUIPC PDF
Const LTS_LandingLtFixedSw = &H64F6
Const EVT_OH_LAND_LIGHTS_GUARD = "#69742"
Const MOUSE_FLAG_LEFTSINGLE = &H20000000   ' values from PMDG SDK.h
Const MOUSE_FLAG_RIGHTSINGLE = &H80000000

Code: Select all

' Put this in the action script of the key
L1 = HIDMacros.GetFSUIPCInt(LTS_LandingLtRetractableSw, 2)
L2 = HIDMacros.GetFSUIPCInt(LTS_LandingLtFixedSw, 2)

if (Round(L1)+Round(L2) > 0) then
  HIDMacros.FSXEvent EVT_OH_LAND_LIGHTS_GUARD, MOUSE_FLAG_RIGHTSINGLE
else
  HIDMacros.FSXEvent EVT_OH_LAND_LIGHTS_GUARD, MOUSE_FLAG_LEFTSINGLE
end if
When all the lights are OFF (value read is 0) they are toggled to ON (left click on the lights guard). If any of the light is ON (value read > 0) they are all turned OFF (right click on the lights guard).
Hope this helps!
Thanks for sharing detailed information about the tool.. I will get it tomorrow and your post will surely help me lot..

Re: PMDG Events and Variables - Success!

Posted: 12 Jun 2018, 16:25
by Les Trickett
Hi Doug.
I have been baffled with science.
And just read your post.
Would you please help with following.
1) I would like to use a toggle switch to switch parking brake on and off so I can incorporate an LED.
2)I would like to use a rotary switch to operate the magnification on the navigation screen.
I have p3d v4 registered versions of fsuipc and spadnext.
Using pmdg 737 ngx
Been going crazy over last few days trying to puzzle it out.
Seems at 62 my brain has stupified
Best regards
Les Trickett
Email machinerepairs@hotmail.com