Jump to content
The simFlight Network Forums

Some newbie questions


rfresh

Recommended Posts

new Offset<string>("info", 0x3D00, 24);

Yes, the 24 is the number of bytes to read. This is only required for certain offset types where the length cannot be determined from the type itself. So with 'int' for example you don't need to specify the length because an 'int' is always 4 bytes. For strings and arrays the dll needs some extra info as strings don't have a fixed length.

 

The "info" part is an example of the grouping feature. You don't have to use grouping, but it can make sense when you don't want to read some offsets as often as others. Typically in applications there is data that needs to be updated frequently (e.g. aircraft position, airspeed etc) and other data that may only be required infrequently or just once. To avoid reading more data than is required you can place offsets in named groups. The names can be anything you like.

 

You can then choose when to Process() the different groups by passing the name to the Process() method as you've seen. You can also process multiple groups at once, see the user guide for how to do that.

 

You could declare the offset like this:

private Offset<string> aircraftName = new Offset<string>(0x3D00, 24);

and then it will work with the normal Process().

 

It's really up to you how, or if, you use the grouping.

 

Paul

Link to comment
Share on other sites

So, I'm still figuring out how to change the fuel tank levels in the PMDG 737NGX and now PMDG has confirmed that the only way to do this is to send keys to the CDU on the MENU->FS ACTIONS->FUEL page. I looked in your UserGuide but didn't see anything about sending key strokes to FSX. Did I miss it worded in another way? How do I send keys to FSUIPC/FSX using your .DLL?

 

Thanks...

Link to comment
Share on other sites

The DLL has nothing specific, but FSUIPC has a key send facility at offset 0x3200. It seems to be a 'front' for a normal Win32 SendMessage() however, so unless you're familiar with the Win32 API and working with bits and bytes it might be a bit of a challenge. The documentation for the key down message is here: (You'll need this to know what to set as the Iparam and Wparam).

 

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646280%28v=vs.85%29.aspx

 

You'll also need to manage each key up as well.

 

I wonder if the PMDG interface has a more direct way of simulating key presses for the CDU through a flight sim 'control' (aka 'events')? It's worth looking in the PMDG SDK for the control list (I think it's in the form of a C header file). This would be much easier than sending actual keyboard presses into the Flight Sim windows process.. If it does exist then report back and we'll go from there.

 

If they don't have such a control then I could put a feature in the DLL to send real key presses to FSX so that you don't have to deal directly with the Win32 API parameters. It will make it much simpler.

 

Paul

Link to comment
Share on other sites

Here is what I've found in the PMDG SDK .h file. It looks like they have mapped out the key inputs to the CDU pretty well but I don't know how to make use of this information (sorry). I also see they have some mouse detection defines but, I don't know how to use those. However, I don't need mouse input, I need to send keys presses to the CDU itself to load the fuel tanks.
 
