mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-20 01:14:20 +00:00
Workaround for keypresses in plugins in Ableton live.
This commit is contained in:
parent
ce3ecc752b
commit
ee2f57ce88
1 changed files with 50 additions and 0 deletions
|
|
@ -206,6 +206,52 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static HHOOK keyboardHook = 0;
|
||||
static int keyboardHookUsers = 0;
|
||||
|
||||
LRESULT CALLBACK keyboardHookCallback (int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (nCode == 0)
|
||||
{
|
||||
const MSG& msg = *(const MSG*) lParam;
|
||||
|
||||
if (msg.message == WM_CHAR)
|
||||
{
|
||||
Desktop& desktop = Desktop::getInstance();
|
||||
HWND focused = GetFocus();
|
||||
|
||||
for (int i = desktop.getNumComponents(); --i >= 0;)
|
||||
{
|
||||
if ((HWND) desktop.getComponent (i)->getWindowHandle() == focused)
|
||||
{
|
||||
SendMessage (focused, msg.message, msg.wParam, msg.lParam);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CallNextHookEx (mouseWheelHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
void registerKeyboardHook()
|
||||
{
|
||||
if (keyboardHookUsers++ == 0)
|
||||
keyboardHook = SetWindowsHookEx (WH_GETMESSAGE, keyboardHookCallback,
|
||||
(HINSTANCE) Process::getCurrentModuleInstanceHandle(),
|
||||
GetCurrentThreadId());
|
||||
}
|
||||
|
||||
void unregisterKeyboardHook()
|
||||
{
|
||||
if (--keyboardHookUsers == 0 && keyboardHook != 0)
|
||||
{
|
||||
UnhookWindowsHookEx (keyboardHook);
|
||||
keyboardHook = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
static bool messageThreadIsDefinitelyCorrect = false;
|
||||
#endif
|
||||
|
|
@ -1291,6 +1337,9 @@ public:
|
|||
addMouseListener (this, true);
|
||||
|
||||
registerMouseWheelHook();
|
||||
|
||||
if (PluginHostType().isAbletonLive())
|
||||
registerKeyboardHook();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1298,6 +1347,7 @@ public:
|
|||
{
|
||||
#if JUCE_WINDOWS
|
||||
unregisterMouseWheelHook();
|
||||
unregisterKeyboardHook();
|
||||
#endif
|
||||
|
||||
deleteAllChildren(); // note that we can't use a ScopedPointer because the editor may
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue