Jump to content
The simFlight Network Forums

Kan fsuipc send keys ?


Recommended Posts

I read in the WideFS manual that WideClient can send keys to programs whenever something on the FS (server) pc is triggered (like a key or a button).

Is this proces also possible in the other direction ?

I will have to run my interface software on a client pc due to the fact that it uses to much resources and it would hurt FS's FPS.

Because the panel I use doesn't use FS token variables, and needs direct key input, I would need WideClient to forward the key input from the client pc back to the server pc and trigger the keys there.

Is this possible ?

If not, will it be in the future ?

Link to comment
Share on other sites

I read in the WideFS manual that WideClient can send keys to programs whenever something on the FS (server) pc is triggered (like a key or a button).

Is this proces also possible in the other direction ?

FSUIPC can detect joystick buttons being pressed on Clients. This was part of the additional facilities in recent updates to WideFS and FSUIPC. Please peruse the release notes at the top of this Forum.

Because the panel I use doesn't use FS token variables, and needs direct key input, I would need WideClient to forward the key input from the client pc back to the server pc and trigger the keys there.

If you are not using buttons (which would be preferable) then the answer is yes, provided the WideClient window on the client PC has the focus when you are pressing the keys, or, if you are sending them from a program, that you send them to the WideClient window. To make this operate you simply set "SendKeyPresses=Yes" in the client INI file, as documented in the WideFS DOC.

If you are writing an interface program to do this, not actually using a keyboard as such, then you would be much better off using the "virtual buttons" facility provided in FSUIPC. See offsets 3340-3363 in the FSUIPC Programmers Guide. If you do this you can program the buttons in FSUIPC "Buttons" page to send keystrokes or controls.

Regards,

Pete

Link to comment
Share on other sites

Hi Pete,

I've been working on my software some more and came to the conclusion that WideClient.exe does not receive the keypresses generated by my code. :cry:

It does get the ones I do on the keyboard. The ini file is set up right and all. But no luck with the "sendkey("a") test I did. Even with wideclient having the focus, of cours.

Notepad receives those keysends just fine.

If I find no sollution for this I'll have a look at those 3340 ofsets.

Is it correct if I think I should send a string with 0's and 1's to this offset. If e.g. the first bit of my string is a 1 and all the others are 0 then the first "joystick button" is pressed. You talk about 9 such "joysticks" or 9 dwords. Do I all write these to 3340 ? or is it 3340 then 3341 for the next ? And how do I set these in fsuipc ? It must be via the ini file or something since I can not access the "button" menu so it seems without pressing a joystick button. This all seems rather confusing and complex to set up compared to the first sollution.

I wonder if you have any idea why my "sendkey" function from VS.Net does not get heard by wideclient while it does work on notepad and on FS if on the same pc. I could shift my software to the FS pc and not use widefs but then i would lose FPS due to the processing speed needed for my software which would be sad indeed.

Any idea maybe on how I could fix this ?

Hope to hear from you soon so I can get back to work 8)

Link to comment
Share on other sites

Oh My God ! This is madness ! :shock:

I have done something else. I've given focus on the server pc not to fs but to notepad there. Turns out that my "sendkey("c")" DOES get to the server pc via wideclient. However for some reason it doesn't do anything in FS. While a normal keypres "by hand" does work ?

Is this strange or what :?:

Any ideas there, Pete ?

Link to comment
Share on other sites

I've been working on my software some more and came to the conclusion that WideClient.exe does not receive the keypresses generated by my code. :cry:

It does get the ones I do on the keyboard. The ini file is set up right and all. But no luck with the "sendkey("a") test I did. Even with wideclient having the focus, of cours.

Notepad receives those keysends just fine.

I've no idea how yur are sending them, but WideClient merely reacts to the standard WM_KEYDOWN and KEYUP messages. There's nothing clever, no magic. If you are using a programming language which supplies microaoft's "spyxx" program you can check the messages it is receiving and compare them with the ones it gets from the keyboard.

If I find no sollution for this I'll have a look at those 3340 ofsets.

Is it correct if I think I should send a string with 0's and 1's to this offset. If e.g. the first bit of my string is a 1 and all the others are 0 then the first "joystick button" is pressed.

Yes, thought you don't need to write a whole DWORD just to change one bit, just the byte with that bit will do. Bits 0-7 are in the first byte, 8-15 in the second and so on.

You talk about 9 such "joysticks" or 9 dwords. Do I all write these to 3340 ? or is it 3340 then 3341 for the next ?

Neither. How can you get 32 x 9 bits into a 32 bit word? And 3341 is only one byte past 3340, with only 8 bytes. For 32 x 9 bits you need 4 x 9 = 36 bytes, as it says, from 3340 all the way to 33663 inclusive!

And how do I set these in fsuipc ?

You write to them through the FSUIPC interface. Please see the SDK. You use FSUIPC_Write and so on.

It must be via the ini file or something since I can not access the "button" menu so it seems without pressing a joystick button.

Sorry, you are losing me completely. Of course you need to set the button first, else how can you program it?

This all seems rather confusing and complex to set up compared to the first sollution.

I assure you it is 1000% easier and mch more efficient and reliable than messing with keys. What exactly is so strange about a "virtual" joystick button being recognised by a bit changing in memory? This is exactly how all the joystick interfaces work.

Regards

Pete

Link to comment
Share on other sites

Ok sorry !

A final test gave me this result: It is espens panel that does not accept initiated by a software, only by hand.

This became obvious when I ran my software on the server PC.