(I'm attaching the whole .h file).
 
 
PMDG_NGX_SDK.h file:
 
{snip lines above this seciton}
 
// The rest of the controls and indicators match their standard FSX counterparts
// and can be accessed using the standard SimConnect means.
// NGX Control Structure
struct PMDG_NGX_Control
{
unsigned int Event;
unsigned int Parameter;
};
#define MOUSE_FLAG_RIGHTSINGLE   0x80000000
#define MOUSE_FLAG_MIDDLESINGLE  0x40000000
#define MOUSE_FLAG_LEFTSINGLE    0x20000000
#define MOUSE_FLAG_RIGHTDOUBLE   0x10000000
#define MOUSE_FLAG_MIDDLEDOUBLE  0x08000000
#define MOUSE_FLAG_LEFTDOUBLE    0x04000000
#define MOUSE_FLAG_RIGHTDRAG     0x02000000
#define MOUSE_FLAG_MIDDLEDRAG    0x01000000
#define MOUSE_FLAG_LEFTDRAG      0x00800000
#define MOUSE_FLAG_MOVE          0x00400000
#define MOUSE_FLAG_DOWN_REPEAT   0x00200000
#define MOUSE_FLAG_RIGHTRELEASE  0x00080000
#define MOUSE_FLAG_MIDDLERELEASE 0x00040000
#define MOUSE_FLAG_LEFTRELEASE   0x00020000
#define MOUSE_FLAG_WHEEL_FLIP    0x00010000   // invert direction of mouse wheel
#define MOUSE_FLAG_WHEEL_SKIP    0x00008000   // look at next 2 rect for mouse wheel commands
#define MOUSE_FLAG_WHEEL_UP      0x00004000
#define MOUSE_FLAG_WHEEL_DOWN    0x00002000
 
 
// Control Events
 
#ifndef THIRD_PARTY_EVENT_ID_MIN
#define THIRD_PARTY_EVENT_ID_MIN         0x00011000 // equals to 69632
#endif
 
// CDU
#define EVT_CDU_L_L1 (THIRD_PARTY_EVENT_ID_MIN + 534)
#define EVT_CDU_L_L2 (THIRD_PARTY_EVENT_ID_MIN + 535)
#define EVT_CDU_L_L3 (THIRD_PARTY_EVENT_ID_MIN + 536)
#define EVT_CDU_L_L4 (THIRD_PARTY_EVENT_ID_MIN + 537)
#define EVT_CDU_L_L5 (THIRD_PARTY_EVENT_ID_MIN + 538)
#define EVT_CDU_L_L6 (THIRD_PARTY_EVENT_ID_MIN + 539)
#define EVT_CDU_L_R1 (THIRD_PARTY_EVENT_ID_MIN + 540)
#define EVT_CDU_L_R2 (THIRD_PARTY_EVENT_ID_MIN + 541)
#define EVT_CDU_L_R3 (THIRD_PARTY_EVENT_ID_MIN + 542)
#define EVT_CDU_L_R4 (THIRD_PARTY_EVENT_ID_MIN + 543)
#define EVT_CDU_L_R5 (THIRD_PARTY_EVENT_ID_MIN + 544)
#define EVT_CDU_L_R6 (THIRD_PARTY_EVENT_ID_MIN + 545)
#define EVT_CDU_L_INIT_REF (THIRD_PARTY_EVENT_ID_MIN + 546)
#define EVT_CDU_L_RTE (THIRD_PARTY_EVENT_ID_MIN + 547)
#define EVT_CDU_L_CLB (THIRD_PARTY_EVENT_ID_MIN + 548)
#define EVT_CDU_L_CRZ (THIRD_PARTY_EVENT_ID_MIN + 549)
#define EVT_CDU_L_DES (THIRD_PARTY_EVENT_ID_MIN + 550)
#define EVT_CDU_L_MENU (THIRD_PARTY_EVENT_ID_MIN + 551)
#define EVT_CDU_L_LEGS (THIRD_PARTY_EVENT_ID_MIN + 552)
#define EVT_CDU_L_DEP_ARR (THIRD_PARTY_EVENT_ID_MIN + 553)
#define EVT_CDU_L_HOLD (THIRD_PARTY_EVENT_ID_MIN + 554)
#define EVT_CDU_L_PROG (THIRD_PARTY_EVENT_ID_MIN + 555)
#define EVT_CDU_L_EXEC (THIRD_PARTY_EVENT_ID_MIN + 556)
#define EVT_CDU_L_N1_LIMIT (THIRD_PARTY_EVENT_ID_MIN + 557)
#define EVT_CDU_L_FIX (THIRD_PARTY_EVENT_ID_MIN + 558)
#define EVT_CDU_L_PREV_PAGE (THIRD_PARTY_EVENT_ID_MIN + 559)
#define EVT_CDU_L_NEXT_PAGE (THIRD_PARTY_EVENT_ID_MIN + 560)
#define EVT_CDU_L_1 (THIRD_PARTY_EVENT_ID_MIN + 561)
#define EVT_CDU_L_2 (THIRD_PARTY_EVENT_ID_MIN + 562)
#define EVT_CDU_L_3 (THIRD_PARTY_EVENT_ID_MIN + 563)
#define EVT_CDU_L_4 (THIRD_PARTY_EVENT_ID_MIN + 564)
#define EVT_CDU_L_5 (THIRD_PARTY_EVENT_ID_MIN + 565)
#define EVT_CDU_L_6 (THIRD_PARTY_EVENT_ID_MIN + 566)
#define EVT_CDU_L_7 (THIRD_PARTY_EVENT_ID_MIN + 567)
#define EVT_CDU_L_8 (THIRD_PARTY_EVENT_ID_MIN + 568)
#define EVT_CDU_L_9 (THIRD_PARTY_EVENT_ID_MIN + 569)
#define EVT_CDU_L_DOT (THIRD_PARTY_EVENT_ID_MIN + 570)
#define EVT_CDU_L_0 (THIRD_PARTY_EVENT_ID_MIN + 571)
#define EVT_CDU_L_PLUS_MINUS (THIRD_PARTY_EVENT_ID_MIN + 572)
#define EVT_CDU_L_A (THIRD_PARTY_EVENT_ID_MIN + 573)
#define EVT_CDU_L_B (THIRD_PARTY_EVENT_ID_MIN + 574)
#define EVT_CDU_L_C (THIRD_PARTY_EVENT_ID_MIN + 575)
#define EVT_CDU_L_D (THIRD_PARTY_EVENT_ID_MIN + 576)
#define EVT_CDU_L_E (THIRD_PARTY_EVENT_ID_MIN + 577)
#define EVT_CDU_L_F (THIRD_PARTY_EVENT_ID_MIN + 578)
#define EVT_CDU_L_G (THIRD_PARTY_EVENT_ID_MIN + 579)
#define EVT_CDU_L_H (THIRD_PARTY_EVENT_ID_MIN + 580)
#define EVT_CDU_L_I (THIRD_PARTY_EVENT_ID_MIN + 581)
#define EVT_CDU_L_J (THIRD_PARTY_EVENT_ID_MIN + 582)
#define EVT_CDU_L_K (THIRD_PARTY_EVENT_ID_MIN + 583)
#define EVT_CDU_L_L (THIRD_PARTY_EVENT_ID_MIN + 584)
#define EVT_CDU_L_M (THIRD_PARTY_EVENT_ID_MIN + 585)
#define EVT_CDU_L_N (THIRD_PARTY_EVENT_ID_MIN + 586)
#define EVT_CDU_L_O (THIRD_PARTY_EVENT_ID_MIN + 587)
#define EVT_CDU_L_P (THIRD_PARTY_EVENT_ID_MIN + 588)
#define EVT_CDU_L_Q (THIRD_PARTY_EVENT_ID_MIN + 589)
#define EVT_CDU_L_R (THIRD_PARTY_EVENT_ID_MIN + 590)
#define EVT_CDU_L_S (THIRD_PARTY_EVENT_ID_MIN + 591)
#define EVT_CDU_L_T (THIRD_PARTY_EVENT_ID_MIN + 592)
#define EVT_CDU_L_U (THIRD_PARTY_EVENT_ID_MIN + 593)
#define EVT_CDU_L_V (THIRD_PARTY_EVENT_ID_MIN + 594)
#define EVT_CDU_L_W (THIRD_PARTY_EVENT_ID_MIN + 595)
#define EVT_CDU_L_X (THIRD_PARTY_EVENT_ID_MIN + 596)
#define EVT_CDU_L_Y (THIRD_PARTY_EVENT_ID_MIN + 597)
#define EVT_CDU_L_Z (THIRD_PARTY_EVENT_ID_MIN + 598)
#define EVT_CDU_L_SPACE (THIRD_PARTY_EVENT_ID_MIN + 599)
#define EVT_CDU_L_DEL (THIRD_PARTY_EVENT_ID_MIN + 600)
#define EVT_CDU_L_SLASH (THIRD_PARTY_EVENT_ID_MIN + 601)
#define EVT_CDU_L_CLR (THIRD_PARTY_EVENT_ID_MIN + 602)
#define EVT_CDU_L_BRITENESS (THIRD_PARTY_EVENT_ID_MIN + 605)
 
#define EVT_CDU_R_L1 (THIRD_PARTY_EVENT_ID_MIN + 606)
#define EVT_CDU_R_L2 (THIRD_PARTY_EVENT_ID_MIN + 607)
#define EVT_CDU_R_L3 (THIRD_PARTY_EVENT_ID_MIN + 608)
#define EVT_CDU_R_L4 (THIRD_PARTY_EVENT_ID_MIN + 609)
#define EVT_CDU_R_L5 (THIRD_PARTY_EVENT_ID_MIN + 610)
#define EVT_CDU_R_L6 (THIRD_PARTY_EVENT_ID_MIN + 611)
#define EVT_CDU_R_R1 (THIRD_PARTY_EVENT_ID_MIN + 612)
#define EVT_CDU_R_R2 (THIRD_PARTY_EVENT_ID_MIN + 613)
#define EVT_CDU_R_R3 (THIRD_PARTY_EVENT_ID_MIN + 614)
#define EVT_CDU_R_R4 (THIRD_PARTY_EVENT_ID_MIN + 615)
#define EVT_CDU_R_R5 (THIRD_PARTY_EVENT_ID_MIN + 616)
#define EVT_CDU_R_R6 (THIRD_PARTY_EVENT_ID_MIN + 617)
#define EVT_CDU_R_INIT_REF (THIRD_PARTY_EVENT_ID_MIN + 618)
#define EVT_CDU_R_RTE (THIRD_PARTY_EVENT_ID_MIN + 619)
#define EVT_CDU_R_CLB (THIRD_PARTY_EVENT_ID_MIN + 620)
#define EVT_CDU_R_CRZ (THIRD_PARTY_EVENT_ID_MIN + 621)
#define EVT_CDU_R_DES (THIRD_PARTY_EVENT_ID_MIN + 622)
#define EVT_CDU_R_MENU (THIRD_PARTY_EVENT_ID_MIN + 623)
#define EVT_CDU_R_LEGS (THIRD_PARTY_EVENT_ID_MIN + 624)
#define EVT_CDU_R_DEP_ARR (THIRD_PARTY_EVENT_ID_MIN + 625)
#define EVT_CDU_R_HOLD (THIRD_PARTY_EVENT_ID_MIN + 626)
#define EVT_CDU_R_PROG (THIRD_PARTY_EVENT_ID_MIN + 627)
#define EVT_CDU_R_EXEC (THIRD_PARTY_EVENT_ID_MIN + 628)
#define EVT_CDU_R_N1_LIMIT (THIRD_PARTY_EVENT_ID_MIN + 629)
#define EVT_CDU_R_FIX (THIRD_PARTY_EVENT_ID_MIN + 630)
#define EVT_CDU_R_PREV_PAGE (THIRD_PARTY_EVENT_ID_MIN + 631)
#define EVT_CDU_R_NEXT_PAGE (THIRD_PARTY_EVENT_ID_MIN + 632)
#define EVT_CDU_R_1 (THIRD_PARTY_EVENT_ID_MIN + 633)
#define EVT_CDU_R_2 (THIRD_PARTY_EVENT_ID_MIN + 634)
#define EVT_CDU_R_3 (THIRD_PARTY_EVENT_ID_MIN + 635)
#define EVT_CDU_R_4 (THIRD_PARTY_EVENT_ID_MIN + 636)
#define EVT_CDU_R_5 (THIRD_PARTY_EVENT_ID_MIN + 637)
#define EVT_CDU_R_6 (THIRD_PARTY_EVENT_ID_MIN + 638)
#define EVT_CDU_R_7 (THIRD_PARTY_EVENT_ID_MIN + 639)
#define EVT_CDU_R_8 (THIRD_PARTY_EVENT_ID_MIN + 640)
#define EVT_CDU_R_9 (THIRD_PARTY_EVENT_ID_MIN + 641)
#define EVT_CDU_R_DOT (THIRD_PARTY_EVENT_ID_MIN + 642)
#define EVT_CDU_R_0 (THIRD_PARTY_EVENT_ID_MIN + 643)
#define EVT_CDU_R_PLUS_MINUS (THIRD_PARTY_EVENT_ID_MIN + 644)
#define EVT_CDU_R_A (THIRD_PARTY_EVENT_ID_MIN + 645)
#define EVT_CDU_R_B (THIRD_PARTY_EVENT_ID_MIN + 646)
#define EVT_CDU_R_C (THIRD_PARTY_EVENT_ID_MIN + 647)
#define EVT_CDU_R_D (THIRD_PARTY_EVENT_ID_MIN + 648)
#define EVT_CDU_R_E (THIRD_PARTY_EVENT_ID_MIN + 649)
#define EVT_CDU_R_F (THIRD_PARTY_EVENT_ID_MIN + 650)
#define EVT_CDU_R_G (THIRD_PARTY_EVENT_ID_MIN + 651)
#define EVT_CDU_R_H (THIRD_PARTY_EVENT_ID_MIN + 652)
#define EVT_CDU_R_I (THIRD_PARTY_EVENT_ID_MIN + 653)
#define EVT_CDU_R_J (THIRD_PARTY_EVENT_ID_MIN + 654)
#define EVT_CDU_R_K (THIRD_PARTY_EVENT_ID_MIN + 655)
#define EVT_CDU_R_L (THIRD_PARTY_EVENT_ID_MIN + 656)
#define EVT_CDU_R_M (THIRD_PARTY_EVENT_ID_MIN + 657)
#define EVT_CDU_R_N (THIRD_PARTY_EVENT_ID_MIN + 658)
#define EVT_CDU_R_O (THIRD_PARTY_EVENT_ID_MIN + 659)
#define EVT_CDU_R_P (THIRD_PARTY_EVENT_ID_MIN + 660)
#define EVT_CDU_R_Q (THIRD_PARTY_EVENT_ID_MIN + 661)
#define EVT_CDU_R_R (THIRD_PARTY_EVENT_ID_MIN + 662)
#define EVT_CDU_R_S (THIRD_PARTY_EVENT_ID_MIN + 663)
#define EVT_CDU_R_T (THIRD_PARTY_EVENT_ID_MIN + 664)
#define EVT_CDU_R_U (THIRD_PARTY_EVENT_ID_MIN + 665)
#define EVT_CDU_R_V (THIRD_PARTY_EVENT_ID_MIN + 666)
#define EVT_CDU_R_W (THIRD_PARTY_EVENT_ID_MIN + 667)
#define EVT_CDU_R_X (THIRD_PARTY_EVENT_ID_MIN + 668)
#define EVT_CDU_R_Y (THIRD_PARTY_EVENT_ID_MIN + 669)
#define EVT_CDU_R_Z (THIRD_PARTY_EVENT_ID_MIN + 670)
#define EVT_CDU_R_SPACE (THIRD_PARTY_EVENT_ID_MIN + 671)
#define EVT_CDU_R_DEL (THIRD_PARTY_EVENT_ID_MIN + 672)
#define EVT_CDU_R_SLASH (THIRD_PARTY_EVENT_ID_MIN + 673)
#define EVT_CDU_R_CLR (THIRD_PARTY_EVENT_ID_MIN + 674)
#define EVT_CDU_R_BRITENESS (THIRD_PARTY_EVENT_ID_MIN + 677)
 

 

 

PMDG_NGX_SDK.txt

Link to comment
Share on other sites

The DLL has nothing specific, but FSUIPC has a key send facility at offset 0x3200. It seems to be a 'front' for a normal Win32 SendMessage() however, so unless you're familiar with the Win32 API and working with bits and bytes it might be a bit of a challenge. The documentation for the key down message is here: (You'll need this to know what to set as the Iparam and Wparam).

 

