Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwindowskeymapper.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QWINDOWSKEYMAPPER_H
5#define QWINDOWSKEYMAPPER_H
6
7#include <QtCore/qt_windows.h>
8
9#include <QtCore/qlocale.h>
10
12
13class QKeyEvent;
14class QWindow;
15
16/*
17 \internal
18 A Windows KeyboardLayoutItem has 8 possible states:
19 1. Unmodified
20 2. Shift
21 3. Control
22 4. Control + Shift
23 5. Alt
24 6. Alt + Shift
25 7. Alt + Control
26 8. Alt + Control + Shift
27*/
30 uint exists : 1; // whether this item has been initialized (by updatePossibleKeyCodes)
32 static const size_t NumQtKeys = 9;
33 quint32 qtKey[NumQtKeys]; // Can by any Qt::Key_<foo>, or unicode character
34};
35
37{
38 Q_DISABLE_COPY_MOVE(QWindowsKeyMapper)
39public:
40 explicit QWindowsKeyMapper();
42
43 void changeKeyboard();
44
45 void setUseRTLExtensions(bool e) { m_useRTLExtensions = e; }
46 bool useRTLExtensions() const { return m_useRTLExtensions; }
47
48 void setDetectAltGrModifier(bool a) { m_detectAltGrModifier = a; }
49 bool detectAltGrModifier() const { return m_detectAltGrModifier; }
50
51 bool translateKeyEvent(QWindow *widget, HWND hwnd, const MSG &msg, LRESULT *result);
52
53 QWindow *keyGrabber() const { return m_keyGrabber; }
54 void setKeyGrabber(QWindow *w) { m_keyGrabber = w; }
55
56 static Qt::KeyboardModifiers queryKeyboardModifiers();
57 QList<int> possibleKeys(const QKeyEvent *e) const;
58
59private:
60 bool translateKeyEventInternal(QWindow *receiver, MSG msg, bool grab, LRESULT *lResult);
61 bool translateMultimediaKeyEventInternal(QWindow *receiver, const MSG &msg);
62 void updateKeyMap(const MSG &msg);
63
64 bool m_useRTLExtensions;
65
66 QLocale keyboardInputLocale;
67 Qt::LayoutDirection keyboardInputDirection;
68
69 void updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 scancode, quint32 vk_key);
70 void deleteLayouts();
71
72 QWindow *m_keyGrabber;
73 QChar m_lastHighSurrogate;
74 static const size_t NumKeyboardLayoutItems = 256;
75 KeyboardLayoutItem keyLayout[NumKeyboardLayoutItems];
76 bool m_detectAltGrModifier = false;
77 bool m_seenAltGr = false;
78
79};
80
82 ShiftLeft = 0x00000001,
83 ControlLeft = 0x00000002,
84 AltLeft = 0x00000004,
85 MetaLeft = 0x00000008,
86 ShiftRight = 0x00000010,
87 ControlRight = 0x00000020,
88 AltRight = 0x00000040,
89 MetaRight = 0x00000080,
90 CapsLock = 0x00000100,
91 NumLock = 0x00000200,
92 ScrollLock = 0x00000400,
93 ExtendedKey = 0x01000000,
94
95 // Convenience mappings
96 ShiftAny = 0x00000011,
97 ControlAny = 0x00000022,
98 AltAny = 0x00000044,
99 MetaAny = 0x00000088,
100 LockAny = 0x00000700
102
104
105#endif // QWINDOWSKEYMAPPER_H
\inmodule QtCore
Definition qchar.h:48
The QKeyEvent class describes a key event.
Definition qevent.h:423
Definition qlist.h:74
\inmodule QtGui
Definition qwindow.h:63
Translates Windows keys to QWindowSystemInterface events.
bool translateKeyEvent(QWindow *widget, HWND hwnd, const MSG &msg, LRESULT *result)
To be called from the window procedure.
bool detectAltGrModifier() const
void setUseRTLExtensions(bool e)
QWindow * keyGrabber() const
bool useRTLExtensions() const
void setKeyGrabber(QWindow *w)
static Qt::KeyboardModifiers queryKeyboardModifiers()
void setDetectAltGrModifier(bool a)
QList< int > possibleKeys(const QKeyEvent *e) const
QOpenGLWidget * widget
[1]
double e
Combined button and popup list for selecting options.
LayoutDirection
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint64EXT * result
[6]
unsigned int quint32
Definition qtypes.h:45
unsigned int uint
Definition qtypes.h:29
unsigned char quint8
Definition qtypes.h:41
struct tagMSG MSG
WindowsNativeModifiers
@ ScrollLock
@ ExtendedKey
@ ShiftRight
@ LockAny
@ AltLeft
@ ShiftLeft
@ MetaRight
@ AltAny
@ MetaLeft
@ MetaAny
@ AltRight
@ ControlLeft
@ ControlRight
@ CapsLock
@ NumLock
@ ShiftAny
@ ControlAny
quint32 qtKey[NumQtKeys]
static const size_t NumQtKeys