Jump to content
The simFlight Network Forums

lua event-based fast/slow button generator for rotary switches


Blake Buhlig

Recommended Posts

https://raw.githubusercontent.com/bbuhlig/fsuipc-contrib/main/rotfsev.lua

The above is what I wrote to manage slow vs. fast rotation of the inc/dec and trim wheel on my Honeycomb Bravo. While not perfect, it's the best I've been able to manage so far given the apparent inability of these rotaries to detect button presses faster than ~95ms. 

This module monitors a set of rotary switches for fast vs. slow toggling based on a user provided threshold between successive button events. If the rotary is moved fast enough that consecutive button events are received within a threshold, a fast virtual button is sent and successive button events are ignored. Otherwise a slow virtual button is sent for each button event if consecutive events are not received within the threshold. If your device is "glitchy" and regularly generates spurious fast events even when turning the rotary slowly, you can tell the module to treat a configurable number of fast events received within a time period as slow events.

Each virtual button can be assigned in the .ini to send FS control commands and keypresses, such as variable rates for trim adjustments on an elevator trim wheel, ref p.25 of the Advanced User's Guide.

This module provides a generally similar concept to the Rotaries.lua approach but takes advantage of buttons that are directly detected by FSUIPC and is primarily event-based rather than poll-based. Thus it should be more efficient/performant.

Define the desired buttons according to the array passed to the init() function at the bottom of the file.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Note when using this script, the virtual buttons will not be seen in the button assignments panel. This is because the event.offset and event.button functions are not called when the buttons assignment panel is open. Therefore, to assign to the virtual buttons, you should first assign to the physical buttons and then edit your FSUIPC7.ini to manually change the assignments to the virtual buttons (including  duplicating the physical button assignment to create two virtual button assignments and changing the control for the fast/slow movement).

For an alternative solution that uses polling and so the virtual buttons can be seen on the assignments panel, together with examples on how to assign to the virtual buttons for the different functions of the selector knob, see 

 

John

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.