You can more easily send keypresses using one of the added FSUIPC controls:

 

1070 keypress and release

1071 key press and hold

1072 key release

 

These are documented in the Advanced User's manual (page 24 or so) and can be sent via offset 3110/4/

 

Pete

Link to comment
Share on other sites

Here is what I've found in the PMDG SDK .h file. It looks like they have mapped out the key inputs to the CDU pretty well but I don't know how to make use of this information (sorry). I also see they have some mouse detection defines but, I don't know how to use those. However, I don't need mouse input, I need to send keys presses to the CDU itself to load the fuel tanks.

 

These are custom controls. Just work out the numerical value assigned to each name (a simple addition) and send it via offset 3110.

 

Pete

Link to comment
Share on other sites

Hi Pete

 

Yes, but can I do this in C#? I'm not programming my flight stick buttons to do this as is the usual way folks interact with FSUIPC.

 

So, here is my key sequence as an example of pushing keys to the CDU to load 3,456 pounds of fuel into tank 1 (using the Left CDU):

 

Press MENU button
#define EVT_CDU_L_MENU (THIRD_PARTY_EVENT_ID_MIN + 551)
Press FS ACTIONS> LSK5R
#define EVT_CDU_L_R5 (THIRD_PARTY_EVENT_ID_MIN + 544)
Press <FUEL LSK1L
#define EVT_CDU_L_L1 (THIRD_PARTY_EVENT_ID_MIN + 534)
Press digit 3
#define EVT_CDU_L_3 (THIRD_PARTY_EVENT_ID_MIN + 563)
Press digit 4
#define EVT_CDU_L_4 (THIRD_PARTY_EVENT_ID_MIN + 564)
Press digit 5
#define EVT_CDU_L_5 (THIRD_PARTY_EVENT_ID_MIN + 565)
Press digit 6
#define EVT_CDU_L_6 (THIRD_PARTY_EVENT_ID_MIN + 566)
Load '3456' pounds of fuel into tank1 for example which is LSK3L
#define EVT_CDU_L_L3 (THIRD_PARTY_EVENT_ID_MIN + 536)
Link to comment
Share on other sites

