commit 21a0c86bce9795af2f266c87a56127946aa446d3
parent 841f7c66213149a0c82551b907bc2cdcd3e7a0ef
Author: falkTX <falktx@falktx.com>
Date: Tue, 18 May 2021 00:24:36 +0100
Correct usage of VST handlePluginKeyEvent; Fix compiler warnings
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
4 files changed, 83 insertions(+), 55 deletions(-)
diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp
@@ -66,7 +66,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s)
autoScaleFactor(1.0),
minWidth(0),
minHeight(0),
- modal(this)
+ modal()
{
init(DEFAULT_WIDTH, DEFAULT_HEIGHT, false);
}
@@ -85,7 +85,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, PrivateData* c
autoScaleFactor(1.0),
minWidth(0),
minHeight(0),
- modal(this, ppData)
+ modal(ppData)
{
init(DEFAULT_WIDTH, DEFAULT_HEIGHT, false);
@@ -108,7 +108,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s,
autoScaleFactor(1.0),
minWidth(0),
minHeight(0),
- modal(this)
+ modal()
{
if (isEmbed)
{
@@ -142,7 +142,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s,
autoScaleFactor(1.0),
minWidth(0),
minHeight(0),
- modal(this)
+ modal()
{
if (isEmbed)
{
diff --git a/dgl/src/WindowPrivateData.hpp b/dgl/src/WindowPrivateData.hpp
@@ -70,19 +70,18 @@ struct Window::PrivateData : IdleCallback {
/** Modal window setup. */
struct Modal {
-// PrivateData* self; // pointer to PrivateData this Modal class belongs to
PrivateData* parent; // parent of this window (so we can become modal)
PrivateData* child; // child window to give focus to when modal mode is enabled
bool enabled; // wherever modal mode is enabled (only possible if parent != null)
/** Constructor for a non-modal window. */
- Modal(PrivateData* const s) noexcept
+ Modal() noexcept
: parent(nullptr),
child(nullptr),
enabled(false) {}
/** Constructor for a modal window (with a parent). */
- Modal(PrivateData* const s, PrivateData* const p) noexcept
+ Modal(PrivateData* const p) noexcept
: parent(p),
child(nullptr),
enabled(false) {}
diff --git a/distrho/src/DistrhoPluginVST.cpp b/distrho/src/DistrhoPluginVST.cpp
@@ -183,20 +183,8 @@ public:
nullptr, // TODO file request
nullptr,
plugin->getInstancePointer(),
- scaleFactor),
- fShouldCaptureVstKeys(false)
+ scaleFactor)
{
- // FIXME only needed for windows?
-//#ifdef DISTRHO_OS_WINDOWS
- char strBuf[0xff+1];
- std::memset(strBuf, 0, sizeof(char)*(0xff+1));
- hostCallback(audioMasterGetProductString, 0, 0, strBuf);
- d_stdout("Plugin UI running in '%s'", strBuf);
-
- // TODO make a white-list of needed hosts
- if (/*std::strcmp(strBuf, "") == 0*/ true)
- fShouldCaptureVstKeys = true;
-//#endif
}
// -------------------------------------------------------------------
@@ -243,9 +231,6 @@ public:
int handlePluginKeyEvent(const bool down, int32_t index, const intptr_t value)
{
# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
- if (! fShouldCaptureVstKeys)
- return 0;
-
d_stdout("handlePluginKeyEvent %i %i %li\n", down, index, (long int)value);
using namespace DGL_NAMESPACE;
@@ -253,44 +238,87 @@ public:
int special = 0;
switch (value)
{
- // convert some specials to normal keys
+ // convert some VST special values to normal keys
case 1: index = kKeyBackspace; break;
+ case 2: index = '\t'; break;
+ // 3 clear
+ case 4: index = '\r'; break;
case 6: index = kKeyEscape; break;
case 7: index = ' '; break;
+ // 8 next
+ // 17 select
+ // 18 print
+ case 19: index = '\n'; break;
+ // 20 snapshot
case 22: index = kKeyDelete; break;
+ // 23 help
+ case 57: index = '='; break;
+
+ // numpad stuff follows
+ case 24: index = '0'; break;
+ case 25: index = '1'; break;
+ case 26: index = '2'; break;
+ case 27: index = '3'; break;
+ case 28: index = '4'; break;
+ case 29: index = '5'; break;
+ case 30: index = '6'; break;
+ case 31: index = '7'; break;
+ case 32: index = '8'; break;
+ case 33: index = '9'; break;
+ case 34: index = '*'; break;
+ case 35: index = '+'; break;
+ // 36 separator
+ case 37: index = '-'; break;
+ case 38: index = '.'; break;
+ case 39: index = '/'; break;
// handle rest of special keys
- case 40: special = kKeyF1; break;
- case 41: special = kKeyF2; break;
- case 42: special = kKeyF3; break;
- case 43: special = kKeyF4; break;
- case 44: special = kKeyF5; break;
- case 45: special = kKeyF6; break;
- case 46: special = kKeyF7; break;
- case 47: special = kKeyF8; break;
- case 48: special = kKeyF9; break;
- case 49: special = kKeyF10; break;
- case 50: special = kKeyF11; break;
- case 51: special = kKeyF12; break;
- case 11: special = kKeyLeft; break;
- case 12: special = kKeyUp; break;
- case 13: special = kKeyRight; break;
- case 14: special = kKeyDown; break;
- case 15: special = kKeyPageUp; break;
- case 16: special = kKeyPageDown; break;
- case 10: special = kKeyHome; break;
- case 9: special = kKeyEnd; break;
- case 21: special = kKeyInsert; break;
- case 54: special = kKeyShift; break;
- case 55: special = kKeyControl; break;
- case 56: special = kKeyAlt; break;
+ /* these special keys are missing:
+ - kKeySuper
+ - kKeyMenu
+ - kKeyCapsLock
+ - kKeyPrintScreen
+ */
+ case 40: special = kKeyF1; break;
+ case 41: special = kKeyF2; break;
+ case 42: special = kKeyF3; break;
+ case 43: special = kKeyF4; break;
+ case 44: special = kKeyF5; break;
+ case 45: special = kKeyF6; break;
+ case 46: special = kKeyF7; break;
+ case 47: special = kKeyF8; break;
+ case 48: special = kKeyF9; break;
+ case 49: special = kKeyF10; break;
+ case 50: special = kKeyF11; break;
+ case 51: special = kKeyF12; break;
+ case 11: special = kKeyLeft; break;
+ case 12: special = kKeyUp; break;
+ case 13: special = kKeyRight; break;
+ case 14: special = kKeyDown; break;
+ case 15: special = kKeyPageUp; break;
+ case 16: special = kKeyPageDown; break;
+ case 10: special = kKeyHome; break;
+ case 9: special = kKeyEnd; break;
+ case 21: special = kKeyInsert; break;
+ case 54: special = kKeyShift; break;
+ case 55: special = kKeyControl; break;
+ case 56: special = kKeyAlt; break;
+ case 52: special = kKeyNumLock; break;
+ case 53: special = kKeyScrollLock; break;
+ case 5: special = kKeyPause; break;
}
if (special != 0)
- return fUI.handlePluginSpecial(down, static_cast<Key>(special));
+ {
+ fUI.handlePluginSpecial(down, static_cast<Key>(special));
+ return 1;
+ }
- if (index >= 0)
- return fUI.handlePluginKeyboard(down, static_cast<uint>(index));
+ if (index > 0)
+ {
+ fUI.handlePluginKeyboard(down, static_cast<uint>(index));
+ return 1;
+ }
# endif
return 0;
@@ -360,7 +388,6 @@ private:
// Plugin UI
UIExporter fUI;
- bool fShouldCaptureVstKeys;
// -------------------------------------------------------------------
// Callbacks
diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp
@@ -408,7 +408,7 @@ public:
fChangingSize = false;
}
- void setWindowTransientWinId(const uintptr_t winId)
+ void setWindowTransientWinId(const uintptr_t /*winId*/)
{
#if 0 /* TODO */
glWindow.setTransientWinId(winId);
@@ -422,18 +422,20 @@ public:
return ! glApp.isQuiting();
}
- bool handlePluginKeyboard(const bool press, const uint key)
+ bool handlePluginKeyboard(const bool /*press*/, const uint /*key*/)
{
#if 0 /* TODO */
return glWindow.handlePluginKeyboard(press, key);
#endif
+ return false;
}
- bool handlePluginSpecial(const bool press, const DGL_NAMESPACE::Key key)
+ bool handlePluginSpecial(const bool /*press*/, const DGL_NAMESPACE::Key /*key*/)
{
#if 0 /* TODO */
return glWindow.handlePluginSpecial(press, key);
#endif
+ return false;
}
#endif