Jump to content
The simFlight Network Forums

Can I send keystrokes to FS?


Recommended Posts

I am writing a simple instructor station APP for a Kingair simpit, and I want to be able to switch between windowed and fullscreen mode. Is there any way for me to send ALT+ENTER via widefs/fsuipc to the FS box? Alternatively... am I making this too complicated, and is there an easier way?

The reason I want to do this is that the sim uses undocked panel windows (in this case for the realityXP Gamin GNS530) which don't like loading flights with the windows undocked. My solution is to drop FS back to a window, then load a flight, wait till it's ready to fly again, and jump back to fullscreen.

Sean

Link to comment
Share on other sites

I am writing a simple instructor station APP for a Kingair simpit, and I want to be able to switch between windowed and fullscreen mode. Is there any way for me to send ALT+ENTER via widefs/fsuipc to the FS box? Alternatively... am I making this too complicated, and is there an easier way?

You can try sending the ALT+ENTER combination. I've never tried myself, but I don't see why it shouldn't work. It depends on what level FS is decoding it at. You can send keypresses via the 3110 offset. Just use the added FSUIPC control number 1070 with the encoded keypress and shifts, as documented in the Advanced User's guide.

The reason I want to do this is that the sim uses undocked panel windows (in this case for the realityXP Gamin GNS530) which don't like loading flights with the windows undocked. My solution is to drop FS back to a window, then load a flight, wait till it's ready to fly again, and jump back to fullscreen.

But won't that tend to lose the positions for the undocked windows? Especially when used on a multi-screen system. Also, panels are easily undocked when in Windowed mode, but it usually is not possible in full screen mode -- there's no concept of docking in full screen mode.

Panel windows are loaded with the aircraft when that is reloaded, and a flight load re-loads aircraft, so whatever way the panels were set when the flight was saved should be the same on the flight load, so whatever you do I can't see how it could make any difference?

Regards

Pete

Link to comment
Share on other sites

Hi Pete,

Thanks for the quick reply!

You can try sending the ALT+ENTER combination. I've never tried myself, but I don't see why it shouldn't work. It depends on what level FS is decoding it at. You can send keypresses via the 3110 offset. Just use the added FSUIPC control number 1070 with the encoded keypress and shifts, as documented in the Advanced User's guide.

I figured that 3110 was going to be the answer, haven't tested yet, but I noted in the docs a warning about using ALT keys. I'll write something up, test it and report how it goes :)

But won't that tend to lose the positions for the undocked windows? Especially when used on a multi-screen system. Also, panels are easily undocked when in Windowed mode, but it usually is not possible in full screen mode -- there's no concept of docking in full screen mode.

Panel windows are loaded with the aircraft when that is reloaded, and a flight load re-loads aircraft, so whatever way the panels were set when the flight was saved should be the same on the flight load, so whatever you do I can't see how it could make any difference?

FS must store the last known "undocked" location of windows, because you can save a flight with all manner of panels updocked, and so long as you re-load the flight in windowed mode, when you switch back to fullscreen the undocked panels all jump back to their saved position. Sadly it doesn't work if you load the flight in fullscreen :(

I thought I had gotten around the undocking problem by using a Matrox Triplehead3go, with one channel for out-the-window and the other 2 for panels, but the addition of a GARSIM530, which is a separate monitor output, has put paid to my cunning plans.

Cheers

Sean

Link to comment
Share on other sites

I figured that 3110 was going to be the answer, haven't tested yet, but I noted in the docs a warning about using ALT keys.

The warninmg about ALT is simply there because effectively, as soon as ALT is seen, the Sim goes into Menu modes after which the keystrokes won't be seen, or even sent if FSUIPC gets stopped because the menu selection goes modal. But ALT+ENTER as a combination is one action so stands a reasonable chance.

Regards

Pete

Link to comment
Share on other sites

The warninmg about ALT is simply there because effectively, as soon as ALT is seen, the Sim goes into Menu modes after which the keystrokes won't be seen, or even sent if FSUIPC gets stopped because the menu selection goes modal. But ALT+ENTER as a combination is one action so stands a reasonable chance.

I like the "reasonable chance" part :) I'll give it a go and see what happens. I don't like the clunky solution that this is going to be, but since the undocked windows are problematic I don't see too many other choices..

Thanks again for steering me in the right direction!

Sean

Link to comment
Share on other sites

I need a little more guidance...

For FS Control 1070 the parameter required is: Keycode + (256 * Shift code)

Where do I find what the shift code is? (I have looked in the docs, but may have overlooked it...)

Where did you find the Key Code? They are both together. The Key Code list is in the section on Button Programming ("Format of Button Definitions") with the shift codes explained immediately afterwards. FSUIPC control 1070 is merely using the button programming action internally.

Pete

Link to comment
Share on other sites

Hi again Pete,

I have just added code to write to FS Control 1070 at offset 3100, and the results are not quite what I expected....

FSUIPC is reporting (via the Adv window) that 3110 is setting correctly to 1070, and 3114 (should be the "parameter" correct?) is setting to 6157, being 13 + 256*(8+16), being 13 (keycode for enter) + 256*(code for normal, + code for alt)

Weird part; what I am setting in FSUIPC is actually appearing to affect the active window, i.e. my instructor station APP.

I changed my code to send ALT+F4, and it closed my app, rather than FS. Now, I haven't tried it with FS on a different PC, and having FS in focus, which may make a difference...

Unless I have done something wrong that is....

More to come as I play around :)

SeanG

Link to comment
Share on other sites

Weird part; what I am setting in FSUIPC is actually appearing to affect the active window, i.e. my instructor station APP.

I changed my code to send ALT+F4, and it closed my app, rather than FS.

Your window must have keyboard focus. I did add facilities to the FSUIPC Lua facilities to temporarily change focus to FS then back to the originally focussed window ("keypressplus"), but they aren't available to WideClient. The point of the keypress facilities is to send keypresses to whatever has the focus, which with a remote app is normally going to be FS on the server. If you want to do things in FS with a focussed app on the server then at present you'd need to use a Lua plug-in. You can use offset 0D70 to make a plug-in run.

Regards

Pete

Link to comment
Share on other sites

Thanks Pete,

I figured out the keyboard focus part... I had confused myself by testing it on my local machine. Once I ran it up on my sim it worked exactly as I wanted, and since the sim it will be living on only has FS on the target machine it wont be a problem.

That's one more hurdle over to getting this sim working as we want it :)

SeanG

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.