Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi Pete,

All of the mouse-controlled functions on a Reality XP GNS can be mapped to a combination of keystrokes so I have coded a simple Lua program to map these mouse actions to a set of rotary encoders and switches. All works great except for two functions which have time-dependent responses, ie press momentarily for one action or hold for 2 seconds for another. However, it appears that the response from my Lua file (I'm using ipc.keypressplus with 0 for press/release to detect the controller button) is always that of the held action. Is it possible for me to get the momentary action response?

Also, can you explain the concept of "focus" in the context of ipc.keypressplus, is this relevant to my problem?

Many thanks for any help.

Best regards

Posted

All of the mouse-controlled functions on a Reality XP GNS can be mapped to a combination of keystrokes so I have coded a simple Lua program to map these mouse actions to a set of rotary encoders and switches.

Why can't you assign the encoders and swtches directly to the keystroke combinations?

All works great except for two functions which have time-dependent responses, ie press momentarily for one action or hold for 2 seconds for another. However, it appears that the response from my Lua file (I'm using ipc.keypressplus with 0 for press/release to detect the controller button) is always that of the held action. Is it possible for me to get the momentary action response?

Sorry, I don't understand. How does using keypressplus detect a controller button? And how is it taking two seconds?

Also, can you explain the concept of "focus" in the context of ipc.keypressplus, is this relevant to my problem?

Why would you be using keypressplus in any case if it were not for the focus issue? The only other use of it is to get keypresses sent to FS menus, which are otherwise modal so preventing normal FSUIPC actions like sending keypresses.

Keyboard focus merely refers to the window which currently receives keypresses. It has the user's focus. Since I don't know why you are using Lua I can't say what is up with what you are trying to do. I would have thought the best way to program buttons and rotaries to send keypresses was to just assign them. Your momentary or 2 second hold is achieved then by the repeat whilst held option.

In general, for a Lua program, a button press action can be timed and different actions resulting quite easily. Simply have the button push start the Lua and the button release set a flag for that Lua (LuaSet ...). In the Lua code you read the elapsed time, then loop till you see the flag, then read the time again. Act according to the difference. You can of course have a limit on the loop to, for example, exit after 2 seconds in any case.

Perhaps if you showed your Lua code it might make it easier for me to understand what and why you are doing what it is you are doing?

Regards

Pete

Posted

Hi Pete,

Many thanks for the prompt reply.

The mouse actions are equivalent to key combinations of the form ctrl+shift+win+A (or B or C etc). I had difficulty directly setting a button to combinations like this. Is this possible?

The alternative approach I used in the Lua file was to detect the button (event.button) which I am setting to the mouse action I want to emulate and use this to call a lua function which uses ipc.keypress to send the appropriate key combination to FS,

eg for ctrl+shift+win+C I use

function button1( )

ipc.keypressplus(67,43)

ipc.display(" Button activated ",2)

end

I was assuming that keypressplus was equivalent to a "press and release" key action.

In the mouse action that I trying to emulate with buttons, clicking the on-screen hotspot gives one response while clicking and holding gives a different response.

Best regards

Posted

The mouse actions are equivalent to key combinations of the form ctrl+shift+win+A (or B or C etc). I had difficulty directly setting a button to combinations like this. Is this possible?

Yes. There should be no difficulty. All of the shifts usable in Lua are also usable in the assignments -- the same core routines are used by both in any case. What was the difficulty? I just tried assigning a button to "ctrl+shift+win+A" and it worked fine.

I was assuming that keypressplus was equivalent to a "press and release" key action.

Well that's what the normal ipc.keypress function does. The ipc.keypressplus was added for two things only:

1. To try to get keys pressed whilst in FS menus or dialogues where FSUIPC is normally halted because of the modal nature of the dialogue, and

2. To optionally move the keyboard focus to FS and afterwards back to the original owner, for use when sending keypresses to external programs.

For your use "keypress" is quite adequate and normal.

In the mouse action that I trying to emulate with buttons, clicking the on-screen hotspot gives one response while clicking and holding gives a different response.

If it works with assigned keypresses from the real keyboard there's no reason I can think of that it won't work with keypresses assigned to buttons in FSUIPC.

Regards

Pete

Posted

Hi Pete,

I have investigated a bit more and the problem is with the gauge itself, the code is operating fine. I may be able to get a workaround using lua.

Many thanks.

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.