VST Plugin Still Not Getting Keystrokes

Discuss issues relating to audio plugins

Re: VST Plugin Still Not Getting Keystrokes

Postby andrewsimper » Sat Jan 14, 2012 3:51 am

The next issue you are going to have then is tracking the mouse as well as passing keys back to the host.
www.cytomic.com
sound music software
User avatar
andrewsimper
JUCE UberWeenie
 
Posts: 158
Joined: Mon Nov 03, 2008 1:24 pm

Re: VST Plugin Still Not Getting Keystrokes

Postby MarC » Wed Mar 14, 2012 7:19 pm

To make sure other readers don't waste their time: zamrate's patch is no longer necessary to make keystrokes work in Ableton Live (Windows 7) if you checkout the latest juce code (14/03/2012) and configure Ableton adding "-_EnsureKeyMessagesForPlugins " to an options.txt file.

Still, I'm sure that this issue will keep us entertained until the TextEditor is implemented following one of the last suggestions mentioned in this thread...
MarC
JUCE Obsessive
 
Posts: 64
Joined: Tue Nov 21, 2006 1:22 am

Re: VST Plugin Still Not Getting Keystrokes

Postby Shlomi » Thu Mar 15, 2012 10:32 pm

The Options.txt is not a user friendly solution.

And I think that the modifier if in RiphRaph's solution:

Code: Select all
            if (modifierKey)
            {
               int keyMods = 0;
   
               if (modifierKey == VKEY_CONTROL)   keyMods |= ModifierKeys::ctrlModifier;
               if (modifierKey == VKEY_SHIFT)      keyMods |= ModifierKeys::shiftModifier;
               if (modifierKey == VKEY_ALT)      keyMods |= ModifierKeys::altModifier;

               ModifierKeys::getCurrentModifiers().withFlags (keyMods);
            }


doesn't really do anything, it needs to be called before the peer->handleKeyPress() with something like updateCurrentModifiers() or as a parameter to handleKeyPress().

Unfortunately I don't know any complete solution to the keystroke problem yet.
User avatar
Shlomi
JUCE UberWeenie
 
Posts: 395
Joined: Tue Dec 28, 2010 2:06 pm

Re: VST Plugin Still Not Getting Keystrokes

Postby ssaue » Wed Apr 18, 2012 12:58 pm

I have to say that this thread confuses me a bit. We have run into the same problem and need a solution, but I am not at all sure what the best solution is based on the previous comments. Here are what we require:

* We provide text editors (with sliders and a custom xy pad) in our GUI that allows the user to enter floating-point numbers (including the '.' of course).
* It should work with Cubase and Ableton Live (or any other host for that matter)
* It should not depend on the user changing host options (at least not in text files)

We are currently working with Juce 1.53. Does any of the aforementioned solutions work for us? Has juce release 2.0 solved this problem?
ssaue
JUCE Weenie
 
Posts: 14
Joined: Wed Apr 18, 2012 11:41 am

Re: VST Plugin Still Not Getting Keystrokes

Postby andrewsimper » Wed Apr 18, 2012 2:35 pm

The only reliable way to get keyboard input is to pop up your own text editor in a new window and then make it go away on a loss of focus.
www.cytomic.com
sound music software
User avatar
andrewsimper
JUCE UberWeenie
 
Posts: 158
Joined: Mon Nov 03, 2008 1:24 pm

Re: VST Plugin Still Not Getting Keystrokes

Postby ssaue » Wed Apr 18, 2012 3:36 pm

Hmmm. In other words solutions like the one you presented earlier in this thread, and not solutions that depend on hacking the vst wrapper (such as those presented by zamrate or RiphRaph)?
ssaue
JUCE Weenie
 
Posts: 14
Joined: Wed Apr 18, 2012 11:41 am

Re: VST Plugin Still Not Getting Keystrokes

Postby Jakob » Wed Apr 18, 2012 3:41 pm

The code I've posted on page 1 works perfectly for us. No complaints from users so far, and having quite a big user base with RTAS/VST/AU, Mac+PC. Only thing is that some special characters are caught by some hosts (the @ for example).
User avatar
Jakob
JUCE Geek
 
Posts: 28
Joined: Mon Jun 14, 2010 6:45 pm

Re: VST Plugin Still Not Getting Keystrokes

Postby ssaue » Wed Apr 18, 2012 3:56 pm

Thanks. I assume you are basically doing the same: A text editor in a new modal window?

