This project has moved and is read-only. For the latest updates, please go here.

VST Plugin isn't receiving KeyPress events in FL Studio

Topics: Editor UI, Host Compatibility
Feb 5, 2014 at 9:41 PM
Edited Feb 6, 2014 at 3:25 PM
I've been working on my own VST using VST.NET.

Everything is working great, except the TextBoxes on the main window (a UserControl) don't receive any keypresses when in FL Studio. I checked with some debug code and the KeyPress event isn't even called. Other events (GotFocus, etc) seem to work just fine though.

However, it works in FL's Bridged Mode, and in other VST Hosts, and on dialog boxes.

FL has two related options, "Typing keyboard to piano" and "Don't allow keyboard focus" they are both off.

Any suggestions? I'm guessing FL is intercepting the keypress events itself, if that's so is there a way to change that?
Feb 6, 2014 at 7:29 AM
As you have discovered the host plays a big role in whether the plugin receives keyboard events.

Additionally there are related methods on the IVstPluginEditor interface - you may want to give those a try - see if they get called.
I am not sure how you would forward these calls to your own Control...
Feb 6, 2014 at 3:48 PM
Ah, so there are. Are these tied to the VST key events (effEditKeyDown and effEditKeyUp)?
Feb 6, 2014 at 3:53 PM
Edited Feb 6, 2014 at 3:53 PM
Yes, VST.NET routes them to these methods on the editor object.

Are they getting called by FL?
Feb 7, 2014 at 1:54 AM
Edited Feb 7, 2014 at 2:23 AM
FL's support staff suggested I try those, so it seemed promising.

For some reason, IVstPluginEditor.KeyDown() is called reliably, but I rarely see the IVstPluginEditor.KeyUp() event. I can work with that though.

I had started a scheme where I subclassed TextBox (which I had to do anyway) and kept a reference to the currently selected one in my Plugin instance, then called a handler in that object from my PluginEditor KeyDown implementation, which also has a reference to the Plugin instance (I hope I explained that properly!), and it worked.

However, after some more experimentation I found that the standard KeyUp() is actually raised directly on the TextBox after all. So I'm planning on using that, even though it seems I have to manage the contents of the TextBox myself, which is doable.

Feb 7, 2014 at 8:17 AM
I have reviewed the VST.NET code and come to the conclusion that there may be a bug there. The VST SDK documentation states that the plugin should return true only when the key is really used. As you can see the method in the IVstPluginEditor is void. The Framework returns true when it finds the interface implementation.

I will let you know when I have the corrected code checked in - so you can give it a spin if you like and see if it solves any problems for you.

Feb 7, 2014 at 8:32 AM
Also there are some older methods (StdPluginDeprecatedCommandStub) that also have to do with key handling: KeysRequired and EditorKey...
Feb 7, 2014 at 9:39 AM
I have checked-in the changes to give the KeyDown/Up methods a bool return value. Return false if you do nothing with the key. Return true if you handle the key press.
Feb 9, 2014 at 6:55 PM
Thanks, but I'm not set up to recompile the core DLLs at the moment. I was able to successfully work around the issue using KeyUp() though.