Jump to content
The simFlight Network Forums

FSUIPCConnection.Open() Calls


rfresh

Recommended Posts

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

Link to comment
Share on other sites

Thanks Paul...excellent updates.

 

1. The hot key keypress multiple assignments are now working properly...they are firing one at a time.

 

2. The ui.RemoveAll() now removes all the menu items, however, when I try to add them back, I get a catch err msg: "An item with the same key has already been added".

 

My app has a menu item to connect to FSUIPC and uses a checkmark next to it when it is connected. When I select that menu item again, the checkmark toggles off and I do this:

 

ui.RemoveAll();

FSUIPCConnection.Close();

 

So, I'm thinking I should be able to re-connect and re-build the addmenuitems and addkeypresss...yes?

Link to comment
Share on other sites

Hi Paul

 

The ui.RemoveAll() now removes all (gone from the FSX Add-On menu) but when I try to re-connect and build the menus again I still get the same error message:

 

"An item with the same key has already been added".

 

I'm sorry for the trouble.

 

Edit:

 

I had a general question about these hot keys. I see that when I set a Shift-3 key combination when I'm running my CaptainSim 777, that Shift-3 is 'seen' by CS777 and displays a panel. So, my question is: is there any way to pass these keys in such a way that FSX doesn't 'see' them?

 

I notice there are not a lot of available key combinations in FSX (I down loaded a sheet listing all the default keys in FSX). I was using an obscure key combination that normally plays the marker beacon sound, thinking I could 'over ride'  that and not miss it, but the sound still played when I pressed that key combination.

 

Thanks...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

You're right...that fixed it...thanks a lot...

 

Update:

 

I went into FSX and removed all the Shift key combinations so I could use them.

 

I set 4 Shift key combinations in my app:

 

Shift-1

Shift-2

Shift-3

Shift-4

 

But I get no reaction in my app when I press any of these 4 Shift key combinations.

 

If I set:

 

Control-1

Control-2

Control-3

Control-4

 

these all work fine and as expected.

 

I also get no reaction to Control-Shift-1 2 3 and 4.

 

I hard coded shift-0 and it didn't work:

ui.AddKeyPresss("Menu", (FSUIPC.ModifierKeys)4, (Keys)48, false); // shift-0

 

Do you think something might be wrong with detecting the Shift Modifier key?

Link to comment
Share on other sites

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

 

ui.AddKeyPresss("Menu", (FSUIPC.ModifierKeys)4, (Keys)48, false); // shift-0

 

 

 

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.

 

I went into FSX and removed all the Shift key combinations so I could use them

 

 

 

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

Link to comment
Share on other sites

Pete/Paul

 

I went into the FSUIPC dialog and set a button press on my joy stick with a parameter of 101 (and selected the KEYPRESS WideFS (0-255) in the drop down list).

 

In my WideClient.ini file I have this line:

 

[user]
Log=Errors+
KeySend101=123
 
In my app I have this line waiting to detect keysends:
 
        private void ui_KeyPressed(object sender, UserInputKeyEventArgs e)
        {
            MessageBox.Show("Pressed " + e.ID);
            // do stuff here
        }

 

When I press that button on my joy stick, this event does not fire.

 

Pages 15 and 16 in the WideFS Technical.pdf talks about key presses and setting a parameter but the examples it shows are keyboard related keys such as Shift+A etc. So I think I don't have the right WideClient.ini syntax for a button press?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Yes, Paul, that is what I wanted to do. Press a button on my controller and have my remote app respond to it.

 

So, I see how that works...thanks.

 

Pete

 

I see when I have the FSUIPC dialog up, I can press a joy stick button (on the Buttons + Switches Tab) and see the Joy# and Btn#. Then in my app's C# code I can program for that and trap that event. That all works fine. My question is back in the FSUIPC dialog: should I actually fill in the 'Control Sent when button is pressed' section and save this button press or do nothing except note the Joy# and Btn# to use in my C# code?

 

Thanks...

Link to comment
Share on other sites

I went into the FSUIPC dialog and set a button press on my joy stick with a parameter of 101 (and selected the KEYPRESS WideFS (0-255) in the drop down list).

 

In my WideClient.ini file I have this line:

 

[user]
Log=Errors+
KeySend101=123
 

When I press that button on my joy stick, this event does not fire.

 

Pages 15 and 16 in the WideFS Technical.pdf talks about key presses and setting a parameter but the examples it shows are keyboard related keys such as Shift+A etc. So I think I don't have the right WideClient.ini syntax for a button press?

 

The second parameter actually documented for the key on its own is 8, so really the KeySend line should be

 

KeySend101=123,8

 

though you can also use 0, as it says. However, I *think* it should default to 0 if omitted (but i've never tried it -- I tend to follow my own documentation! ;-) ).

 

The other thing is that without direction to your specific program, the keypress will just go to the application on the client PC with the current keyboard focus. Are you sure that was your program?

 

The easiest way to make sure it's directed to your program is to have WideClient actually start your program, using a Run or RunReady parameter, then add a third parameter to the KeySend line to tell it to go to that program, by reference to the parameter name you used to load it.

 

You could use your program's window class name, if that's likely to be unique, plus it's title bar text if that helps.

 

There's also a difference between using UseSendInput=No (default) and Yes. This changes the way the key is sent. Normally your program would only get WM_KEYDOWN and WM_KEYUP messages, but with UseSendInput=Yes WideClient simulates the keyboard more closely and as a result you get messages such as WM_CHAR where appropriate, and all the Windows message flags are set properly.

 

Different programs look for keypresses in different ways.

 

BTW you can log the KEYSEND reception in WideClient by setting

 

Log=KeySend

 

in the INI file [user] section.

 

Pete

Link to comment
Share on other sites

My question is back in the FSUIPC dialog: should I actually fill in the 'Control Sent when button is pressed' section and save this button press or do nothing except note the Joy# and Btn# to use in my C# code?

 

 

 

You don't need to program anything in the FSUIPC dialog. It's just an easy way of finding out your joystick and button numbers. As with the key presses, everything is set up by your C# application via the UserInputServices.

 

Paul

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.