I know that Espen has been fooling around with the "receive key" option in his panel or whatever it is called. The problem we had was that his panel would accept keys even when FS did not have the focus. This would result in a weird setting of the panel whenever you whould let FS fly on autopilot for a bit and go type something in a forum or on msn. He wanted that out and I think now instead of disabeling the option to send keys when the panel is out of focus, he disabeled the option of sending keys from a software.

I am very happy to know and to tell you, Pete: your stuff still works great :wink: :lol:

I'll have to talk to Espen.

1 very final test is comming up with an older version of his panel to check if indeed it did use to work before. It should but just to make sure.

Link to comment
Share on other sites

It must be via the ini file or something since I can not access the "button" menu so it seems without pressing a joystick button.

Sorry, you are losing me completely. Of course you need to set the button first, else how can you program it?

Well if I don't have a joystick button to press to let fsuipc know which button I want to assign whatever action tohow do I do this then ?

Either way, I'm currently testing an older gau file to see if it makes any difference. If not I'll first check with Espen as to why it doesn't work.

The reason why I prefer keypresses over anything with joystick buttons is that espen is just making those keypresses hard coded in his gauge files. And I find using "virtual joysticks" rather confusing If my software can just do keypresses as if I would just press the keys and if espens panel captures them, then it's quite easy. All I need to do is make my software send a keypress and not write anything via to fsuipc which I can do, but I find it rather complicated at the same time. Though your explaining on the 3340 subject makes much better sence now. So if I would need to use that for whatever reason, tnx ! I think I get it now :)

Link to comment
Share on other sites

Victory for me :D

I tested an older gauge file and indeed it turns out that Espen changed something in his new file which cancels the option for the panel to receive keypresses generated by the pc and not by the user.

Sorry to have bothered you here Pete.

I'm on my way to e-mail espen.

Cheers!

Link to comment
Share on other sites

Well if I don't have a joystick button to press to let fsuipc know which button I want to assign whatever action tohow do I do this then ?

Just write your program to emulate any buttons you choose from the 288 available (288 = 9 x 32)! Which ones you choose doesn't matter unless you have other software also using this facility, in which case of course you'd want to avoid choosing the same bits.

Once your program is operating the bits in those "virtual button" locations, THEN you can easily program them in FSUIPC to do whatever you like. All you need to do is get your program to operate each "virtual button" and program it in turn.

This is EXACTLY the same as connecting a real joystick or button pad and programming the buttons on that in FSUIPC. The "virtual button" facility emulates real buttons.

The reason why I prefer keypresses over anything with joystick buttons is that espen is just making those keypresses hard coded in his gauge files.

Okay, fine. Please yourself. I won't argue. I just don't understand how you find buttons so mystifying.

Regards

Pete

Link to comment
Share on other sites

Hmmmz .. I see your point :)

So first I write my program to use this "button" facility. Then I hook up my sim to the interface. Then I press a button in my cockpit while having the "button" window shown in FS>Fsuipc. Then it will be triggered and I can set the output key.

That is nice indeed.

I don't have my interface yet, that's probably why I didn't understand it straight away and I couldn't use it at this point. I expect my Photon to be here next week. It's a strange idea however if you use a hardware interface and need keycommand to think of something as a joystick :wink: thus my confusion.

I know from Scott from Photon hardware that he is using an other option. Offset 3200. His point on using this prior to using the "sendkey" option is that it would enable sending keys to FS even when FS has no focus. He is making software that is used by a varyity of people whom have all other needs. However, my software is just for me personal use so I can make it a simple as I want.

Either way, it turns out I have these 3 choises I can make. Buttons, Sendkey or Offset 3200. In the end, they all come down to the same thing. Though using buttons as you suggest would allow me to change a key command later in time without having to go into my code but I don't see that as a problem. I keep my source files so ...

If in time an other option than sendkey seems preferable to me I can still change. That's the big advantage of making your own software :) I know now how to use all 3.

I'm outa here now. Thnx very much for the info and for taking the time to try and help me out here. I appreciate it a lot.

Cheers,

P.

Link to comment
Share on other sites

It's a strange idea however if you use a hardware interface and need keycommand to think of something as a joystick :wink: thus my confusion.

The joystick analogy is just a convention. The business of 9 "joysticks" each with 32 buttons derives from the standard (outdated non-DirectX) Windows joystick support API which allowed each joystick (out of a maximum of 16) to have 32 buttons, represented by a bit each in a 32-bit DWORD.

The same analogy was extended many years ago by my EPIC driver for Windows 95/98. It presented the older ISA EPIC card as a set of 16 joysticks each with 32 buttons, 6 axes and a "POV" (point of view input, or "Hat"). Whether the things at the source end of these "buttons" were really physical buttons or just events made in software inside the EPIC was not relevant -- in many cases there was not a one-to-one correspondence. The "button" events would be programmed to perform whatever cockpit actions the EPIC programmer desired.

The virtual button facilities in FSUIPC are merely a continuance of the same sort of theme, for programmers of any equipment.

I know from Scott from Photon hardware that he is using an other option. Offset 3200. His point on using this prior to using the "sendkey" option is that it would enable sending keys to FS even when FS has no focus.

Yes, you can do that too. In fact the facility that activates in FSUIPC is the same one as that being used by WideClient when sending the keys it receives -- except it is WideServer doing the eventual "sending".

Don't forget, when sending keys to either WideClient or FS directly you can address them to the top level window with Classname "FS98Main". The program itself then doesn't need to have keyboard focus.

Regards,

Pete

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.