Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,728
  • Joined

  • Days Won

    78

Everything posted by Paul Henty

  1. I'm not sure what you're trying to do with this. Do you want to detect joystick button presses in your C# application? If so, the UserInputServices deals with those too: This will detect button 1 of Joystick number 0 being pressed from Off to On. I'm pretty sure these joystick and button numbers will match up with those shown in the buttons assignment tab of FSUIPC. ui.AddJoystickButtonPress("Joy1", 0, 1, StateChange.Off_On); ui.ButtonPressed += new EventHandler<UserInputButtonEventArgs>(ui_ButtonPressed); The event hander: private void ui_ButtonPressed(object sender, UserInputButtonEventArgs e) { MessageBox.Show("Joytick Button Pressed " + e.ID); } If you're trying to do something else can you explain some more? Paul
  2. The easiest way would be to use the new beta version of the DLL as it has a feature to send controls directly to FS. I've attached it here. Just overwrite your current DLL and XML file with the new ones. To send a control call: FSUIPCConnection.SendControlToFs(ControlNumber, ParameterValue); This just sends the control immediately (no need for a Process() call). There are also overloads that take an Enum instead of the raw control number. For your request to reload the aircraft you would use: FSUIPCConnection.SendControlToFS(FsControl.RELOAD_USER_AIRCRAFT, 0); (A parameter is not required for this control so it's just set to 0). Enums available are: FsControl - the normal FSX/P3D list of controls FSUIPCControl - Additional controls added by FSUIPC FSUIPCAxesControl - Used to control axed assign directly in FSUIPC FSUIPCAutoPilotControl PMControl - Controls for Project Magenta software PMDG_737_NGX_Control - Controls defined in the PMDG 737 NGX SDK Paul FSUIPCClient3.0_BETA.zip
  3. I don't see any problems here with the shift modifier. Also tested under WideFS. Here is the code I used to add Shift-1, Ctrl-1 and Ctrl-Shift-1. All are detected as expected. ui.AddKeyPresss("Shift1", FSUIPC.ModifierKeys.Shift, Keys.D1, false); // Shift-1 ui.AddKeyPresss("Ctrl1", FSUIPC.ModifierKeys.Ctrl, Keys.D1, false); // Ctrl-1 ui.AddKeyPresss("CtrlShift1", FSUIPC.ModifierKeys.Shift | FSUIPC.ModifierKeys.Ctrl, Keys.D1, false); // Ctrl-Shift-1 The shift modifier value for this feature in FSUIPC is 1, not 4. I've rechecked all the values for the FSUIPC.ModifierKeys enum against the docs and they are correct. You don't really need to do this if you use 'false' as the last parameter when registering the key. This prevents the key from being passed onto FSX once FSUIPC has trapped it. You could try with a default aircraft loaded or try some other shift combination keys that are not numbers. Maybe one of your add-ons is getting to the shift-n keys first. Paul
  4. I wonder if Visual Studio hasn't recognised the latest DLL is new since it was built on the same day as the previous version. Can you try going to your bin\debug folder and deleting the FSUIPCClient.dll file. VS will then be forced to copy the new one in and use that. If that doesn't work, you could try removing the reference to the DLL and putting it back in. Otherwise I'll have a look tomorrow. Paul
  5. Yeah, there were some internal tables that were not getting cleared. Fix attached. Paul FSUIPCClient3.0_BETA.zip
  6. >> So, I'm thinking I should be able to re-connect and re-build the addmenuitems and addkeypresss...yes? Yes, sounds like something isn't getting cleared properly. I'll have a look this evening. Paul
  7. Seems to be sorted now. It was just a timing issue with WideFS. Everything was fine locally, but the DLL wasn't leaving enough time for the network roundtrip when running remotely. New version attached. Also added are two new methods: 1. FSUIPCConnection.SendControlToFs(ControlNumber, ParameterValue); This just sends the control immediately (no need for a Process() call) and just saves a bit of typing. What might be helpful is that there are overloads that take an Enum instead of the raw control number. For example: FSUIPCConnection.SendControlToFS(FsControl.PARKING_BRAKES, 0); will toggle the parking brake. A parameter is not required for this control so it's just set to 0. Enums available are: FsControl - the normal FSX/P3D list of controls FSUIPCControl - Additional controls added by FSUIPC FSUIPCAxesControl - Used to control axed assign directly in FSUIPC FSUIPCAutoPilotControl PMControl - Controls for Project Magenta software PMDG_737_NGX_Control - Controls defined in the PMDG 737 NGX SDK 2. FSUIPCConnection.SendKeyToFS(Key, Modifier, ReturnFocusToForm); This sends a key stroke to the FS window. The Modifier and ReturnFocusToForm are optional. e.g. This sends Control-L and return focus back to the application form: FSUIPCConnection.SendKeyToFS(Keys.L, SendModifierKeys.Control, this); This is also instant (no need to Process()) and also sets the focus to the FSX window automatically. Both work over WideFS. Paul FSUIPCClient3.0_BETA.zip
  8. Okay - I'll check that too. Yes, the event should just fire once per key press and you check the ID. I'll fix this as well. You must be the first person to use these User Input facilities. They have been there for about three years but are clearly a bit broken. I'll likely have a new version tomorrow. Paul
  9. Ah, I'm managed to reproduce this. It only happens if you add the keys before the menus. There's obviously a bug in my DLL and the menus are trampling over the key presses. Sorry this has taken so long to get the bottom of. I'll get it fixed as soon as I can. In the mean time registering the buttons after the menus in your program might make it work properly. Paul
  10. Hi Ralph, On the WideClient machine you can run your program and it will add items to the FSX menu, on the FSX machine. When you select these menus from within FSX your program on the WideClient PC will respond just the same as it does when running locally. Whether this is useful or not is dependent on the application I guess, but I'm just trying to see if the menus work remotely as menus use the same signalling system used by the Key presses we're trying to get to work. I've managed to set up a WideFS setup here and the code in #7 works fine locally or on my WideClient machine. Do you have two programs running at the same time? One on the FSX PC and one on the WideClient pc? The code in #7 must be placed in the program running on the WideClient pc. Paul
  11. Ralph, All you should need is the code I posted in #7 above. In the background this is using the 0x3210 hotkey facilities. As you've seen this works fine when you're running your app on the same machine as FSX: Now Pete has confirmed this should also work on the WideClient pc we just need to work out why it doesn't. I think this will be easier than getting SendKeys to work and overall a cleaner way of handling this. Can you confirm that you're using exactly the same .exe to test on both PC's? Do your FSX menu additions work on the WideClient pc? Paul
  12. If you mean sinking the KeyPress event on the Form then yes. You will need to set the KeyPreview property of the form to 'true' as well. However, from reading the WideFS documentation you'll need to add information to the KeySend definition in the ini file to direct the key press to the correct window (i.e. your application). I should say that I believe Pete has misunderstood what you want to do. I don't think he realised that your application is already communicating with FSUIPC and reading offsets etc. From his last reply to me it's clear that the FSUIPC HotKeys facility at 0x3210 (UserInputServices in my DLL) should work fine across WideFS. In my opinion this is a far better solution than having to configure keys and ini settings on the FSX PC and then trap the resulting real key presses on the Client PC in a .NET form. Paul
  13. Hi Pete, Thanks for chipping in again. Unfortunately I've steered Ralph down the wrong path again as I've misunderstood things. The documentation for the HotKeys feature at 0x3210 says: "This system will work through WideFS with no problems too.". If it doesn't trap the key on the FSX PC and mark byte 3 of the key slot as pressed so the clients can see it, how does it work through WideFS? Thanks, Paul
  14. Hi Ralph, The key is not set up in the FSUIPC interface. Your application registers the key with FSUIPC and will be notified when it's pressed by the user on the FSX machine. This is a feature of the UserInputServices which you've used to create your menus and works in a very similar way. The following code shows registering ctrl-1 and sinking the KeyPressed event so you know when one of your keys is pressed. You then get the ID from the EventArgs to see which one. As you already have menus working I've left out the code to set-up a timer to do the CheckForInput() as you'll already have that. This is just the additional code you need. 1. Register the key press and sink the event UserInputServices ui = FSUIPCConnection.UserInputServices; ui.AddKeyPresss("Button1", FSUIPC.ModifierKeys.Ctrl, Keys.D1, false); // Three s's - typo in my dll. // Register more keys here. ui.KeyPressed += new EventHandler<UserInputKeyEventArgs>(ui_KeyPressed); 2. The event handler private void ui_KeyPressed(object sender, UserInputKeyEventArgs e) { MessageBox.Show("Pressed " + e.ID); } Paul
  15. There's nothing you need to do differently. WideClient is designed to be exactly like having the flight sim on the local PC. Which error message are you getting? Paul
  16. Just once when you start the application; it will be valid for as long as FSX is running. There's no point in repeatedly opening and closing the connection. You should have the Process() calls (and similar calls on the special services classes like PayloadServices.RefreshData()) in Try-Catch blocks so you can detect if the connection is ever lost. Then your application can close() the now broken one and then attempt to open() a new one. Paul
  17. Ralph, Since Pete has pointed out an easy way to give focus to FSX, sending alt-enter now becomes fairly simple. The code is below. I will still add a feature to the DLL to make sending key strokes a bit easier and less verbose. Declarations: private Offset<int> controlParameter = new Offset<int>("SendControl", 0x3114, true); private Offset<int> sendControl = new Offset<int>("SendControl", 0x3110, true); private readonly int KEY_PRESS_RELEASE = 1070; private readonly int KEY_FOCUS_RESTORE = 1125; Main Code: // Set FSX as active window sendControl.Value = KEY_FOCUS_RESTORE; FSUIPCConnection.Process("SendControl"); // Send alt-enter sendControl.Value = KEY_PRESS_RELEASE; controlParameter.Value = (int)(Keys.Enter) + (256 * 16); FSUIPCConnection.Process("SendControl"); Paul
  18. Thanks Pete. That's much simpler than calling into the Win32 API. Paul
  19. Yes that's useful. Thanks. Paul
  20. Hi - The key press control only sends the keys to the active window so it's not as simple as it first looked. Switching focus to FSX is fairly complicated in C# so I'll have a look at building a keysend facility into the DLL this week. Paul
  21. Hi Pete, I misunderstood then. I thought this would send the keypress to the FSX window as the name suggests as opposed to the active window. My C# program has the focus and that's trying to send a key press through to FSX. I'll have to give focus to the FSX window first. Thanks, Paul
  22. Since this offset is only 2 bytes long you should declare the offset as a shot integer like this: private Offset<short> ENG1 = new Offset<short>(0x088C); The value you write in the offset doesn't determine its size in bytes. A 0 stored in an 'int' is still 4 bytes long. Declaring the correct variable type for each offset is very important. My UserGuide.pdf (located in the 'Docs' folder of the FSUIPCClient DLL Zip file) has a table on page 7 explaining what C# types to use given the size of the offset. Paul
  23. I'm only using the L key as a basic test to prove the concept of sending key presses to FSX via the documented control. I'm not really asking about lights. Paul
  24. Okay - I'm looking into sending the key press but I can't get the key send control to work at the moment. I've asked Pete for some help so bear with me. The full list of FSX/P3D controls is under your main FSX folder in the "Modules\FSUIPC Documents" folder. It's called "List of FSX and P3D controls,pdf". In addition FSUIPC also has it's own set of controls listed in "FSUIPC4 for Advanced Users.pdf". (same folder). Paul
  25. Hi Pete, I'm trying to send key presses to FSX using the 1070 control sent via offset 0x3110. (FSUIPC Version 4.938f). In my test I'm using the 'L' key to toggle the lights. According to the logging the key seems to be getting through and is sent, but the lights do not toggle. Here's me pressing 'L' on the keyboard: - the lights get toggled. 2202204 KEYDOWN: VK=76, Waiting=0, Repeat=N, Shifts=0 2202204 .. Key not programmed -- passed on to FS 2202204 *** EVENT: Cntrl= 65574 (0x00010026), Param= 0 (0x00000000) ALL_LIGHTS_TOGGLE 2202266 KEYUP: VK=76, Waiting=0 This is my program sending the 1070 control via 3110. All seems okay and the log is reporting the [L] key press being made, but the lights control is not triggered. 2205360 WRITE repeated 1 times 2205360 WRITE0[2788] 3114, 4 bytes: 4C 00 00 00 L... 2205360 WRITE0[2788] 3110, 4 bytes: 2E 04 00 00 .... 2205360 FSUIPC Control Action: Ctrl=1070, Param=76 2205360 SendKeyToFS(0000004C=[L], KEYDOWN) ctr=0 2205360 Sending WM_KEYDOWN, Key=76 (Scan code 38), Ctr=1 2205500 SendKeyToFS(0000004C=[L], KEYUP) ctr=0 2205500 Sending WM_KEYUP, Key=76 (Scan code 38), Ctr=1 Have I got something wrong here or have I misunderstood what 1070 is meant to do? Thanks, 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.