From bdd7de1459414ece6476511389765e40bd5b64df Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Wed, 20 Aug 2014 01:29:58 +0200 Subject: [PATCH] refs #318 Let CInputManager forward HotkeyFunc events --- src/blackcore/input_manager.cpp | 3 +++ src/blackcore/input_manager.h | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/blackcore/input_manager.cpp b/src/blackcore/input_manager.cpp index bfe26321d..8fd4b8a3d 100644 --- a/src/blackcore/input_manager.cpp +++ b/src/blackcore/input_manager.cpp @@ -87,6 +87,9 @@ namespace BlackCore void CInputManager::callFunctionsBy(const CHotkeyFunction &hotkeyFunction, bool isKeyDown) { + BlackMisc::Event::CEventHotkeyFunction hotkeyEvent(hotkeyFunction, isKeyDown); + if(m_eventForwardingEnabled) emit hotkeyFuncEvent(hotkeyEvent); + if (!m_hashRegisteredFunctions.contains(hotkeyFunction)) return; auto func = m_hashRegisteredFunctions.value(hotkeyFunction); func(isKeyDown); diff --git a/src/blackcore/input_manager.h b/src/blackcore/input_manager.h index fe9455b75..dad0144e3 100644 --- a/src/blackcore/input_manager.h +++ b/src/blackcore/input_manager.h @@ -12,6 +12,7 @@ #include "blackmisc/hwjoystickbutton.h" #include "blackmisc/hotkeyfunction.h" #include "blackmisc/setkeyboardhotkeylist.h" +#include "blackmisc/eveventhotkeyfunction.h" #include #include #include @@ -65,6 +66,9 @@ namespace BlackCore //! Deletes all registered hotkeys. Be careful with this method! void resetAllHotkeyFuncs() { m_hashRegisteredFunctions.clear(); } + //! Enable event forwarding to core + void setEventForwarding(bool enabled) { m_eventForwardingEnabled = enabled; } + //! Creates a native keyboard handler object static CInputManager *getInstance(); @@ -76,6 +80,11 @@ namespace BlackCore //! Call functions by hotkeyfunction void callFunctionsBy(const BlackMisc::CHotkeyFunction &hotkeyFunction, bool isKeyDown); + signals: + + //! Event hotkeyfunction occured + void hotkeyFuncEvent(const BlackMisc::Event::CEventHotkeyFunction &event); + protected: //! Constructor CInputManager(QObject *parent = nullptr); @@ -102,6 +111,8 @@ namespace BlackCore QHash > m_hashRegisteredFunctions; QHash m_hashKeyboardKeyFunctions; QHash m_hashJoystickKeyFunctions; + + bool m_eventForwardingEnabled = false; }; }