5#include <QtCore/QLoggingCategory>
6#include <QtGui/private/qguiapplication_p.h>
7#include <QtGui/private/qinputdevicemanager_p.h>
8#include <qpa/qwindowsysteminterface.h>
10#if QT_CONFIG(xkbcommon)
11#include <xkbcommon/xkbcommon-keysyms.h>
12#include <xkbcommon/xkbcommon-names.h>
13#include <QtGui/private/qxkbcommon_p.h>
25#if QT_CONFIG(xkbcommon)
26 qCDebug(qLcLibInput) <<
"Using xkbcommon for key mapping";
27 m_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
29 qWarning(
"Failed to create xkb context");
32 m_keymap = xkb_keymap_new_from_names(m_ctx,
nullptr, XKB_KEYMAP_COMPILE_NO_FLAGS);
34 qCWarning(qLcLibInput,
"Failed to compile keymap");
37 m_state = xkb_state_new(m_keymap);
39 qCWarning(qLcLibInput,
"Failed to create xkb state");
43 m_repeatTimer.setSingleShot(
true);
46 qCWarning(qLcLibInput) <<
"xkbcommon not available, not performing key mapping";
52#if QT_CONFIG(xkbcommon)
54 xkb_state_unref(m_state);
56 xkb_keymap_unref(m_keymap);
58 xkb_context_unref(m_ctx);
64#if QT_CONFIG(xkbcommon)
65 if (!m_ctx || !m_keymap || !m_state)
68 const uint32_t keycode = libinput_event_keyboard_get_key(
e) + 8;
69 const xkb_keysym_t sym = xkb_state_key_get_one_sym(m_state, keycode);
70 const bool pressed = libinput_event_keyboard_get_key_state(
e) == LIBINPUT_KEY_STATE_PRESSED;
80 xkb_state_update_key(m_state, keycode, pressed ? XKB_KEY_DOWN : XKB_KEY_UP);
89 if (pressed && xkb_keymap_key_repeats(m_keymap, keycode)) {
90 m_repeatData.qtkey = qtkey;
92 m_repeatData.nativeScanCode = keycode;
93 m_repeatData.virtualKey = sym;
95 m_repeatData.unicodeText =
text;
96 m_repeatData.repeatCount = 1;
98 m_repeatTimer.start();
99 }
else if (m_repeatTimer.isActive()) {
100 m_repeatTimer.stop();
108#if QT_CONFIG(xkbcommon)
109void QLibInputKeyboard::handleRepeat()
112 m_repeatData.qtkey, m_repeatData.mods,
113 m_repeatData.nativeScanCode, m_repeatData.virtualKey, m_repeatData.nativeMods,
114 m_repeatData.unicodeText,
true, m_repeatData.repeatCount);
115 m_repeatData.repeatCount += 1;
117 m_repeatTimer.start();
static QInputDeviceManager * inputDeviceManager()
\macro QT_RESTRICTED_CAST_FROM_ASCII
void timeout(QPrivateSignal)
This signal is emitted when the timer times out.
static bool handleExtendedKeyEvent(QWindow *window, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
static QString lookupString(struct xkb_state *state, xkb_keycode_t code)
static Qt::KeyboardModifiers modifiers(struct xkb_state *state, xkb_keysym_t keysym=XKB_KEY_VoidSymbol)
static int keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers)
EGLImageKHR int int EGLuint64KHR * modifiers
Combined button and popup list for selecting options.
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)