commit bb0c16cfdb9d477cdc4485482f8962559b3e85d2
parent 21a0c86bce9795af2f266c87a56127946aa446d3
Author: falkTX <falktx@falktx.com>
Date: Tue, 18 May 2021 00:48:26 +0100
VST: Store keyboard modifiers from host key events
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/distrho/src/DistrhoPluginVST.cpp b/distrho/src/DistrhoPluginVST.cpp
@@ -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
diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp
@@ -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);