Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi Paul

 

What's the recommended technique for calling FSUIPCConnection.Open()? I don't mean how to call it, I mean should we call it repeatedly out of a timer to make sure we are connected/keep our connection? Or is calling it once enough when our app starts up?

 

Thanks...

 

Posted

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

Posted

I finally got WideClient connecting on my remote PC to my main PC which is running FSX.

 

My app however, cannot seem to connect to FSUIPC using

 

FSUIPCConnection.Open();

 

When I run my app on my main PC it connects OK. IS there something different it has to do when run on the remote PC to be able to connect to FSUIPC?

 

WideClient is "connected" in the title bar of that app.

 

Thanks...

Posted

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

Posted

Paul,

 

Now that I finally have my app connecting to WideClient on my remote PC, I'm finally at the heart of what I need to do with my app on the remote PC. On my main PC I want to press a key combination such as Ctrl-1 and pass that through FSUIPC such that on my remote PC my app can detect it. Then my app can act accordingly with that key combination.

 

Normally, flight simmers manually set up various keys in FSUIPC to map to their sticks or control wheels, or even hot keys to do things, but in my case, I want to define a key combination like (Ctrl-1) and pass it through to my remote app and have it detect it.

 

I'm still pretty new to FSUIPC but I imagine I would manually setup the key stroke Ctrl-1 in FSUIPC but then I don't know what code I would need on my remote app side to detect it coming in?

 

I see in FSUIPC, on the Key Presses Tab, on the left side there is "Program keyboard controls here". I can see how to enter Ctrl-1 but the "Control sent when keys pressed" drop down list all seem to be pointing to FSX itself. I don't need FSX as the key press destination. I need the key press to 'pass through' to my remote app so I can detect it.

 

If you could give some pointers on what I need to do to set this up I'd appreciate it very much.

 

Thanks...

 

 

 

Posted

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

Posted

Thanks Paul.

 

I added your code example to my app and it works fine on my local PC but the MessageBox.Show("Pressed " + e.ID); doesn't popup when I run my app on my remote PC. So the ui_Key_Pressed() event isn't firing on the remote PC.

 

WideClient is Connected and my app on the remote is connected to FSUIPC. All the network connections are fine.

 

Is there some log data I can capture to see what happening?

 

Thanks...

Posted

On my main PC I want to press a key combination such as Ctrl-1 and pass that through FSUIPC such that on my remote PC my app can detect it. Then my app can act accordingly with that key combination.

 

There's no facility that does exactly that, but there is one which is much more flexible and can be programmed to do that if you wish. This is "KeySend", which is actually documented in the WideFS documentation.

 

Briefly you assign whatever you like, keystroke or button, it doesn't matter, to the "Keysend" control in FSUIPC, giving it a parameter, a number from 1-255. Then in WideClient.INI you place a parameter which tells WideClient what to do when it receives than specific KeySend. As well as sending keystrokes to a program it can start or stop a program and a few other things.

 

Pete

Posted

I added your code example to my app and it works fine on my local PC but the MessageBox.Show("Pressed " + e.ID); doesn't popup when I run my app on my remote PC. So the ui_Key_Pressed() event isn't firing on the remote PC.

 

WideClient is Connected and my app on the remote is connected to FSUIPC. All the network connections are fine.

 

Is there some log data I can capture to see what happening?

 

There are lots of logging facilities in WideClient, documented in the documentation for WideFS. You should also use FSInterrogate and/or one of the FS utilities supplied, like WeatherSet or TrafficLook, to make sure they are getting data okay.

 

The business of facilities in WideFS which you can use actually being documented has come up twice in a short time now. Do you actually have the documents to hand. They are supplied in the downloadable ZIP for WideFS.

 

Pete

Posted

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

Posted

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?

 

That system is for a program which wants to register keypresses in FSUIPC which can be detected by programming inside that program which monitors the flag bits which tell it when the key is pressed. There is a similar facility for detecting button presses.

 

