Move IKeyboard and subclasses to new library BlackInput

refs #256
This commit is contained in:
Roland Winklmeier
2014-06-04 14:23:14 +02:00
committed by Roland Winklmeier
parent 14e9e01b90
commit a131e8c91c
25 changed files with 105 additions and 65 deletions

View File

@@ -9,6 +9,10 @@ contains(BLACK_CONFIG, BlackSound) {
SUBDIRS += src/blacksound SUBDIRS += src/blacksound
} }
contains(BLACK_CONFIG, BlackInput) {
SUBDIRS += src/blackinput
}
contains(BLACK_CONFIG, BlackSim) { contains(BLACK_CONFIG, BlackSim) {
SUBDIRS += src/blacksim SUBDIRS += src/blacksim
} }

View File

@@ -23,6 +23,7 @@ DEFINES += BLACK_VERSION=$$BLACK_VERSION
BLACK_CONFIG += BlackCore BLACK_CONFIG += BlackCore
BLACK_CONFIG += BlackGui BLACK_CONFIG += BlackGui
BLACK_CONFIG += BlackSound BLACK_CONFIG += BlackSound
BLACK_CONFIG += BlackInput
BLACK_CONFIG += BlackSim BLACK_CONFIG += BlackSim
BLACK_CONFIG += Samples BLACK_CONFIG += Samples
BLACK_CONFIG += Unittests BLACK_CONFIG += Unittests
@@ -35,6 +36,7 @@ BLACK_CONFIG += FSX
################################ ################################
contains(BLACK_CONFIG, BlackSound) { DEFINES += WITH_BLACKSOUND } contains(BLACK_CONFIG, BlackSound) { DEFINES += WITH_BLACKSOUND }
contains(BLACK_CONFIG, BlackInput) { DEFINES += WITH_BLACKINPUT }
contains(BLACK_CONFIG, BlackSim) { DEFINES += WITH_BLACKSIM } contains(BLACK_CONFIG, BlackSim) { DEFINES += WITH_BLACKSIM }
contains(BLACK_CONFIG, BlackCore) { DEFINES += WITH_BLACKCORE } contains(BLACK_CONFIG, BlackCore) { DEFINES += WITH_BLACKCORE }
contains(BLACK_CONFIG, BlackGui) { DEFINES += WITH_BLACKGUI } contains(BLACK_CONFIG, BlackGui) { DEFINES += WITH_BLACKGUI }

View File

@@ -20,6 +20,10 @@ blacksound {
LIBS += -lblacksound LIBS += -lblacksound
} }
blackinput {
LIBS += -lblackinput
}
blacksim { blacksim {
LIBS += -lblacksim LIBS += -lblacksim
} }

View File

@@ -10,7 +10,7 @@ TEMPLATE = app
CONFIG += console CONFIG += console
CONFIG -= app_bundle CONFIG -= app_bundle
CONFIG += blackmisc blacksound blackcore blacksim CONFIG += blackmisc blacksound blackinput blackcore blacksim
DEPENDPATH += . ../../src/blackmisc ../../src/blacksound ../../src/blackcore ../../src/blacksim DEPENDPATH += . ../../src/blackmisc ../../src/blacksound ../../src/blackcore ../../src/blacksim
INCLUDEPATH += . ../../src INCLUDEPATH += . ../../src

View File

@@ -12,7 +12,7 @@
#include "infowindow.h" #include "infowindow.h"
#include "guimodeenums.h" #include "guimodeenums.h"
#include "blackcore/keyboard.h" #include "blackinput/keyboard.h"
#include "blackcore/context_audio.h" #include "blackcore/context_audio.h"
#include "blackcore/context_network.h" #include "blackcore/context_network.h"
#include "blackcore/context_settings.h" #include "blackcore/context_settings.h"
@@ -132,7 +132,7 @@ private:
QLabel *m_statusBarLabel; /*!< status bar label */ QLabel *m_statusBarLabel; /*!< status bar label */
// Hotkeys // Hotkeys
BlackCore::IKeyboard *m_keyboard; BlackInput::IKeyboard *m_keyboard;
//! GUI status update //! GUI status update
void updateGuiStatusInformation(); void updateGuiStatusInformation();

