PMDG Events and Variables - Success!

How can be this controlled in that simulator? Can HIDmacros be used with this application?

PMDG Events and Variables - Success!

Postby ryhoo2 » 24 Feb 2013, 18:08

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.
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 light 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!
Last edited by ryhoo2 on 01 Mar 2013, 00:38, edited 5 times in total.
ryhoo2
 
Posts: 21
Joined: 24 Feb 2013, 17:57
Location: Poland

Re: PMDG Events - Success!

Postby Larry » 28 Feb 2013, 07:22

HI ryhoo2!!!!!
Awesome! You have answered many questions I have had regarding the PMDG SDK file. Like the "Third Party Event ID" plus 380 = 70012 stuff! THANK YOU! I have had a question about that for a while regarding entering this info into the FSUIPC "custom control" area!

Anyhow...where do you enter this script into HIDmacros? Yopu said...Quote: "And here's how to use it in script:
HIDMacros.FSXEvent "#70012", 0".

Sorry, but I have been reading so much about macros, scripts, LUA and offset mapping that my head is going to explode! Would this be inserted under the "script" tab, or the "scripted" tab under the "macros/action" section in HID macros? And is there any other "simple setting/s" needed in HID macros I might have to add to make this work? Sorry about my simple question/s. Thanks, Larry 8-)
Larry
 
Posts: 19
Joined: 28 Feb 2013, 06:45

Re: PMDG Events - Success!

Postby ryhoo2 » 28 Feb 2013, 10:52

Hi Larry!

You should put this under "scripted" tab, under the "macros/action" section in HID macros, where you define an action for the selected key.
I will post more fancy stuff for PMDG soon:), like how to read PMDG variables, so you can take full control over PMDG! And finally my keyboard configuration specific for 737NGX, including knobs control!

Stay tuned!
ryhoo2
 
Posts: 21
Joined: 24 Feb 2013, 17:57
Location: Poland

Re: PMDG Events and Variables - Success!

Postby ryhoo2 » 01 Mar 2013, 00:29

All right, I have added more information on how to read the current state of the PMDG component in the first post.
ryhoo2
 
Posts: 21
Joined: 24 Feb 2013, 17:57
Location: Poland

Re: PMDG Events and Variables - Success!

Postby Larry » 01 Mar 2013, 06:10

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


I can get this to work in FSUIPC by assigning a button to turn the auto throttle on (using 70012 custom control), this works good, but when entering the script above into Hidmacros (action/scripted area), and assigning a key stroke, it does not work. I tried clicking "compile" and "test" and tried again. Is this VB script or jscript? Maybe a missing setting in hidmacros? Do I need to select a predefined action under the action tab also? I'm still learning this program. :?

I can get the "send keyboard sequence" to work (did the parking brake) but had no luck with your auto throttle example. I copied and pasted your example above and included the space after the comma just like your example (the space before the "0").

FYI-I will admit I'm not a code guy, I use Dreamweaver to create my PHP based website and look up scripts on internet when I want to try to do something specific. So needlesss to say the extra added info you included about how to READ the PMDG current switch settings is something I want to eventually figure out! I can find all the coded you dug up from both FSUIPC and PMDG files but that's about it. I'm still trying to figure out which lines are a switch input command and which lines tell a specific setting.

The information you supplied about
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.
is the most useful thing I have read in weeks of building/setting my forward overhead panel.

Back to Hidmacros....Stuff like the added "&H" in front of the line "Const MOUSE_FLAG_LEFTSINGLE = &H20000000" I am assuming means Hex?!? See, I'm such a noob when it comes to offset mapping code and macros, and I see these line additions but don't know why they are there. Guess I should do my homework (at 45 ha, ha). I'm having no problems building the panels, but programming them is where I hit the snags.

PS - The auto throttle can be set mouse macro in FSUIPC as you probably know, but I would like the option of keyboard macro settings! Sorry to ramble so much. :D Thanks, Larry
Larry
 
Posts: 19
Joined: 28 Feb 2013, 06:45

Re: PMDG Events and Variables - Success!

Postby ryhoo2 » 01 Mar 2013, 11:24

Larry,
Did you enable the PMDG data broadcasting in the Options file 737NGX_Options.ini? See my first post.
It's a simple script example found on the forums. You should not select any predefined action, just paste the one-liner.

Also, some keys are reserved by the PMDG, like L, G, A... See my other posts on how to unlock them.

And yes, the &H is Hex, I defined it like that so it matches exactly the values from the SDK.

Here's more troubleshooting that might help:
http://goflight.vanillaforums.com/discussion/151/mcp-pro-with-pmdg-737ngx
Good luck!

Regards,
Michal
ryhoo2
 
Posts: 21
Joined: 24 Feb 2013, 17:57
Location: Poland

Re: PMDG Events and Variables - Success!

Postby Larry » 02 Mar 2013, 20:31

thanks, I will look into it further.
Larry
 
Posts: 19
Joined: 28 Feb 2013, 06:45

Re: PMDG Events and Variables - Success!

Postby Larry » 03 Mar 2013, 07:10

Hi Michal,
It appears after inserting the code, I had to close/re-start Hidmacros. Works great now. I noticed the parameter/s does not show on a lot of the SDK lines. I had to mess with 1 AND 0 at the end of line to get the switch to turn off. Glad it worked.

Before I get side tracked, can you send me to a good place (site) to go for help in controlling/setting up "outputs" like annunciator lights. I am using input board/encoder boards from desktop aviator which work great with toggle, rotary, push button and pulse switches. I even have 5 V LEDS that can turn on and off, and have separate power supply with switch running back lighting high intensity LEDS. But I do not know how to set up outputs (I assume the Boolean lines in the "offset mapping' PDF and SDK)?? Do you know hwt kind of "output boards" I can use for this purpose (inexpensive I hope), and where to get help with FSUIPC to control them?

I am still reading your previous post and will try comprehend that added info later. :geek: I work full time, do extra jobs on the side (and have a website) and can only study this stuff/work on the overhead panel at night. I get real tired at times and sometimes fall asleep on my computer trying to soak this stuff up. Sorry if I ramble... I just try to ask everything possible that comes to mind to prevent too many trips to the forum. THANK YOU! Larry :mrgreen:
Larry
 
Posts: 19
Joined: 28 Feb 2013, 06:45

Re: PMDG Events and Variables - Success!

Postby ryhoo2 » 03 Mar 2013, 12:59

Hi Larry,

I have no experience in the hardware controllers yet (they're too expensive for me at the moment), but I've done some reading and these boards might help you:
1. http://www.pjrc.com/teensy/ - can be configured as Input, Output or Analog; USB plug-n-play
2. http://www.amazon.com/SmartProjects-Mega-Arduino-MEGA-Board/dp/B004A7H3DG
http://arduino.cc/en/Main/arduinoBoardMega2560
ryhoo2
 
Posts: 21
Joined: 24 Feb 2013, 17:57
Location: Poland

Re: PMDG Events and Variables - Success!

Postby Larry » 03 Mar 2013, 17:04

thanks a lot, you've been a lot of help. Larry
Larry
 
Posts: 19
Joined: 28 Feb 2013, 06:45

Next

Return to HOW-TOs and documentation

Who is online

Users browsing this forum: No registered users and 1 guest