diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index 540c00fdb..e3ae331ee 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -175,6 +175,11 @@ namespace BlackCore // startup done connect(this, &CApplication::startUpCompleted, this, &CApplication::onStartUpCompleted, Qt::QueuedConnection); connect(this, &CApplication::coreFacadeStarted, this, &CApplication::onCoreFacadeStarted, Qt::QueuedConnection); + + if (!this->getApplicationInfo().isUnitTest()) + { + CInputManager::instance()->createDevices(); + } } } diff --git a/src/blackcore/inputmanager.cpp b/src/blackcore/inputmanager.cpp index 9bcfd3c76..141b829cf 100644 --- a/src/blackcore/inputmanager.cpp +++ b/src/blackcore/inputmanager.cpp @@ -25,12 +25,8 @@ using namespace BlackMisc::Input; namespace BlackCore { CInputManager::CInputManager(QObject *parent) : - QObject(parent), - m_keyboard(IKeyboard::create(this)), - m_joystick(IJoystick::create(this)) + QObject(parent) { - connect(m_keyboard.get(), &IKeyboard::keyCombinationChanged, this, &CInputManager::processKeyCombinationChanged, Qt::QueuedConnection); - connect(m_joystick.get(), &IJoystick::buttonCombinationChanged, this, &CInputManager::processButtonCombinationChanged, Qt::QueuedConnection); reloadHotkeySettings(); } @@ -129,6 +125,14 @@ namespace BlackCore m_lastCombination = combination; } + void CInputManager::createDevices() + { + m_keyboard = IKeyboard::create(this); + m_joystick = IJoystick::create(this); + connect(m_keyboard.get(), &IKeyboard::keyCombinationChanged, this, &CInputManager::processKeyCombinationChanged, Qt::QueuedConnection); + connect(m_joystick.get(), &IJoystick::buttonCombinationChanged, this, &CInputManager::processButtonCombinationChanged, Qt::QueuedConnection); + } + void CInputManager::releaseDevices() { m_keyboard.reset(); diff --git a/src/blackcore/inputmanager.h b/src/blackcore/inputmanager.h index e5a2cd952..f2e06e877 100644 --- a/src/blackcore/inputmanager.h +++ b/src/blackcore/inputmanager.h @@ -87,6 +87,9 @@ namespace BlackCore //! Triggers a key event manually and calls the registered functions. void triggerKey(const BlackMisc::Input::CHotkeyCombination &combination, bool isPressed); + //! Creates low level input devices. Once completed, hotkeys start to be processed. + void createDevices(); + //! Releases all devices void releaseDevices();