And of course that works for clients or local programs because it is all a matter of offset manipulation.

 

Maybe he asked you for such advice earlier, but the question I was answering was 

 

"On my main PC I want to press a key combination such as Ctrl-1 and pass that through FSUIPC such that on my remote PC my app can detect it. Then my app can act accordingly with that key combination."

 

which seemed to be asking more for something like KeySend.

 

Maybe I misunderstood him too? Maybe we are both wrong in our interpretations?

 

Pete

Posted

"On my main PC I want to press a key combination such as Ctrl-1 and pass that through FSUIPC such that on my remote PC my app can detect it. Then my app can act accordingly with that key combination."

 

You understand my question correctly Pete.

 

I'm looking at the WideFS docs now and at SendKey.

 

"Briefly you assign whatever you like, keystroke or button, it doesn't matter, to the "Keysend" control in FSUIPC, giving it a parameter, a number from 1-255."

 

Do you mean the FSUIPC dialog? I don't see a tab labeled "Keysend". Or do I add this "Keysend" line in the FSUIPC.ini file?

 

I see in the FSUIPC User Guide page 34 the ans to my question immediately above:

 

"A control for sending KeySend messages to WideFS clients running on other PCs."

 

So, in FSUIPC options dialog, Key Presses Tab, I have defined a key F12 and assigned a parameter of 101 to it and used the KEYSEND list item.

 

In my FSUIPC.ini file I see this entry for that:

 
[Keys]
9=123,8,1006,101

 

In WideFS.ini I have added this line to the [user] section:

 

[user]
Log=Errors+
KeySend101=123
 

WideFS would see 101 come in and assign it to F12, correct?

 

So, Paul, if these assumptions are correct, then I would have to create a KeyPress event in my app to detect that keypress 123 (F12) came in.

 

Thank you...

Posted

So, Paul, if these assumptions are correct, then I would have to create a KeyPress event in my app to detect that keypress 123 (F12) came in.

 

 

 

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

Posted

>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.

 

How would I set up using the FSUIPC hotkey method? Enter the hotkey into the FSUIPC options dialog window? Then use your UserInputServices to grab the key.

 

I see in the FSUIPC options dialog that the hotkey Tab has only one empty slot to define a hotkey. There are 9 others but they are preset. I will need to define more than one hotkey if I use this method.

 

>I should say that I believe Pete has misunderstood what you want to do.

 

I don't believe so Paul. He knows I registered both products so he knows I am using FSUIPC and WideFS.

Posted

How would I set up using the FSUIPC hotkey method? Enter the hotkey into the FSUIPC options dialog window? Then use your UserInputServices to grab the key.

 

No no no. The method Paul is talking about is in no way related to the FSUIPC pre-defined Hotkeys tab. It is a facility for an application to register an interest in keypresses by filling in details in a table in FSUIPC Offsets -- i.e. places you WRITE using the FSUIPC application interface.

 

Please refer to the FSUIPC Programmers guide. It is all described under the heading "Hot Keys for Applications".

 

Pete

Posted

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:
 

    I added your code example to my app and it works fine on my local PC but ... doesn't ... when I run my app on my remote PC

 

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

Posted

Paul,

 

>Do your FSX menu additions work on the WideClient pc?

My menu additions work fine on the main PC. However, I don't understand this question...I can't access the FSX menu system from the remote PC where WideClient is running. There is no FSX installed on it. So, how can I access the FSX menu system?

 

My code is back to your example in #7 of this thread. Same results as yesterday: the key press is not being fired in the app running on the remote PC. I must be missing a step somewhere. I will re-read the FSUIPC hot key pages and re-check my code against what you have provided.

 

Thanks...

Posted

Hi Ralph,

 

>Do your FSX menu additions work on the WideClient pc?