By the way, have you tested your solution with Reaper? We have noticed that window popups disappear behind the VST editor due to a "pinned-on-top"-mechanism in Reaper. This messes up the popup menus of comboboxes for instance. Could the same happen with your modal editors?
ssaue
JUCE Weenie
 
Posts: 14
Joined: Wed Apr 18, 2012 11:41 am

Re: VST Plugin Still Not Getting Keystrokes

Postby Jakob » Thu Apr 19, 2012 12:42 am

ssaue wrote:Thanks. I assume you are basically doing the same: A text editor in a new modal window?

On Windows if the host is not Sonar: Yes.

On Mac: No, just <grabKeyboardFocus()> does the trick.

ssaue wrote:By the way, have you tested your solution with Reaper? We have noticed that window popups disappear behind the VST editor due to a "pinned-on-top"-mechanism in Reaper. This messes up the popup menus of comboboxes for instance. Could the same happen with your modal editors?

We also have these issues on Windows if running Reaper in 64bit and the plugin in 32bit. We have no issues if both are 64bit (or 32bit).

Has anyone tested with the new JUCE 2.0 yet, if it's finally working out of the box?
User avatar
Jakob
JUCE Geek
 
Posts: 28
Joined: Mon Jun 14, 2010 6:45 pm

Re: VST Plugin Still Not Getting Keystrokes

Postby ssaue » Thu Apr 19, 2012 1:06 pm

Thanks again, Jakob. I will implement something along the lines of what you and Andrew have done. Why is it important to make a special case for Sonar? Does it hurt to do the same there, besides the fact that it isn't necessary?
ssaue
JUCE Weenie
 
Posts: 14
Joined: Wed Apr 18, 2012 11:41 am

Re: VST Plugin Still Not Getting Keystrokes

Postby atom » Thu Apr 19, 2012 1:28 pm

I don't know if that was said but i didn't like any of those solutions since my plugin changes it's controls at runtime, it's like a WYSIWYG for plugins (MIDI plugins). So i had to go all the way and i created a small wrapper code that's the actual AudioProcessorEditor and your plugin window is actually a normal Desktop window that has all the perks of beeing on the desktop, no more keyboard issues or any issues of any kind. The trick is to keep the wrapper tightly integrated with the window. But it works for me so far and i need a lot of keyboard input in many components.
User avatar
atom
JUCE UberWeenie
 
Posts: 1115
Joined: Thu Feb 15, 2007 11:36 am

Re: VST Plugin Still Not Getting Keystrokes

Postby ssaue » Fri Apr 20, 2012 12:41 pm

Jakob wrote:The code I've posted on page 1 works perfectly for us. No complaints from users so far, and having quite a big user base with RTAS/VST/AU, Mac+PC. Only thing is that some special characters are caught by some hosts (the @ for example).


Hmm. I doesn't work here, at least not when I try to use your ModalTextEditor as the editor for my custom Label class. No editor shows up. Focus is lost immediately as a side effect of calling addToDesktop(ComponentPeer::windowIsTemporary). How do you create and show your editor from, say, a Label?
ssaue
JUCE Weenie
 
Posts: 14
Joined: Wed Apr 18, 2012 11:41 am

Re: VST Plugin Still Not Getting Keystrokes

Postby ssaue » Fri Apr 20, 2012 5:12 pm

In case anyone's interested I ended up with a solution close to what Andrew showed earlier on this topic. Since we only edit labels using double clicks, it turned out that the easiest fix for us was to customize the Label class only:

Code: Select all
#include "juce.h"

class HadronLabel : public Label
{
public:
   HadronLabel(const String& name = String::empty, const String& labelText = String::empty);
   ~HadronLabel();

private:
    bool    use_modal_editor_;

    // Override to allow custom text editor
    virtual void mouseDoubleClick(const MouseEvent& e);

    virtual void textEditorReturnKeyPressed(TextEditor& editor);
    virtual void textEditorEscapeKeyPressed(TextEditor& editor);
    virtual void textEditorFocusLost(TextEditor& editor);

    // Hide copy constructor and assignment operator
    HadronLabel(const HadronLabel&);
   const HadronLabel operator= (const HadronLabel&);
};

#include "HadronLabel.h"

HadronLabel::HadronLabel(const String& name, const String& labelText)
    : Label(name, labelText)
    , use_modal_editor_(false)
{
#if _WIN32
    // Windows need special handling (unless sonar is the host)
    const String hostPath(File::getSpecialLocation(File::hostApplicationPath).getFullPathName());
    const String hostFilename(File(hostPath).getFileName());
    bool is_sonar = hostFilename.containsIgnoreCase("SONAR");
    use_modal_editor_ = !is_sonar;
#endif
}

