diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-06-17 12:28:15 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-06-25 12:39:14 +0200 |
commit | 186354ee513b13dafa77978cb4c10321950600de (patch) | |
tree | 208a444ed245182998003f6090d2ff494f33c9b8 /src/platformsupport/input | |
parent | 27dc07fa050b5f216516debcd11802530a0c2d79 (diff) |
Add a way to access loadKeymap on eglfs
[ChangeLog][QtGui] Keymaps are now changeable at runtime when using eglfs
Task-number: QTBUG-39583
Change-Id: I93480da72c1d1d1db1914298fe624cae02b0b2d0
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Reviewed-by: Will Wagner <willw@carallon.com>
Diffstat (limited to 'src/platformsupport/input')
4 files changed, 38 insertions, 6 deletions
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index 0841544208..72de73db7e 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -93,13 +93,15 @@ QEvdevKeyboardHandler::~QEvdevKeyboardHandler() qt_safe_close(m_fd); } -QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device, const QString &specification) +QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device, + const QString &specification, + const QString &defaultKeymapFile) { #ifdef QT_QPA_KEYMAP_DEBUG qWarning() << "Try to create keyboard handler for" << device << specification; #endif - QString keymapFile; + QString keymapFile = defaultKeymapFile; int repeatDelay = 400; int repeatRate = 80; bool disableZap = false; diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h index 1065b05d51..164b1c3863 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h @@ -145,7 +145,9 @@ public: SwitchConsoleMask = 0x0000007f }; - static QEvdevKeyboardHandler *create(const QString &device, const QString &specification); + static QEvdevKeyboardHandler *create(const QString &device, + const QString &specification, + const QString &defaultKeymapFile = QString()); static Qt::KeyboardModifiers toQtModifiers(quint8 mod) { @@ -161,13 +163,14 @@ public: return qtmod; } + bool loadKeymap(const QString &file); + void unloadKeymap(); + private slots: void readKeycode(); KeycodeAction processKeycode(quint16 keycode, bool pressed, bool autorepeat); private: - void unloadKeymap(); - bool loadKeymap(const QString &file); void processKeyEvent(int nativecode, int unicode, int qtcode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat); void switchLed(int, bool); diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp index 4932087c5f..4ceaf98055 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp @@ -113,7 +113,7 @@ void QEvdevKeyboardManager::addKeyboard(const QString &deviceNode) #endif QEvdevKeyboardHandler *keyboard; - keyboard = QEvdevKeyboardHandler::create(deviceNode, m_spec); + keyboard = QEvdevKeyboardHandler::create(deviceNode, m_spec, m_defaultKeymapFile); if (keyboard) m_keyboards.insert(deviceNode, keyboard); else @@ -132,4 +132,28 @@ void QEvdevKeyboardManager::removeKeyboard(const QString &deviceNode) } } +void QEvdevKeyboardManager::loadKeymap(const QString &file) +{ + m_defaultKeymapFile = file; + + if (file.isEmpty()) { + // Restore the default, which is either the built-in keymap or + // the one given in the plugin spec. + QString keymapFromSpec; + foreach (const QString &arg, m_spec.split(QLatin1Char(':'))) { + if (arg.startsWith(QLatin1String("keymap="))) + keymapFromSpec = arg.mid(7); + } + foreach (QEvdevKeyboardHandler *handler, m_keyboards) { + if (keymapFromSpec.isEmpty()) + handler->unloadKeymap(); + else + handler->loadKeymap(keymapFromSpec); + } + } else { + foreach (QEvdevKeyboardHandler *handler, m_keyboards) + handler->loadKeymap(file); + } +} + QT_END_NAMESPACE diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h index 37c60c035c..e7a07f17a4 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h @@ -59,6 +59,8 @@ public: QEvdevKeyboardManager(const QString &key, const QString &specification, QObject *parent = 0); ~QEvdevKeyboardManager(); + void loadKeymap(const QString &file); + private slots: void addKeyboard(const QString &deviceNode = QString()); void removeKeyboard(const QString &deviceNode); @@ -67,6 +69,7 @@ private: QString m_spec; QHash<QString,QEvdevKeyboardHandler*> m_keyboards; QDeviceDiscovery *m_deviceDiscovery; + QString m_defaultKeymapFile; }; QT_END_NAMESPACE |