Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qbsdkeyboard.h
Go to the documentation of this file.
1// Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
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 QBSDKEYBOARD_H
5#define QBSDKEYBOARD_H
6
7#include <qobject.h>
8#include <QDataStream>
9#include <QList>
10
12
13class QSocketNotifier;
14
15struct termios;
16
17enum {
18 Bsd_NoKeyMode = -1
19};
20
21namespace QBsdKeyboardMap {
22 const quint32 FileMagic = 0x514d4150; // 'QMAP'
23
33
34 enum Flags {
35 NoFlags = 0x00,
36 IsLetter = 0x01,
37 IsModifier = 0x02
38 };
39
40 enum Modifiers {
41 ModPlain = 0x00,
42 ModShift = 0x01,
43 ModAltGr = 0x02,
44 ModControl = 0x04,
45 ModAlt = 0x08,
46 ModShiftL = 0x10,
47 ModShiftR = 0x20,
48 ModCtrlL = 0x40,
49 ModCtrlR = 0x80
50 // ModCapsShift = 0x100, // not supported!
51 };
52}
53
55{
56 return ds >> m.keycode >> m.unicode >> m.qtcode >> m.modifiers >> m.flags >> m.special;
57}
58
60{
62
63public:
64 QBsdKeyboardHandler(const QString &key, const QString &specification);
65 ~QBsdKeyboardHandler() override;
66
67 static Qt::KeyboardModifiers toQtModifiers(quint8 mod)
68 {
69 Qt::KeyboardModifiers qtmod = Qt::NoModifier;
70
72 qtmod |= Qt::ShiftModifier;
74 qtmod |= Qt::ControlModifier;
76 qtmod |= Qt::AltModifier;
77
78 return qtmod;
79 }
80
81protected:
82 void switchLed(int led, bool state);
83 void processKeycode(quint16 keycode, bool pressed, bool autorepeat);
84 void processKeyEvent(int nativecode, int unicode, int qtcode,
85 Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat);
86 void revertTTYSettings();
87 void resetKeymap();
88 void readKeyboardData();
89
90private:
91 QScopedPointer<QSocketNotifier> m_notifier;
92 QScopedPointer<termios> m_kbdOrigTty;
93 int m_origKbdMode = Bsd_NoKeyMode;
94 int m_fd = -1;
95 bool m_shouldClose = false;
96 QString m_spec;
97
98 // keymap handling
99 quint8 m_modifiers = 0;
100 bool m_capsLock = false;
101 bool m_numLock = false;
102 bool m_scrollLock = false;
103
104 QList<QBsdKeyboardMap::Mapping> m_keymap;
105};
106
108
109#endif // QBSDKEYBOARD_H
void processKeycode(quint16 keycode, bool pressed, bool autorepeat)
static Qt::KeyboardModifiers toQtModifiers(quint8 mod)
void switchLed(int led, bool state)
QBsdKeyboardHandler(const QString &key, const QString &specification)
void processKeyEvent(int nativecode, int unicode, int qtcode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat)
~QBsdKeyboardHandler() override
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
EGLImageKHR int int EGLuint64KHR * modifiers
else opt state
[0]
const quint32 FileMagic
Combined button and popup list for selecting options.
@ ShiftModifier
@ ControlModifier
@ NoModifier
@ AltModifier
QDataStream & operator>>(QDataStream &ds, QBsdKeyboardMap::Mapping &m)
@ Bsd_NoKeyMode
const GLfloat * m
GLuint64 key
#define Q_OBJECT
unsigned int quint32
Definition qtypes.h:50
unsigned short quint16
Definition qtypes.h:48
unsigned char quint8
Definition qtypes.h:46
int keycode
Definition qvnc.cpp:140