Thanks for that Pete, I didn't know about those control for sending Key Presses.

 

Ralph - here's an example of sending the key presses for your sequence:

 

First you need to declare the offset to send the control to (0x3110). Here i've put it in it's own group and made it write only. Also I've declared the constant for the THIRD_PARTY_EVENT_ID_MIN value to make things easier.

private Offset<int> sendControl = new Offset<int>("SendControl", 0x3110, true);
private readonly int THIRD_PARTY_EVENT_ID_MIN = 0x00011000; // equal to 69632

Then to send the sequence you need this:

// Press MENU button
sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 551;
FSUIPCConnection.Process("SendControl");

// Press FS ACTIONS> LSK5R
sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 544;
FSUIPCConnection.Process("SendControl");

// Press <FUEL LSK1L
sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 534;
FSUIPCConnection.Process("SendControl");

// Press digit 3
sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 563;
FSUIPCConnection.Process("SendControl");

// Press digit 4
sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 564;
FSUIPCConnection.Process("SendControl");

Etc...

You could go to the trouble of declaring all the constants as well as the 'min' constant. You can then use those variable names instead of using the '+' syntax all the time. e.g.

private readonly int EVT_CDU_L_4  = THIRD_PARTY_EVENT_ID_MIN + 564;

then you can just use this to set the control value. It will make the code much more readable.