My menu additions work fine on the main PC. However, I don't understand this question...I can't access the FSX menu system from the remote PC where WideClient is running. There is no FSX installed on it. So, how can I access the FSX menu system?

 

 

 

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.

 

the key press is not being fired in the app running on the remote PC

 

 

 

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

Posted

I see.

 

Yes, the FSX menus are being built on the main machine running FSX when I run my app on the remote machine.

 

When I press one of my apps menu items on the main PC, the menu item displays on my remote PC as expected (correct window was displayed)...however...the messageBox dialog also pops up and displays the "Button1" string that is defined from your key press sample code! So when I select a menu item, the keypress event is also being fired...and for the first time for me the key press event was fired on my remote PC.

 

I am not running my app on both machines at the same time. I only run my app one at a time on a given PC.

 

                ui = FSUIPCConnection.UserInputServices;
                ui.AddKeyPresss("Button1", FSUIPC.ModifierKeys.Ctrl, Keys.D1, false); // Three s's - typo in my dll.
                ui.KeyPressed += new EventHandler<UserInputKeyEventArgs>(ui_KeyPressed);
 
                ui.AddMenuItem("SCL", "SimChecklist", false);
                ui.AddSubMenuItem("chkList", "SCL", "Checklist");
                ui.MenuSelected += new EventHandler<UserInputMenuEventArgs>(ui_MenuSelected);
 
        private void ui_KeyPressed(object sender, UserInputKeyEventArgs e)
        {
            MessageBox.Show("Pressed " + e.ID);
        }
 
        private void ui_MenuSelected(object sender, UserInputMenuEventArgs e)
        {
            switch (e.ID)
            {
                case "chkList":
                    chklstForm.Show();
                    break;
            }
        }
Posted

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

Posted

Yes, that worked...I added my keypress stuff after the menus.

 

Update:

 

Some further information for you Paul.

 

When I have only one AddKeyPresss() line, it works fine (the action in my app running on the remote PC works as expected).

 

However, if I add more lines, as shown below, then what happens, is when I press Ctrl-1 on the main PC, the KeyPress event fires for all four AddKeyPresss() lines below. I'm expecting only one keypress event to fire and I have switch statements in that function to check the e.ID to see which key was pressed.

 

I see my messageBox dialog display 4 times when I press Ctrl-1 only one time. And each e.ID string is displayed in the messageBoxes as it pops up.

 

Maybe that is expected behavior? I should remm out the MessageBox line so I don't see it pop up 4 times?

 

                ui.AddKeyPresss("LSK1L", FSUIPC.ModifierKeys.Ctrl, Keys.D1, false); // Three s's - typo in my dll.
                ui.AddKeyPresss("LSK2L", FSUIPC.ModifierKeys.Ctrl, Keys.D2, false); // Three s's - typo in my dll.
                ui.AddKeyPresss("LSK3L", FSUIPC.ModifierKeys.Ctrl, Keys.D3, false); // Three s's - typo in my dll.
                ui.AddKeyPresss("LSK4L", FSUIPC.ModifierKeys.Ctrl, Keys.D4, false); // Three s's - typo in my dll.
                ui.KeyPressed += new EventHandler<UserInputKeyEventArgs>(ui_KeyPressed);
 

Thanks Paul...

Posted

Hi Paul

 

I notice that

 

ui.RemoveAll();

 

doesn't remove any of my Add-On FSX menu items that I put up there.

 

Is there something else that I need to also do?

 

Thanks...

Posted

I notice that

 

ui.RemoveAll();

 

doesn't remove any of my Add-On FSX menu items that I put up there.

 

 

Okay - I'll check that too.

 

However, if I add more lines, as shown below, then what happens, is when I press Ctrl-1 on the main PC, the KeyPress event fires for all four AddKeyPresss() lines below. I'm expecting only one keypress event to fire and I have switch statements in that function to check the e.ID to see which key was pressed.

 

 

 

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

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.