| 1 | // Copyright (C) 2021 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QEVDEVKEYBOARDHANDLER_P_H |
| 5 | #define QEVDEVKEYBOARDHANDLER_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <qobject.h> |
| 19 | #include <qloggingcategory.h> |
| 20 | #include <QtInputSupport/private/qfdcontainer_p.h> |
| 21 | #include <QtInputSupport/private/qkeyboardmap_p.h> |
| 22 | #include <QtInputSupport/private/qkeycodeaction_p.h> |
| 23 | |
| 24 | #include <private/qglobal_p.h> |
| 25 | |
| 26 | #include <memory> |
| 27 | |
| 28 | QT_BEGIN_NAMESPACE |
| 29 | |
| 30 | Q_DECLARE_LOGGING_CATEGORY(qLcEvdevKey) |
| 31 | |
| 32 | class QSocketNotifier; |
| 33 | |
| 34 | class QEvdevKeyboardHandler : public QObject |
| 35 | { |
| 36 | public: |
| 37 | QEvdevKeyboardHandler(const QString &device, QFdContainer &fd, bool disableZap, bool enableCompose, const QString &keymapFile); |
| 38 | ~QEvdevKeyboardHandler(); |
| 39 | |
| 40 | static std::unique_ptr<QEvdevKeyboardHandler> create(const QString &device, |
| 41 | const QString &specification, |
| 42 | const QString &defaultKeymapFile = QString()); |
| 43 | |
| 44 | bool loadKeymap(const QString &file); |
| 45 | void unloadKeymap(); |
| 46 | |
| 47 | void readKeycode(); |
| 48 | QKeycodeAction processKeycode(quint16 keycode, bool pressed, bool autorepeat); |
| 49 | |
| 50 | void switchLang(); |
| 51 | |
| 52 | private: |
| 53 | void processKeyEvent(int nativecode, int unicode, int qtcode, |
| 54 | Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat); |
| 55 | void switchLed(int, bool); |
| 56 | |
| 57 | QString m_device; |
| 58 | QFdContainer m_fd; |
| 59 | QSocketNotifier *m_notify; |
| 60 | |
| 61 | // keymap handling |
| 62 | quint8 m_modifiers; |
| 63 | quint8 m_locks[3]; |
| 64 | int m_composing; |
| 65 | quint16 m_dead_unicode; |
| 66 | quint8 m_langLock; |
| 67 | |
| 68 | bool m_no_zap; |
| 69 | bool m_do_compose; |
| 70 | |
| 71 | const QKeyboardMap::Mapping *m_keymap; |
| 72 | int m_keymap_size; |
| 73 | const QKeyboardMap::Composing *m_keycompose; |
| 74 | int m_keycompose_size; |
| 75 | |
| 76 | static const QKeyboardMap::Mapping s_keymap_default[]; |
| 77 | static const QKeyboardMap::Composing s_keycompose_default[]; |
| 78 | }; |
| 79 | |
| 80 | |
| 81 | QT_END_NAMESPACE |
| 82 | |
| 83 | #endif // QEVDEVKEYBOARDHANDLER_P_H |
| 84 | |