Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi John,
 

Not an urgent problem but just a suggestion for future versions of FSUIPC, which could save a lot of LUA programming if you want to make multiple use of a single button.

Very often many users with a limited number of buttons make use of the method, to distinguish between a shot button press and a long one to trigger different functions. There is a nice example in the documentation folder (TripleUse.lua), how to solve this by a LUA program. But you have to code this for all button events, which you monitor, where you need this functionality.

The current syntax of the event.button trigger (or at least one of the four possible) looks like this:

event.button(joynum, button, downup, "function-name")

Addimg one additional parameter (duration in msec to identify a long press) in case of downup being 2 (detecting the up event) could return a different downup for a short and for a long button press.

event.button(joynum, button, downup, "function-name",longpress)

event.button(j17, 3, 2, "myFunction",2000) for example would return downup as usual when the button was pressed shortly. Pressing it longer that 2 seconds could return a different downup value to the defined function, which then could do different things depending on the returned value.

This could be made completely upward compatible. If there is no parameter specified, it returns downup as usual. In fact this would only affect events, where downup is specified as 2 (or 3). All the other behavior stays completely the same. So if the code for remembering the point in time, when the button went down and deciding according to the duration when the button went up again in case if there is a longpress parameter supplied, could move to FSUIPC, this would save a lot of LUA coding on pilot side. And all the existing LUA programs would work as before.

So if you once should have plenty of time on a rainy day, maybe you think about the proposal 😉

Best regards and thanks for the great addon.
Reinhard

 

Posted

Sounds reasonably, but I don't think this will be that easy to implement. I will make a note to look into at some point, but not sure when I will have time. I already have quite a long list of new functionality to implement (mainly for FSUIPC7 / MSFS) and have very little time for this as support is  still taking up most of my time.

Regards,

John

  • Thanks 1
  • 3 months later...
Posted

After looking into this further, I don't think i will be implementing this. Issues arise when there is a long press but only an event on a short press - should the short press function still be called? Presumably so, otherwise this would effect existing behavior, but this then means the function called depends on the events registered which is a pain to handle...This is also problematic with switches which are like buttons but are 'always on' or 'always off', which can also give issues (as FSUIPC doesn't know the difference between a button and a switch, it just sees the change events.

Note there are already lua scripts that you can use to handle long and double button presses - see 

John

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.