Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,644
  • Joined

  • Days Won

    74

Everything posted by Paul Henty

  1. Hi, The PMDG_737_NGX_Control enum will not work with the MSFS PMDG aircraft. It was written for the FSX and P3D aircraft. PMDG changed the way they handle controls in the new MSFS aircraft. Everything gets sent as a parameter to the built-in ROTOR BRAKE control. As far as I know they have not finalised the SDK for the MSFS version. When they do I can build helpers into my DLL. Until then you can use this conversion code below to convert the old P3D control numbers into the new Rotor Brake parameters: public enum PMDGMouseCode { LeftClick = 1, RightClick = 2, MouseMove = 3, LeftRelease = 4, RightRelease = 5, MiddleClick = 6, WheelUp = 7, WheelDown = 8 } private void sendPMDGControl(PMDG_737_NGX_Control control, PMDGMouseCode mouseCode) { // Convert P3D control to MSFS equivalent int msfsControl = (((int)control - (int)PMDG_737_NGX_Control.THIRD_PARTY_EVENT_ID_MIN) * 100) + (int)mouseCode; // Send converted control via RotorBrake FSUIPCConnection.SendControlToFS(FsControl.ROTOR_BRAKE, msfsControl); } E.g. Then you can send your control like this: sendPMDGControl(PMDG_737_NGX_Control.EVT_MCP_HDG_SEL_SWITCH, PMDGMouseCode.LeftClick); As for the PMDG offsets, you will need to ask @John Dowsonabout that. Usually the problem is that you haven't enabled the SDK broadcast in the PMDG .ini file. Paul
  2. Yes; the short explanation is: Create two FsLatLonPoint objects. The constructor takes the Lat/Lon in decimal degrees or FsLat/FsLon objects. Then with one of the objects you can call DistanceFromInFeet(), or DistanceFromInMetres() and pass the other FsLatLonPoint object. For more details about this and other Lat/Lon helpers see the example code application, specifically the section called "Lon/Lat Helper Classes". The distance example is on the form called LL002_DistancesAndBearings. Paul
  3. Yes, like this: List<string> AllLVarNames = MSFSVariableServices.LVars.Names; Paul
  4. Only if your encoders can be seen by FSUIPC as joystick button presses. This will depend on the drivers\software you use to read the encoders. Some encoders can be set up to simulate a joystick button press when they are rotated left, and another button when rotated right. Sometimes you will get two buttons for each direction, one for a slow turn and one for a fast turn. In this case you just use the encoders as if they were joystick buttons in FSUIPC, using the method described above. If your encoders cannot be set up like this then you won't be able to use the switches/buttons method described above. You will need to use different software to read the encoders and send the controls directly to FSUIPC. What that software is will depend on the specific hardware you are using. Paul
  5. NOTE: This guide references an out-dated method for controlling the PMDG aircraft in MSFS. While it might still work, a better method is explained in this linked FAQ: Background PMDG Aircraft for MSFS do not use the normal controls provided by the flight sim. This means that many of the aircraft's switches cannot be assigned to buttons and keys using the list of controls in the FSUIPC dropdown boxes. Assigning a standard control in FSUIPC will likely do nothing in the PMDG aircraft when the button or key is pressed. Solution Instead of using the standard list of controls shown in the FSUIPC dropdown box, users must send codes as a parameter to the standard MSFS 'Rotor Brake' control. The parameter code specifies which switch to operate and what type of mouse click to simulate. The control numbers vary for each aircraft and are listed in the SDK that is installed alongside the aircraft. This guide will show you, step-by-step: How to find the SDK files How to calculate the 'Rotor Brake' parameter codes How to assign the code to buttons/keys in FSUIPC The specific examples shown will be taken from the PMDG 737-700, but the same method works for any PMDG aircraft with an SDK. 1. Locating the SDK From your main Flight Sim install folder, open the PMDG folder. Then select the folder belonging to the aircraft you want to use. e.g. PMDG 737 NGXu Then select the SDK folder Locate the file with the .h extension. For the 737 it's called PMDG_NG3_SDK.h You can open this file with Notepad or your favourite text editor. As an example, the document you need for the 737 will be: [FlightSimInstallFolder]\PMDG\PMDG 737 NGXu\SDK\PMDG_NG3_SDK.h 2. Calculating the 'Rotor Brake' Parameter Code 2.1. Find the control you want to use. Search for the control by name, or look through the listed controls to find the one you want. They are helpfully grouped together by panel. The controls are listed under a comment: // Control Events You can search for this to find where the list of control numbers starts. As an example we'll use the "Autopilot CMD A" switch on the MCP. This is the relevant line in the 737 SDK: #define EVT_MCP_CMD_A_SWITCH (THIRD_PARTY_EVENT_ID_MIN + 402) To calculate the control number for this switch we ignore THIRD_PARTY_EVENT_ID_MIN and take the number after it. In this case 402. NOTE: Some controls reference other controls. For example: #define EVT_EFB_L_BACK (EVT_EFB_L_START + 1) For this you need to find the value of EVT_EFB_L_START and add 1. Searching for EVT_EFB_L_START we find this: #define EVT_EFB_L_START (THIRD_PARTY_EVENT_ID_MIN + 1700) As before, THIRD_PARTY_EVENT_ID_MIN is always ignored. So we get the value of 1700. Adding 1 to this will give us the value for EVT_EFB_L_BACK. Therefore EVT_EFB_L_BACK would be 1700 + 1 = 1701. We have now calculated the control number. 2.2. Adding the Mouse Action Code You now need to add a number to tell the aircraft what kind of mouse interaction you want to simulate. (e.g. left click, right click, scroll wheel up). First multiply the control number you have so far by 100. In our example for EVT_MCP_CMD_A_SWITCH we get: 402 * 100 = 40200 Now you ADD the following number, depending on the mouse operation you want: 1 for left mouse click 2 for right mouse click 3 for mouse move 4 for left mouse button release 5 for right mouse button release 6 for middle mouse button click 7 for mouse wheel up 8 for mouse wheel down For our example, we'll have our key assignment simulate the left mouse button clicking on the CMD A autopilot button. So we'll need to add 1: 40200 + 1 = 40201 Now we have the final code number. 3. Assigning the control to a button or key in FSUIPC Select [Assignments] -> [buttons + switches] or [key presses] in the FSUIPC7 menu. Then select the button or key to program. From the "control sent..." dropdown select Rotor Brake In the Parameter field below type in your calculated code number from the previous step. For our 'Autopilot CMD A' example, we enter 40201 If you're programming a key press, remember to press the [confirm] button. Here is our example control assigned to a button in FSUIPC: Your button or key press should now operate the switch in your PMDG aircraft.
  6. Yes, you can use them. At the moment you will need to declare them as normal offsets with the correct type. The PMDG_737_NGX_Offsets helper class will not work because the offset addresses have changed. I will eventually add a new helper class for this aircraft after John releases the official FSUIPC version that includes these offsets. Paul
  7. It's difficult to know where the problem is with the WASM module as there are many interacting parts. Please try the following to narrow it down: Instead of my example application, use John's WASMClien.exe program from the FSUIPC-WASMv0.5.9a.zip file. It's in the \WASMClient folder. If John's client doesn't work on your user's machine then you'll need to ask John about this. This program generates a log which John can look at. If John's client does work then it's something in my DLL. Try turning the log level to _DEBUG in my sample application source code. Recompile and run it again to see if the extra logging provides any useful information. Paul
  8. Can you explain what these means please? I'm wondering if I need to update my post about programming events for the PMDG aircraft. Is the process different in MSFS? I've found some other posts on this. I think I've figured it out. Paul
  9. There's not much - just what's on the intellisense. The default is LOG_LEVEL_INFO which won't give you errors. To see errors, try LOG_LEVEL_DEBUG first which will probably be sufficient. Failing that, you can try with the highest (LOG_LEVEL_TRACE) but that's very verbose. Paul
  10. When using MSFSVariableServices you should normally leave the LVARUpdateFrequency property set to 0. This is the default from version 3.2.20, so make sure you're not overriding it in your code. My DLL does not create a log file for the WAPI. It's up to the user to do that by setting the LogLevel property and handling the OnLogEntryReceived event. This is automatically handled inside my DLL. The user doesn't directly interact with the events from the WAPI dll. Paul
  11. Yes. You can pass the handle of your application's form (e.g. this.Handle). The sim will still be given focus, but after the key is sent the focus will be returned to your form. FSUIPCConnection.SendKeyToFS(Keys.F12, SendModifierKeys.Control); // Flight Sim keeps focus FSUIPCConnection.SendKeyToFS(Keys.F12, SendModifierKeys.Control, this.Handle); // focus returns to this form Paul
  12. The handle you pass to SendKeyToFS is for the window you want to return focus to, after the key has been sent. It's not the MSFS window handle. Paul
  13. The only things I can think of to check is: Make sure your .NET program is running as 64bit. Make sure you're running your program at the same privilege level as MSFS. Either both 'As Administrator' or both not as administrator. Try sending keys to another application like Notepad.exe to check the code. If it still doesn't work then maybe MSFS is not processing these kinds of messages. Paul
  14. You'll need to ask John about this in the FSUIPC 7 sub forum. Paul
  15. Yes you can try PostMessage then. (I wrongly called it SendMessage in the last post): I can't try it on MSFS as I don't have it, but it works with FS9. The following example is setting the pause function without giving focus to the Sim: First declare the PostMessage call and the KeyDown code: const UInt32 WM_KEYDOWN = 0x0100; [DllImport("user32.dll")] static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam); This call requires the handle of the main window of the flight sim. You can get this from the process name. I don't know what the process name is for MSFS, you'll need to find out with a tool like Spy++ while MSFS is running. (Visual Studio -> TOOLS menu -> Spy++ -> Spy Menu -> Processes). using System.Diagnostics; IntPtr wHnd = IntPtr.Zero; // Handle to main FS window string simProcessName = "FS9"; // Example for Flight Sim 2004 Process[] procs = Process.GetProcessesByName(simProcessName); if (procs.Length>0) { wHnd = procs[0].MainWindowHandle; // Used later in PostMessage } else { // Flight sim not loaded } Now you just need to call PostMessage to send the key presses: // Send P key to FS to pause/unpause PostMessage(wHnd, WM_KEYDOWN, (int)Keys.P, 0); Paul
  16. There isn't because of the way Windows works. The Win32 API that send key press messages (SendInput) assumes that the application has focus. It's possible to send a KeyDown/KeyUp message to a window that doesn't have focus (using PostMessage), but this doesn't support modifier keys. If you want to control the sim without shifting the focus you need to use another method like Offsets, Controls (Event) or LVars. If these are not available, and your only choice is keyboard presses, then you're just stuck with having to give focus to the sim. Paul
  17. I've just released a helper DLL on NuGet called FSUIPCWebSocketClientDLL. This makes it easier for .NET applications to talk to my FSUIPCWebSocket server. This server is installed with FSUIPC7 but can be used with any version from FSUIPC3 onwards. The server runs on the Flight Sim computer and allows offsets, LVars and HVars to be read and written over a TCP/IP connection (even over the internet if your Flight Sim PC is accessible from the internet). It was written to allow Web Browser/JavaScript applications to use FSUIPC, but it can be used by any language that can use WebSockets and read/write JSON data structures. The new DLL makes this easy in .NET by handling the WebSocket/JSON transfers for you. The DLL targets .NET Standard 2.0 so it's possible to use this DLL with any operating systems than supports .NET Standard 2.0. If your application is only for Windows and you don't need access to FSUIPC across a network or the internet, or you are using WideClient.exe then the current FSUIPCClientDLL offers a much more comprehensive, feature-rich and streamlined way of writing .NET applications for FSUIPC. Everything you need to know about the WebSocket server and the .NET Client is on the website: http://fsuipcwebsockets.paulhenty.com Paul
  18. All done. You'll need the latest WebSocket server (V1.0.0): http://fsuipcwebsockets.paulhenty.com/ There is a new section on that website for my new WebSockets .NET Client. This gives you all the details on how to use it. The NuGet package is called FSUIPCWebSocketsClientDLL. There is example code on the website, embedded in the main documentation in JavaScript, C# and VB.NET. There are also separate example code applications (C# and VB) that you can download from the section called "Example Code Projects" under ".NET Client". If the WebSocket server is connected to FSUIPC7 it will use the new WASM module to get LVARs. If it's anything earlier than 7 it will fall back to the legacy LVar access like FSUIPCConnection.ReadLVar() in the FSUIPCClientDLL. You'll notice that the websocket server also allows for reading/writing offsets. You can of course still use the FSUIPCClientDLL for offsets, and just use the WebSocket server for LVars if you want. If you have any questions or problem, please start new threads on this sub-forum. Paul
  19. New version of the WebSocket server just released (V1.0.0.) This is using FSUIPC_WAPID.DLL version 0.5.10. http://fsuipcwebsockets.paulhenty.com/ Paul
  20. I think this changed at some point. My understanding is that it's no longer needed if the interval is specified in the WASM configuration (which is the default now). At some point I will change this in the DLL and the docs, but at the moment you should just set the the LVARUpdateFrequency property to 0, before you call Start(). Paul
  21. Okay, thanks for letting me know. I'm doing some work on the socket server at the moment, so I'll get this worked out for the next release in a week or so. Paul
  22. Me too. What about with programming it on a button with the FSUIPC interface? Paul
  23. Are they working with SPAD on your machine? What about via the Joystick/Keyboard assignments in FSUIPC itself? Paul
  24. That looks okay. The mouse flag also look correct according to the PMDG_NG3_SDK.h file. Have you tried programming a joystick button or key press for any PMDG controls in the FSUIPC interface? If it doesn't work there either, and if normal flight sim control work (e.g. pause), then it's probably a question for PMDG support. Yes Paul
×
×
  • 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.