View File

@@ -320,7 +320,7 @@ void MainWindow::setHotkeys()
Q_ASSERT(this->getIContextSettings()); Q_ASSERT(this->getIContextSettings());
if (!this->m_keyboard) if (!this->m_keyboard)
{ {
this->m_keyboard = BlackCore::IKeyboard::getInstance(); this->m_keyboard = BlackInput::IKeyboard::getInstance();
} }
else else
{ {

View File

@@ -10,7 +10,7 @@ TEMPLATE = app
SOURCES += *.cpp SOURCES += *.cpp
HEADERS += *.h HEADERS += *.h
FORMS += *.ui FORMS += *.ui
CONFIG += blackmisc blacksound blackcore blackgui blacksim CONFIG += blackmisc blacksound blackinput blackcore blackgui blacksim
DEPENDPATH += . ../../src/blackmisc ../../src/blackgui ../../src/blacksound ../../src/blacksim ../../src/blackcore DEPENDPATH += . ../../src/blackmisc ../../src/blackgui ../../src/blacksound ../../src/blacksim ../../src/blackcore
INCLUDEPATH += . ../../src INCLUDEPATH += . ../../src

View File

@@ -16,7 +16,7 @@ HotkeyDialog::HotkeyDialog(QWidget *parent) :
m_lblHotkey(nullptr), m_lblHotkey(nullptr),
m_led(nullptr) m_led(nullptr)
{ {
m_keyboard = BlackCore::IKeyboard::getInstance(); m_keyboard = BlackInput::IKeyboard::getInstance();
setupUi(); setupUi();
setupConnections(); setupConnections();
@@ -87,7 +87,7 @@ void HotkeyDialog::setupUi()
} }
void HotkeyDialog::setupConnections() void HotkeyDialog::setupConnections()
{ {
connect(m_keyboard, &BlackCore::IKeyboard::keySelectionChanged, this, &HotkeyDialog::keySelectionChanged); connect(m_keyboard, &BlackInput::IKeyboard::keySelectionChanged, this, &HotkeyDialog::keySelectionChanged);
connect(m_keyboard, &BlackCore::IKeyboard::keySelectionFinished, this, &HotkeyDialog::keySelectionFinished); connect(m_keyboard, &BlackInput::IKeyboard::keySelectionFinished, this, &HotkeyDialog::keySelectionFinished);
connect(m_pbSelect, &QPushButton::clicked, this, &HotkeyDialog::selectHotKey); connect(m_pbSelect, &QPushButton::clicked, this, &HotkeyDialog::selectHotKey);
} }

View File

@@ -7,7 +7,7 @@
#define BLACKSAMPLE_HOTKEY_H #define BLACKSAMPLE_HOTKEY_H
#include "led.h" #include "led.h"
#include "blackcore/keyboard.h" #include "blackinput/keyboard.h"
#include "blackmisc/hwkeyboardkey.h" #include "blackmisc/hwkeyboardkey.h"
#include <QDialog> #include <QDialog>
@@ -57,7 +57,7 @@ private:
void setupUi(); void setupUi();
void setupConnections(); void setupConnections();
BlackCore::IKeyboard *m_keyboard; BlackInput::IKeyboard *m_keyboard;
QPushButton *m_pbSelect; QPushButton *m_pbSelect;
QLabel *m_lblHotkey; QLabel *m_lblHotkey;
CLed *m_led; CLed *m_led;

View File

@@ -9,7 +9,7 @@ TARGET = sample_hotkey
TEMPLATE = app TEMPLATE = app
CONFIG -= app_bundle CONFIG -= app_bundle
CONFIG += blackmisc blackcore CONFIG += blackmisc blackinput blackcore
DEPENDPATH += . ../../src DEPENDPATH += . ../../src
INCLUDEPATH += . ../../src INCLUDEPATH += . ../../src

View File

@@ -8,7 +8,7 @@ QT += network dbus xml multimedia
TARGET = blackcore TARGET = blackcore
TEMPLATE = lib TEMPLATE = lib
CONFIG += staticlib CONFIG += staticlib
CONFIG += blackmisc blacksim CONFIG += blackmisc blackinput blacksim
INCLUDEPATH += .. INCLUDEPATH += ..
DEPENDPATH += . .. DEPENDPATH += . ..
@@ -25,21 +25,6 @@ DEFINES += LOG_IN_FILE
HEADERS += *.h HEADERS += *.h
SOURCES += *.cpp SOURCES += *.cpp
win32 {
HEADERS += $$PWD/win/*.h
SOURCES += $$PWD/win/*.cpp
}
unix:!macx {
HEADERS += $$PWD/linux/*.h
SOURCES += $$PWD/linux/*.cpp
}
macx {
HEADERS += $$PWD/mac/*.h
SOURCES += $$PWD/mac/*.cpp
}
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib ../../lib/blacksound.lib ../../lib/blacksim.lib win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib ../../lib/blacksound.lib ../../lib/blacksim.lib
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a ../../lib/libblacksound.a ../../lib/libblacksim.a else: PRE_TARGETDEPS += ../../lib/libblackmisc.a ../../lib/libblacksound.a ../../lib/libblacksim.a

View File

@@ -34,8 +34,7 @@ namespace BlackCore
m_voice->moveToThread(&m_threadVoice); m_voice->moveToThread(&m_threadVoice);
m_threadVoice.start(); m_threadVoice.start();
// 2. Hotkeys m_keyboard = BlackInput::IKeyboard::getInstance();
m_keyboard = IKeyboard::getInstance();
// 3. own aircraft, if possible // 3. own aircraft, if possible
if (this->getIContextOwnAircraft()) m_voice->setMyAircraftCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign()); if (this->getIContextOwnAircraft()) m_voice->setMyAircraftCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());

View File

@@ -11,7 +11,7 @@
#include "context_runtime.h" #include "context_runtime.h"
#include "dbus_server.h" #include "dbus_server.h"
#include "voice_vatlib.h" #include "voice_vatlib.h"
#include "blackcore/keyboard.h" #include "blackinput/keyboard.h"
#include <QThread> #include <QThread>
#include <QQueue> #include <QQueue>
@@ -127,8 +127,8 @@ namespace BlackCore
bool inTransitionState() const; bool inTransitionState() const;
CVoiceVatlib *m_voice; //!< underlying voice lib CVoiceVatlib *m_voice; //!< underlying voice lib
IKeyboard *m_keyboard; BlackInput::IKeyboard *m_keyboard;
IKeyboard::RegistrationHandle m_handlePtt; BlackInput::IKeyboard::RegistrationHandle m_handlePtt;
QThread m_threadVoice; QThread m_threadVoice;
}; };
} }

View File

@@ -8,7 +8,7 @@
#include "blackcore/context.h" #include "blackcore/context.h"
#include "blackcore/dbus_server.h" #include "blackcore/dbus_server.h"
#include "blackcore/keyboard.h" #include "blackinput/keyboard.h"
#include "blackmisc/hwkeyboardkeylist.h" #include "blackmisc/hwkeyboardkeylist.h"
#include "blackmisc/statusmessagelist.h" #include "blackmisc/statusmessagelist.h"
#include "blackmisc/settingutilities.h" #include "blackmisc/settingutilities.h"

View File

@@ -0,0 +1,46 @@
include (../../config.pri)
include (../../build.pri)
QT += network dbus gui multimedia
TARGET = blackinput
TEMPLATE = lib
CONFIG += staticlib
CONFIG += blackmisc
INCLUDEPATH += ..
DEPENDPATH += . ..
# PRECOMPILED_HEADER = stdpch.h
precompile_header:!isEmpty(PRECOMPILED_HEADER) {
DEFINES += USING_PCH
}
DEFINES += LOG_IN_FILE
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a
HEADERS += *.h
SOURCES += *.cpp
win32 {
HEADERS += $$PWD/win/*.h
SOURCES += $$PWD/win/*.cpp
}
unix:!macx {
HEADERS += $$PWD/linux/*.h
SOURCES += $$PWD/linux/*.cpp
}
macx {
HEADERS += $$PWD/osx/*.h
SOURCES += $$PWD/osx/*.cpp
}
DESTDIR = ../../lib
OTHER_FILES +=
RESOURCES +=
include (../../libraries.pri)

View File

@@ -6,16 +6,16 @@
#include "keyboard.h" #include "keyboard.h"
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#include "blackcore/win/keyboard_windows.h" #include "win/keyboard_windows.h"
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
#include "blackcore/linux/keyboard_linux.h" #include "linux/keyboard_linux.h"
#elif defined(Q_OS_OSX) #elif defined(Q_OS_OSX)
#include "blackcore/mac/keyboard_mac.h" #include "osx/keyboard_mac.h"
#else #else
#error "Platform is not supported!" #error "Platform is not supported!"
#endif #endif
namespace BlackCore namespace BlackInput
{ {
IKeyboard *IKeyboard::m_instance = nullptr; IKeyboard *IKeyboard::m_instance = nullptr;
@@ -49,4 +49,4 @@ namespace BlackCore
return false; return false;
} }
} // BlackCore } // BlackInput

View File

@@ -7,8 +7,8 @@
\file \file
*/ */
#ifndef BLACKCORE_KEYBOARD_H #ifndef BLACKINPUT_KEYBOARD_H
#define BLACKCORE_KEYBOARD_H #define BLACKINPUT_KEYBOARD_H
#include "../blackmisc/hwkeyboardkey.h" #include "../blackmisc/hwkeyboardkey.h"
#include <QMultiMap> #include <QMultiMap>
@@ -16,7 +16,7 @@
#include <QPointer> #include <QPointer>
#include <functional> #include <functional>
namespace BlackCore namespace BlackInput
{ {
/*! /*!
* \brief Abstract interface for native keyboard handling. * \brief Abstract interface for native keyboard handling.
@@ -181,4 +181,4 @@ namespace BlackCore
bool operator==(IKeyboard::RegistrationHandle const &lhs, IKeyboard::RegistrationHandle const &rhs); bool operator==(IKeyboard::RegistrationHandle const &lhs, IKeyboard::RegistrationHandle const &rhs);
} }
#endif // BLACKCORE_KEYBOARD_H #endif // BLACKINPUT_KEYBOARD_H

View File

@@ -8,7 +8,7 @@
using namespace BlackMisc::Hardware; using namespace BlackMisc::Hardware;
namespace BlackCore namespace BlackInput
{ {
CKeyboardLinux::CKeyboardLinux(QObject *parent) : CKeyboardLinux::CKeyboardLinux(QObject *parent) :
IKeyboard(parent), IKeyboard(parent),

View File

@@ -7,14 +7,14 @@
\file \file
*/ */
#ifndef BLACKCORE_KEYBOARD_LINUX_H #ifndef BLACKINPUT_KEYBOARD_LINUX_H
#define BLACKCORE_KEYBOARD_LINUX_H #define BLACKINPUT_KEYBOARD_LINUX_H
#include "blackcore/keyboard.h" #include "blackinput/keyboard.h"
#include "blackmisc/hwkeyboardkey.h" #include "blackmisc/hwkeyboardkey.h"
#include <QHash> #include <QHash>
namespace BlackCore namespace BlackInput
{ {
//! \brief Linux implemenation of IKeyboard using hook procedure //! \brief Linux implemenation of IKeyboard using hook procedure
//! \todo Change QHash to a CCollection object //! \todo Change QHash to a CCollection object
@@ -84,4 +84,4 @@ namespace BlackCore
}; };
} }
#endif // BLACKCORE_KEYBOARD_LINUX_H #endif // BLACKINPUT_KEYBOARD_LINUX_H

View File

@@ -8,7 +8,7 @@
using namespace BlackMisc::Hardware; using namespace BlackMisc::Hardware;
namespace BlackCore namespace BlackInput
{ {
CKeyboardMac::CKeyboardMac(QObject *parent) : CKeyboardMac::CKeyboardMac(QObject *parent) :
IKeyboard(parent), IKeyboard(parent),

View File

@@ -7,14 +7,14 @@
\file \file
*/ */
#ifndef BLACKCORE_KEYBOARD_MAC_H #ifndef BLACKINPUT_KEYBOARD_MAC_H
#define BLACKCORE_KEYBOARD_MAC_H #define BLACKINPUT_KEYBOARD_MAC_H
#include "blackcore/keyboard.h" #include "blackinput/keyboard.h"
#include "blackmisc/hwkeyboardkey.h" #include "blackmisc/hwkeyboardkey.h"
#include <QHash> #include <QHash>
namespace BlackCore namespace BlackInput
{ {
//! \brief Linux implemenation of IKeyboard using hook procedure //! \brief Linux implemenation of IKeyboard using hook procedure
//! \todo Change QHash to a CCollection object //! \todo Change QHash to a CCollection object
@@ -84,4 +84,4 @@ namespace BlackCore
}; };
} }
#endif // BLACKCORE_KEYBOARD_MAC_H #endif // BLACKINPUT_KEYBOARD_MAC_H

View File

@@ -9,7 +9,7 @@
using namespace BlackMisc::Hardware; using namespace BlackMisc::Hardware;
namespace BlackCore namespace BlackInput
{ {
CKeyboardWindows::CKeyboardWindows(QObject *parent) : CKeyboardWindows::CKeyboardWindows(QObject *parent) :
IKeyboard(parent), IKeyboard(parent),

View File

@@ -7,10 +7,10 @@
\file \file
*/ */
#ifndef BLACKCORE_KEYBOARD_WINDOWS_H #ifndef BLACKINPUT_KEYBOARD_WINDOWS_H
#define BLACKCORE_KEYBOARD_WINDOWS_H #define BLACKINPUT_KEYBOARD_WINDOWS_H
#include "blackcore/keyboard.h" #include "blackinput/keyboard.h"
#include "blackmisc/hwkeyboardkey.h" #include "blackmisc/hwkeyboardkey.h"
#include <QHash> #include <QHash>
#ifndef NOMINMAX #ifndef NOMINMAX
@@ -18,7 +18,7 @@
#endif #endif
#include <windows.h> #include <windows.h>
namespace BlackCore namespace BlackInput
{ {
//! \brief Windows implemenation of IKeyboard using hook procedure //! \brief Windows implemenation of IKeyboard using hook procedure
//! \todo Change QHash to a CCollection object //! \todo Change QHash to a CCollection object
@@ -107,4 +107,4 @@ namespace BlackCore
}; };
} }
#endif // BLACKCORE_KEYBOARD_WINDOWS_H #endif // BLACKINPUT_KEYBOARD_WINDOWS_H

View File

@@ -13,7 +13,7 @@
using namespace BlackMisc::Hardware; using namespace BlackMisc::Hardware;
namespace BlackCore namespace BlackInput
{ {
Qt::Key CKeyMappingWindows::convertToKey(WPARAM virtualKey) Qt::Key CKeyMappingWindows::convertToKey(WPARAM virtualKey)
{ {

View File

@@ -4,8 +4,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef BLACKCORE_KEYMAPPING_WINDOWS_H #ifndef BLACKINPUT_KEYMAPPING_WINDOWS_H
#define BLACKCORE_KEYMAPPING_WINDOWS_H #define BLACKINPUT_KEYMAPPING_WINDOWS_H
#include "blackmisc/hwkeyboardkey.h" #include "blackmisc/hwkeyboardkey.h"
#ifndef NOMINMAX #ifndef NOMINMAX
@@ -13,7 +13,7 @@
#endif #endif
#include <windows.h> #include <windows.h>
namespace BlackCore namespace BlackInput
{ {
//! \brief This class provides methods to map between windows virtual keys and CKeyboardKey //! \brief This class provides methods to map between windows virtual keys and CKeyboardKey
class CKeyMappingWindows class CKeyMappingWindows
@@ -41,5 +41,5 @@ namespace BlackCore
static bool isModifier(WPARAM vkcode); static bool isModifier(WPARAM vkcode);
}; };
} // namespace BlackCore } // namespace BlackInput
#endif // guard #endif // guard