Jump to content
The simFlight Network Forums

FS2020 and FSUIPC character and input detection - rotary encoders


kooky45

Recommended Posts

Can someone explain to me how FSUIPC7 reads keyboard inputs when running with FS2020, please, and how it sends the mapped commands back to the sim?

I bought a mini keypad but instead of having five keys installed I asked the builder to put in 5 rotary encoders (it's a miniMacro5c). The firmware has been flashed so that each rotation of a knob sends a keyboard character to the computer, a different one for each knob and each direction, and also when the knobs are pressed downwards. I want to use it for things like radio tuning, AP heading, etc.

If I have any type of text input window open on the computer, like Notepad++, or even a text input field in FS2020, rotating or pressing the knobs reliably inputs the right character into the the computer - never missing a character and is very fast. But when I'm in the sim cockpit and the sim is running then the inputs from the knob rotations are very unreliable, most are missed and when the sim does catch them it's erratic.

I thought I'd try FSUIPC for catching the knob inputs and to feed them to the sim. But it makes no difference. When I'm viewing the FSUIPC console it looks like FSUIPC is waiting for the sim to tell it which keys it has detected being pressed and then tells FSUIPC. And since the sim is missing the character inputs then it's not telling FSUIPC. I'm lost for where the fault could be in the sim not reading the knob inputs (why it's so bad compared to all other tools on the computer) or how to address it.

All help gratefully accepted.

Many thanks.

Link to comment
Share on other sites

15 hours ago, kooky45 said:

Can someone explain to me how FSUIPC7 reads keyboard inputs when running with FS2020, please, and how it sends the mapped commands back to the sim?

Keyboard input is received from MSFS via SimConnect as key input events, when MSFS has the focus. Commands are sent back (usually) as events also via simconnect.
When FSUIPC has the focus, it receives the key events as windows messages.

15 hours ago, kooky45 said:

And since the sim is missing the character inputs then it's not telling FSUIPC.

Yes, that would be the case when MSFS has the focus.


See if there is a difference when MSFS has the focus vs when FSUIPC has the focus.

John

Link to comment
Share on other sites

  • 11 months later...

Hi there,

this is a rather old post, but it addresses my problems too. I have a self made hardware (sold by DesktopAviator) which fully emulates a keyboard. Keystrokes are rarely recognized by MSFS and only if I set key down and key up times rather long (~50ms). So I tried to use FSUIPC as an interface, but I learned from several posts here that FSUIPC relies on MSFS according to key inputs. My final solution was to write a little program which hooks into Windows' keyboard input queue and connects to MSFS via SimConnect. This is independent of who has the focus, and it works fast. I can even implement a fast/slow feature for encoder inputs: turning fast sends 4 characters per detent while rotating slow gives just 1 character per detent. Couldn't FSUIPC have also such a keyboard hook, eliminating much of the problems MSFS has with custom-made keyboards?

Best regards
Detlef

 

Link to comment
Share on other sites

40 minutes ago, dedel said:

My final solution was to write a little program which hooks into Windows' keyboard input queue and connects to MSFS via SimConnect.

This is what FSUIPC previously did, when it was an embedded dll. I took the decision to switch to using SimConnect to receive keyboard input, as I had issues getting the input via hooks (can;t remember what exactly, was a long time ago now...), and using SimConnect also allows FSUIPC to receive (and act) upon keyboard input when it is running on a client PC (i.e. a separate PC to the one the FS is running on).

43 minutes ago, dedel said:

This is independent of who has the focus, and it works fast.

But what if you are using a utility program and you need the keyboard input to go to that program? Grabbing all keyboard input, regardless of focus, seems a bad idea IMHO. Sounds like you are treating all keys as hot keys doing this....

46 minutes ago, dedel said:

Couldn't FSUIPC have also such a keyboard hook, eliminating much of the problems MSFS has with custom-made keyboards?

Revising how FSUIPC handles keyboard input is something I could look into I guess, at some point...but I don't know if/when I will have time to look into this. There are far many other things I would like to do before this. and don't have time for much development at all at the moment....all my time is taken up by support and keeping up with MSFS / P3D releases at the moment...

Maybe you could share your program and I can take a look. I could possibly make it a configuration option to handle keyboard input differently, but I think the way it is currently handled is sufficient for most folks. There do seem to be some issues with custom keyboards though, or button-boxes that act like keyboards....

John

Link to comment
Share on other sites

Hi John,

the code is no secret. I put it here together with the compiled utility program in the 'Release' folder:

https://www.jottacloud.com/s/08862521f62b0504d59a7b21f6077666be7

Consider that it's a work in progress and not yet finished. The KBD03Link.cfg configuration program uses keyboard commands otherwise unused by the default settings of MSFS. The utility program filters these inputs without removing them from the keyboard event queue. So every keystroke is transparent and can also be used by other programs. I am programming simultaneously while MSFS is running for testing the code. It doesn't affect each other.

If you want to have a look at my hardware, I could send you a sample board (40mm by 40mm) for tests as a typical custom keyboard.

Detlef

Link to comment
Share on other sites

Hi Detlef,

19 hours ago, dedel said:

the code is no secret. I put it here together with the compiled utility program in the 'Release' folder:

https://www.jottacloud.com/s/08862521f62b0504d59a7b21f6077666be7

Thanks.

FSUIPC4, 5 and 6 use a similar windows hook to get the keyboard input, but as an embedded dll it only gets the input when the FS has the focus.
As I previously said, I do not like the idea of grabbing all keyboard input regardless of focus, as this would cause issue for mot (i.e. the majority) of FSUIPC users.
However, this does seems to be an issue when using additional 'keyboard type' devices. But, the issue with these is that they are not recognised by MSFS, and so the keyboard input is not forwarded to FSUIPC7 via SimConnect input events.

I can look into adding a global hook for keyboard input. If I do this, it will be activated on a new ini parameter (i.e. not active by default), and if/when activated, I will disable the keyboard input from SimConnect (to prevent multiple inputs). However, as I am very busy on other things at the moment, I am not sure when I will have time to look into this fully - maybe in 2-3 months or so, but earlier if I get a chance...

20 hours ago, dedel said:

If you want to have a look at my hardware, I could send you a sample board (40mm by 40mm) for tests as a typical custom keyboard.

Thanks for the kind offer, but this shouldn't be necessary. I should be able to implement and test sufficiently using a standard keyboard (or two!). I can also post here for you to try once implemented.

Thanks and regards,

John

Link to comment
Share on other sites

  • 2 months later...

Hi Detlef/ @dedel,

could you try the attached FSUIPC7.exe, v7.3.3b. You can use a global keyboard hook for keyboard input (instead of receiving keyboard input via SimConnect) by adding the following to the [General] section  of your GSUIPC7.ini file:
    UseKeyboardHook=Yes
The hook is set when you leave the MSFS main menu, and removed when you go back to the main menu.

Let me know if this enables FSUIPC7 to see the key presses from your button box.

John

FSUIPC7.exe

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 months later...

At last!

I could test the new FSUIPC with my keyboard emulator: Every keystroke is registered when keyboardhook is on. This works fast enough for rapid turns on encoders.

Best of all for me is that FSUIPC discriminates between left shift and right shift, left ctl and right ctl, left alt and right alt and even left gui and right gui and any combination of these. Together with, i.e., F13 to F24 keys this is more enough to not conflict with any default shortkeys.

Thanks,

Detlef

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.