yabridge icon indicating copy to clipboard operation
yabridge copied to clipboard

optional keyboard passthrough

Open Goli4thus opened this issue 1 year ago • 4 comments

Feature description

Hi robbert-vdh! First off, thanks to you and the community for creating yabridge!

I recently started trying it out to see how it performs.

Status quo

One thing that stuck out bit negatively to me is the keyboard input handling, specifically on reaper. Right now it's like this:

  • when mouse is over the plugin window (oftentimes seems to be called "editor window"), all keyboard input goes towards plugin window
  • as mouse leaves plugin window, focus is given back to reaper

When I looked through existing issues, I found this one: https://github.com/robbert-vdh/yabridge/issues/38 I certainly can see that it was quite a journey to get where it is now! But even though it's an older topic, I hope suggestions are still welcome.

EDIT2: I ended up completely rewriting how keyboard input is handled to be simpler, more reliable, and to be able to give input focus back to the host when needed (can be useful in REAPER).

I'm not sure I fully understand the last part. Focus only seems to return to reaper when placing mouse outside of plugin window. Furthermore, the README mentions in section Input focus grabbing, that there's this mechanism regarding "holding shift key" to direct all keyboard input (e.g. spacebar) to plugin window. I tried it out with bitwig just to see how that behaves. It's certainly better than in reaper.

Suggestion

To get to the main point of me writing all this, here is a suggestion on how yabridge could handle keyboard input even better from an UX perspective:

I assume there's a way to forward keyboard input to host even if mouse is over plugin window (i.e. technically possible). If so, let's say we add something like this keyboard_passthrough option to yabridge.toml:

["FabFilter*.so"]
group = "fabfilter"
keyboard_passthrough = [ 'spacebar', 'F1', 'F2', 'F3', 'q', 'w' ]

Or even something like this:

["FabFilter*.so"]
group = "fabfilter"
keyboard_passthrough = true

Then the behavior could be like this:

  • by default, (the first case) yabridge will forward all keyboard input regarding respective plugin group to plugin window, except for those events that are listed in this keyboard_passthrough list
  • by default, (the second case) yabridge will forward all keyboard input regarding respective plugin group to host (except modifier keys like alt, shift, etc. when used in conjunction with mouse events)
  • using the "hold shift" trick, any such forwarding would be temporarily disabled (i.e. all input would be directed to plugin window; basically what already exists)

Why would this be helpful? From a workflow perspective, I certainly need the ability to have at least certain keys reach the host (reaper) by default at all times. I simply use this way more often than I type anything into a plugin window's input box.

But I'm aware that different users have different needs and the way things are now is perfectly fine for them. This suggestion would allow for letting users decide the behavior themselves.

The above config ideas are based on editing plugin groups. But it might make sense to have a "global" keyboard_passthrough list as well (e.g. spacebar might be a key that always should be forwarded to host, regardless of plugin group). Of course, this will make it bit more complex, cause then the "global" and "plugin group" lists need to be merged on the fly. Furthermore some edge cases like have keyboard_passthrough: true set globally, but then also having a list of keys in a plugin group would need some precedence re evaluation (e.g. "global" wins in this case).

But IMO it's important to have both the global and the plugin group specific configuration, as this gives the greatest amount of flexibility to the end user, helps avoiding having to repeat a common setting for all plugin groups and likely will cover most workflow scenarios that could come up.

Possible technical challenges here might be:

  • checking the actual keyboard input against the content of keyboard_passthrough list in case of individual keys:
    • I'm not sure if having such a "plain" listing is possible, or if some special "syntax" is needed (or even keycodes, etc., which would make configuration bit harder)
  • the keyboard input forwarding to host while plugin window has focus

Do you think this is technically doable? Maybe I'm missing something for why this is a bad idea. So I'm open to critique or suggestions!

Anything else?

Some technical notes:

  • manjaro
  • wine 8.6
  • yabridge 5.0.4 (via pacman)
  • reaper (latest; linux native)

Goli4thus avatar Jun 24 '23 17:06 Goli4thus