sendControl.Value = EVT_CDU_L_4;

Paul

Link to comment
Share on other sites

Hmmm...I tried out your example code Paul but I didn't see anything show up in the CDU Fuel Page.

 

UPDATE: I have not registered FSUIPC yet...could that be it?

 

namespace FSUIPC_Fuel_Tanks
{
    public partial class FSXFuelConfigForm : Form
    {
        PayloadServices ps;
        private Offset<int> sendControl = new Offset<int>("SendControl", 0x3110, true);
        private readonly int THIRD_PARTY_EVENT_ID_MIN = 0x00011000; // equal to 69632
        public FSXFuelConfigForm()
        {
            InitializeComponent();
        }
        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void FSXFuelConfigForm_Load(object sender, EventArgs e)
        {
            try
            {
                FSUIPCConnection.Open();
            }
            catch (FSUIPCException ex)
            {
                if (ex.FSUIPCErrorCode == FSUIPCError.FSUIPC_ERR_SENDMSG)
                {
                    FSUIPCConnection.Close();
                    MessageBox.Show("Unable to connect to FSX.");
                }
                else
                {
 
                }
            }
            ps = FSUIPCConnection.PayloadServices;
        }
        private void btnSetTankValues_Click(object sender, EventArgs e)
        {
            ps.RefreshData();
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 551;
            FSUIPCConnection.Process("SendControl");
 
            // Press FS ACTIONS> LSK5R
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 544;
            FSUIPCConnection.Process("SendControl");
 
            // Press <FUEL LSK1L
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 534;
            FSUIPCConnection.Process("SendControl");
 
            // Press digit 3
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 563;
            FSUIPCConnection.Process("SendControl");
 
            // Press digit 4
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 564;
            FSUIPCConnection.Process("SendControl");
 
            // Press digit 5
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 565;
            FSUIPCConnection.Process("SendControl");
 
            // Press digit 6
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 566;
            FSUIPCConnection.Process("SendControl");
 
            ps.WriteChanges();
            ps.RefreshData();
        }
    }
}
Link to comment
Share on other sites

