mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 10:45:37 +08:00
refs #318 Let CInputManager forward HotkeyFunc events
This commit is contained in:
@@ -87,6 +87,9 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CInputManager::callFunctionsBy(const CHotkeyFunction &hotkeyFunction, bool isKeyDown)
|
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;
|
if (!m_hashRegisteredFunctions.contains(hotkeyFunction)) return;
|
||||||
auto func = m_hashRegisteredFunctions.value(hotkeyFunction);
|
auto func = m_hashRegisteredFunctions.value(hotkeyFunction);
|
||||||
func(isKeyDown);
|
func(isKeyDown);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "blackmisc/hwjoystickbutton.h"
|
#include "blackmisc/hwjoystickbutton.h"
|
||||||
#include "blackmisc/hotkeyfunction.h"
|
#include "blackmisc/hotkeyfunction.h"
|
||||||
#include "blackmisc/setkeyboardhotkeylist.h"
|
#include "blackmisc/setkeyboardhotkeylist.h"
|
||||||
|
#include "blackmisc/eveventhotkeyfunction.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@@ -65,6 +66,9 @@ namespace BlackCore
|
|||||||
//! Deletes all registered hotkeys. Be careful with this method!
|
//! Deletes all registered hotkeys. Be careful with this method!
|
||||||
void resetAllHotkeyFuncs() { m_hashRegisteredFunctions.clear(); }
|
void resetAllHotkeyFuncs() { m_hashRegisteredFunctions.clear(); }
|
||||||
|
|
||||||
|
//! Enable event forwarding to core
|
||||||
|
void setEventForwarding(bool enabled) { m_eventForwardingEnabled = enabled; }
|
||||||
|
|
||||||
//! Creates a native keyboard handler object
|
//! Creates a native keyboard handler object
|
||||||
static CInputManager *getInstance();
|
static CInputManager *getInstance();
|
||||||
|
|
||||||
@@ -76,6 +80,11 @@ namespace BlackCore
|
|||||||
//! Call functions by hotkeyfunction
|
//! Call functions by hotkeyfunction
|
||||||
void callFunctionsBy(const BlackMisc::CHotkeyFunction &hotkeyFunction, bool isKeyDown);
|
void callFunctionsBy(const BlackMisc::CHotkeyFunction &hotkeyFunction, bool isKeyDown);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
//! Event hotkeyfunction occured
|
||||||
|
void hotkeyFuncEvent(const BlackMisc::Event::CEventHotkeyFunction &event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CInputManager(QObject *parent = nullptr);
|
CInputManager(QObject *parent = nullptr);
|
||||||
@@ -102,6 +111,8 @@ namespace BlackCore
|
|||||||
QHash<BlackMisc::CHotkeyFunction, std::function<void(bool)> > m_hashRegisteredFunctions;
|
QHash<BlackMisc::CHotkeyFunction, std::function<void(bool)> > m_hashRegisteredFunctions;
|
||||||
QHash<BlackMisc::Hardware::CKeyboardKey, BlackMisc::CHotkeyFunction> m_hashKeyboardKeyFunctions;
|
QHash<BlackMisc::Hardware::CKeyboardKey, BlackMisc::CHotkeyFunction> m_hashKeyboardKeyFunctions;
|
||||||
QHash<BlackMisc::Hardware::CJoystickButton, BlackMisc::CHotkeyFunction> m_hashJoystickKeyFunctions;
|
QHash<BlackMisc::Hardware::CJoystickButton, BlackMisc::CHotkeyFunction> m_hashJoystickKeyFunctions;
|
||||||
|
|
||||||
|
bool m_eventForwardingEnabled = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user