HadronLabel::~HadronLabel()
{
}

void HadronLabel::mouseDoubleClick(const MouseEvent& e)
{
    if (use_modal_editor_) {

        if (isEditableOnDoubleClick() && ! e.mods.isPopupMenu()) {

            ModalComponentManager::Callback* userCallback = 0;
            ScopedPointer<ModalComponentManager::Callback> userCallbackDeleter (userCallback);
            Component::SafePointer<Component> prevFocused (Component::getCurrentlyFocusedComponent());
            Component::SafePointer<Component> prevTopLevel ((prevFocused != 0) ? prevFocused->getTopLevelComponent() : 0);

            ScopedPointer <TextEditor> texteditor = createEditorComponent();
            texteditor->setColour(TextEditor::backgroundColourId, Colours::black);
            texteditor->setWantsKeyboardFocus (true);
            texteditor->setAlwaysOnTop (true);

            // Find screen position
            Rectangle<int> sr (getBounds ());
            sr.setPosition (getScreenX(), getScreenY());
            int fontheight = static_cast<int>(texteditor->getFont().getHeight()) + 4;
            if (sr.getHeight() > fontheight) {
                sr.translate (0, (sr.getHeight() - fontheight)/2);
                sr.setHeight (fontheight);
            }
            texteditor->setBounds(sr);

            texteditor->setText(getText(),false);
            texteditor->setHighlightedRegion (Range <int> (0, getText().length ()));
            texteditor->setVisible (true);
            texteditor->grabKeyboardFocus();
            texteditor->addToDesktop (ComponentPeer::windowIsTemporary, 0);
       
            texteditor->addListener (this);
            texteditor->enterModalState (false);
            texteditor->grabKeyboardFocus();

            texteditor->runModalLoop();

            if (prevTopLevel != 0)
                prevTopLevel->toFront (true);
            if (prevFocused != 0)
                prevFocused->grabKeyboardFocus();
        }
    }
    else {
        Label::mouseDoubleClick(e);
    }
}

void HadronLabel::textEditorReturnKeyPressed(TextEditor& editor)
{
    if (use_modal_editor_) {
        setText(editor.getText(), true);
        editor.exitModalState(0);
    }
    else {
        Label::textEditorReturnKeyPressed(editor);
    }
}

void HadronLabel::textEditorEscapeKeyPressed(TextEditor& editor)
{
    if (use_modal_editor_) {
        editor.exitModalState(0);
    }
    else {
        Label::textEditorEscapeKeyPressed(editor);
    }
}

void HadronLabel::textEditorFocusLost(TextEditor& editor)
{
    if (use_modal_editor_) {
        editor.exitModalState(0);
    }
    else {
        Label::textEditorFocusLost(editor);
    }
}


ssaue
JUCE Weenie
 
Posts: 14
Joined: Wed Apr 18, 2012 11:41 am

Re: VST Plugin Still Not Getting Keystrokes

Postby bdejong » Mon Dec 10, 2012 5:02 pm

Guys,

Imho none of these "fixes" or "workarounds" make a lot of sense, this should REALLY be fixed at the level of Juce as far as I'm concerned...
Zamrate's patch is OK, but it fails for the decimal ".", so for example if you want to type the value of a parameter ("1.5") it fails, so it's not really a solution.
Should we start another thread for a petition Jules to fix this?
It looks like this bug has been around since Cubase 3 and it's still not fixed, that's... madness.

- Bram
bdejong
JUCE UberWeenie
 
Posts: 278
Joined: Wed Sep 28, 2011 1:30 pm

Re: VST Plugin Still Not Getting Keystrokes

Postby yairadix » Sun Dec 30, 2012 8:39 pm

bdejong wrote:this should REALLY be fixed at the level of Juce as far as I'm concerned...


+1.

As I think this should belong in JUCE, I made my version of the work-around a patch to juce changing its own Label class. see https://github.com/yairchu/JUCE/commit/ ... bbabb94ace

It's based on Jakob solution, BUT I found that in Samplitude that solution actually makes the keystrokes stop working! So my patch only does it for Cubase & PT (I'll have to check what's up with Nuendo, I suspect it will probably act like Cubase).
User avatar
yairadix
JUCE UberWeenie
 
Posts: 130
Joined: Fri Jul 23, 2010 10:38 pm

PreviousNext

Return to Audio Plugins

Who is online

Users browsing this forum: No registered users and 1 guest