Thanks very much for the donation, it's much appreciated.

 

I can't see anything wrong with your code. I can't test it properly because I don't have the PMDG 737.

 

I've tested sending a normal 'fsx' control (parking brakes toggle) and it's working okay. Maybe you can adding this to the end of your controls and see if this one reacts.

           sendControl.Value = 65752; // parking brakes
            FSUIPCConnection.Process("SendControl");

If this doesn't work on the 737NGX then try on a stock FS aircraft, just to prove the code/dll/fsuipc is working okay.

 

If it's just the 737NGX CDU events that aren't working, try enabling the event (non axis) logging in FSUIPC. You can show the log in a separate console window to get real time feedback. Then press the buttons on the CDU and see what events are being triggered. Make sure they are the ones you are expecting. You can also run your code and compare the events fired manually with the ones your code it firing.

 

Paul

Link to comment
Share on other sites

The code to toggle the parking brakes works fine on the PMDG 737NGX. I can set and release them OK.

 

Here is the events log from running my code as shown above:

 

   968579 *** EVENT: Cntrl= 70183 (0x00011227), Param= 0 (0x00000000)  <70183> MENU Button
   968579 *** EVENT: Cntrl= 70176 (0x00011220), Param= 0 (0x00000000)  <70176> FS ACTIONS LSK
   968579 *** EVENT: Cntrl= 70166 (0x00011216), Param= 0 (0x00000000)  <70166> FUEL LSK
   968579 *** EVENT: Cntrl= 70195 (0x00011233), Param= 0 (0x00000000)  <70195> 3 digit
   968579 *** EVENT: Cntrl= 70196 (0x00011234), Param= 0 (0x00000000)  <70196> 4 digit
   968579 *** EVENT: Cntrl= 70197 (0x00011235), Param= 0 (0x00000000)  <70197> 5 digit
   968579 *** EVENT: Cntrl= 70198 (0x00011236), Param= 0 (0x00000000)  <70198> 6 digit
   968595 *** EVENT: Cntrl= 65752 (0x000100d8), Param= 0 (0x00000000) PARKING_BRAKES
 
