Browse Source

VST: Store keyboard modifiers from host key events

Signed-off-by: falkTX <falktx@falktx.com>
pull/272/head
falkTX 4 years ago
parent
commit
bb0c16cfdb
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 30 additions and 6 deletions
  1. +28
    -4
      distrho/src/DistrhoPluginVST.cpp
  2. +2
    -2
      distrho/src/DistrhoUIInternal.hpp

+ 28
- 4
distrho/src/DistrhoPluginVST.cpp View File

@@ -183,7 +183,8 @@ public:
nullptr, // TODO file request
nullptr,
plugin->getInstancePointer(),
scaleFactor)
scaleFactor),
fKeyboardModifiers(0)
{
}

@@ -275,7 +276,6 @@ public:
// handle rest of special keys
/* these special keys are missing:
- kKeySuper
- kKeyMenu
- kKeyCapsLock
- kKeyPrintScreen
*/
@@ -303,20 +303,43 @@ public:
case 54: special = kKeyShift; break;
case 55: special = kKeyControl; break;
case 56: special = kKeyAlt; break;
case 58: special = kKeyMenu; break;
case 52: special = kKeyNumLock; break;
case 53: special = kKeyScrollLock; break;
case 5: special = kKeyPause; break;
}

switch (special)
{
case kKeyShift:
if (down)
fKeyboardModifiers |= kModifierShift;
else
fKeyboardModifiers &= ~kModifierShift;
break;
case kKeyControl:
if (down)
fKeyboardModifiers |= kModifierControl;
else
fKeyboardModifiers &= ~kModifierControl;
break;
case kKeyAlt:
if (down)
fKeyboardModifiers |= kModifierAlt;
else
fKeyboardModifiers &= ~kModifierAlt;
break;
}

if (special != 0)
{
fUI.handlePluginSpecial(down, static_cast<Key>(special));
fUI.handlePluginSpecial(down, static_cast<Key>(special), fKeyboardModifiers);
return 1;
}

if (index > 0)
{
fUI.handlePluginKeyboard(down, static_cast<uint>(index));
fUI.handlePluginKeyboard(down, static_cast<uint>(index), fKeyboardModifiers);
return 1;
}
# endif
@@ -388,6 +411,7 @@ private:

// Plugin UI
UIExporter fUI;
uint16_t fKeyboardModifiers;

// -------------------------------------------------------------------
// Callbacks


+ 2
- 2
distrho/src/DistrhoUIInternal.hpp View File

@@ -422,7 +422,7 @@ public:
return ! glApp.isQuiting();
}

bool handlePluginKeyboard(const bool /*press*/, const uint /*key*/)
bool handlePluginKeyboard(const bool /*press*/, const uint /*key*/, const uint16_t /*mods*/)
{
#if 0 /* TODO */
return glWindow.handlePluginKeyboard(press, key);
@@ -430,7 +430,7 @@ public:
return false;
}

bool handlePluginSpecial(const bool /*press*/, const DGL_NAMESPACE::Key /*key*/)
bool handlePluginSpecial(const bool /*press*/, const DGL_NAMESPACE::Key /*key*/, const uint16_t /*mods*/)
{
#if 0 /* TODO */
return glWindow.handlePluginSpecial(press, key);


Loading…
Cancel
Save