I'm not sure what debug checkboxes I should check in FSUIPC to be more helpful?
 
UPDATE: I'm missing the last key stroke, a LSK 5L to put the digits into tank 2. Let me try that.
 
That didn't help any:
            // Press LSK5L to send fuel load to tank 2
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 538;
            FSUIPCConnection.Process("SendControl");
 
Here I'm just pressing the MENU button on the left CDU...70183 is the correct number (69632+551). The CDU was on the LEGS page and did not change to the MENU page. The brakes of course toggled correctly.
 
  2119648 *** EVENT: Cntrl= 70183 (0x00011227), Param= 0 (0x00000000)  <70183> MENU Button press only
  2119648 *** EVENT: Cntrl= 65752 (0x000100d8), Param= 0 (0x00000000) PARKING_BRAKES
 
Link to comment
Share on other sites

I don't have the PMDG aircraft or else I maybe could help. I can only suggest you ask in the PMDG support forum. It is there SDK and their set of custom controls.

 

It may well be simply that you need to have the proper parameter value. Maybe there's one parameter for "press" and another for "release". I know many of their commands are more based on mousae operations than keyboard, so maybe the mouse-type parameters are needed, the "click" and "unclick" flags.

 

Pete

Link to comment
Share on other sites

Mabye thats the problem...I need to be using mouse clicks instead of key presses...I see if I can do that...thanks...

 

Update:

 

From the FSUIPC debugger I can see that

#define MOUSE_FLAG_LEFTSINGLE    0x20000000

 

0x20000000 is the left mouse click event being fired.

 

But how does one use that in this:

            // Press MENU button

            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 551;
            FSUIPCConnection.Process("SendControl");
 
This tells FSUIPC which button (Menu) to press but how to tell it by the mouse click?
 
Perhaps in the definition of the offset?
private Offset<int> sendControl = new Offset<int>("SendControl", 0x3110, true);
 
Thanks...
Link to comment
Share on other sites

Hi Ralph,

 

Here is the updated version of the DLL (Version 3.0 beta) containing the sub menu functionality.

 

To update, either overwrite your existing DLL and XML file with the new ones, or you can put them in a new folder and redo the reference in the C# project.

 

The sub menu functionality is the same as the main menu except you have to specify the parent menu:

 

Here's some sample code which should be self-explanatory. In all other respects (e.g. responding to the user clicking them) the sub menus are exactly the same as the normal menu. I refer you back to the main 2.4 thread.

            ui = FSUIPCConnection.UserInputServices;
            // Add our main menu items
            // The first parameter is the key and can be whatever you want.
            // Second is the text to display
            // Third is whether to pause FS on selection
            ui.AddMenuItem("MenuA", "Menu A", false);
            ui.AddMenuItem("MenuB", "Menu B", false);
            ui.AddMenuItem("MenuC", "Menu C", false);
            // Adding sub menus to menu B
            // First is the ID of this sub menu
            // Second is the ID of the parent menu
            // Third is the test to display
            ui.AddSubMenuItem("SubMenuB1", "MenuB", "Sub B1");
            ui.AddSubMenuItem("SubMenuB2", "MenuB", "Sub B2");
            

As an aside, I've improved the way the payload stations and fuel tanks work as you can now hold on to a reference to a particular tank or payload station between calls to RefreshData(). Before it was recreating new tank and payload objects forcing users to get new copies from PayloadServices after RefreshData(). It is still the case that you need to call RefreshData() at least once before any fuel tanks are available. I couldn't see an elegant way around that.

 

Paul

FSUIPCClient3.0_BETA.zip

Link to comment
Share on other sites

 

From the FSUIPC debugger I can see that

#define MOUSE_FLAG_LEFTSINGLE    0x20000000

 

0x20000000 is the left mouse click event being fired.

 

But how does one use that in this:

            // Press MENU button

            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 551;
            FSUIPCConnection.Process("SendControl");
 

 

I've really no idea how you would use the mouse flags.

 

Controls do have parameters, so my first thought was that the mouse flags could be send as the parameter to the control. However, looking at your log from FSUIPC it clearly shows the menu control being sent by PMDG without any parameter (it's 0).

 

2119648 *** EVENT: Cntrl= 70183 (0x00011227), Param= 0 (0x00000000)  <70183> MENU Button press only

 

 

If you want to try sending the mouse flag you can but I don't have much expectation that it will work:

To do this you need another offset. This one MUST be declared before the sendControl offset, or it won't work properly (you can set the values in any order you like).

// Order is important!
private Offset<int> controlParameter = new Offset<int>("SendControl", 0x3114, true); // Both in the SendControl group, not a typo!
private Offset<int> sendControl = new Offset<int>("SendControl", 0x3110, true);
private readonly int MOUSE_FLAG_LEFTSINGLE  = 0x20000000;
            // Press MENU button            
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 551;
            controlParameter.Value = MOUSE_FLAG_LEFTSINGLE;
            FSUIPCConnection.Process("SendControl");
If that doesn't work then you really need to ask PMDG directly or on their support forums how these CDU controls are meant to be used.
 
Paul
Link to comment
Share on other sites

I've reread your post where you did the logging. I think I misread it earlier. It seems to me now that line I quoted was not sent by PMDG but by your code.

 

What you need to do is turn on the event logging in FSUIPC and press the keys on the CDU with your mouse and see what controls and parameters PMDG is sending. That will help us replicate the correct messages.

 

Paul

Link to comment
Share on other sites

Here is the event logging when I mouse click on the left CDU MENU button:

   103304 *** EVENT: Cntrl= 70183 (0x00011227), Param= 536870912 (0x20000000)  <70183>
   103382 *** EVENT: Cntrl= 70183 (0x00011227), Param= 131072 (0x00020000)  <70183>
 
One must be mouse down and the other mouse up?
 
These are clicking on the FS ACTIONS LSK5R
   329786 *** EVENT: Cntrl= 70176 (0x00011220), Param= 536870912 (0x20000000)  <70176>
      329958 *** EVENT: Cntrl= 70176 (0x00011220), Param= 131072 (0x00020000)  <70176>
 
Link to comment
Share on other sites

It worked!! This put 3456 pounds of fuel in the center tank, via the left side CDU!!

Thanks so much Paul and Pete for you help on this issue!

 

            // Press MENU button            
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 551;
            controlParameter.Value = MOUSE_FLAG_LEFTSINGLE;
            FSUIPCConnection.Process("SendControl");
            // Press FS ACTIONS> LSK5R
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 544;
            controlParameter.Value = MOUSE_FLAG_LEFTSINGLE;
            FSUIPCConnection.Process("SendControl");
 
            // Press <FUEL LSK1L
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 534;
            controlParameter.Value = MOUSE_FLAG_LEFTSINGLE;
            FSUIPCConnection.Process("SendControl");
 
            // Press digit 3
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 563;
            controlParameter.Value = MOUSE_FLAG_LEFTSINGLE;
            FSUIPCConnection.Process("SendControl");
 
            // Press digit 4
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 564;
            controlParameter.Value = MOUSE_FLAG_LEFTSINGLE;
            FSUIPCConnection.Process("SendControl");
 
            // Press digit 5
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 565;
            controlParameter.Value = MOUSE_FLAG_LEFTSINGLE;
            FSUIPCConnection.Process("SendControl");
            // Press digit 6
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 566;
            controlParameter.Value = MOUSE_FLAG_LEFTSINGLE;
            FSUIPCConnection.Process("SendControl");
 
            // Press LSK5L to send fuel load to tank 2
            sendControl.Value = THIRD_PARTY_EVENT_ID_MIN + 538;
            controlParameter.Value = MOUSE_FLAG_LEFTSINGLE;
            FSUIPCConnection.Process("SendControl");
 
Link to comment
Share on other sites

Ralph, excuse me from being off-topic here, but I've been viewing your excellent video tutorials, I've got through to the MCP ones on VNAV, and I'm having a discussion on ALT INTV with the author of ProSim737 (the cockpit system I use), because he thinks it is different to what you say.

 

Do you think you could contact me on petedowson@btconnect.com, please, so we could discuss this? I'd like to understand fully.

 

Best Regards

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.