qevdevkeyboardhandler.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7const QLoggingCategory &qLcEvdevKey() { static const QLoggingCategory category("qt.qpa.input"); return
never executed: return category;
category;
never executed: return category;
}
0
8const QLoggingCategory &qLcEvdevKeyMap() { static const QLoggingCategory category("qt.qpa.input.keymap"); return
never executed: return category;
category;
never executed: return category;
}
0
9-
10-
11-
12void QFdContainer::reset() noexcept-
13{-
14 if (m_fd >= 0
m_fd >= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
15 qt_safe_close(m_fd);
never executed: qt_safe_close(m_fd);
0
16 m_fd = -1;-
17}
never executed: end of block
0
18-
19QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, QFdContainer &fd, bool disableZap, bool enableCompose, const QString &keymapFile)-
20 : m_device(device), m_fd(fd.release()), m_notify(nullptr),-
21 m_modifiers(0), m_composing(0), m_dead_unicode(0xffff),-
22 m_no_zap(disableZap), m_do_compose(enableCompose),-
23 m_keymap(0), m_keymap_size(0), m_keycompose(0), m_keycompose_size(0)-
24{-
25 for (bool qt_category_enabled = qLcEvdevKey().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 75, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "Create keyboard handler with for device" << device;
never executed: QMessageLogger(__FILE__, 75, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "Create keyboard handler with for device" << device;
0
26-
27 setObjectName(QLatin1String("LinuxInput Keyboard Handler"));-
28-
29 memset(m_locks, 0, sizeof(m_locks));-
30-
31 if (keymapFile.isEmpty()
keymapFile.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| !loadKeymap(keymapFile)
!loadKeymap(keymapFile)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
32 unloadKeymap();
never executed: unloadKeymap();
0
33-
34-
35 m_notify = new QSocketNotifier(m_fd.get(), QSocketNotifier::Read, this);-
36 connect(m_notify, qFlagLocation("2""activated(int)" "\0" __FILE__ ":" "86"), this, qFlagLocation("1""readKeycode()" "\0" __FILE__ ":" "86"));-
37}
never executed: end of block
0
38-
39QEvdevKeyboardHandler::~QEvdevKeyboardHandler()-
40{-
41 unloadKeymap();-
42}
never executed: end of block
0
43-
44QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device,-
45 const QString &specification,-
46 const QString &defaultKeymapFile)-
47{-
48 for (bool qt_category_enabled = qLcEvdevKey().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 98, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "Try to create keyboard handler for" << device << specification;
never executed: QMessageLogger(__FILE__, 98, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "Try to create keyboard handler for" << device << specification;
0
49-
50 QString keymapFile = defaultKeymapFile;-
51 int repeatDelay = 400;-
52 int repeatRate = 80;-
53 bool disableZap = false;-
54 bool enableCompose = false;-
55 int grab = 0;-
56-
57 const auto args = specification.splitRef(QLatin1Char(':'));-
58 for (const QStringRef &arg : args) {-
59 if (arg.startsWith(QLatin1String("keymap="))
arg.startsWith...ng("keymap="))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
60 keymapFile = arg.mid(7).toString();
never executed: keymapFile = arg.mid(7).toString();
0
61 else if (arg == QLatin1String("disable-zap")
arg == QLatin1..."disable-zap")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
62 disableZap = true;
never executed: disableZap = true;
0
63 else if (arg == QLatin1String("enable-compose")
arg == QLatin1...able-compose")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
64 enableCompose = true;
never executed: enableCompose = true;
0
65 else if (arg.startsWith(QLatin1String("repeat-delay="))
arg.startsWith...peat-delay="))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
66 repeatDelay = arg.mid(13).toInt();
never executed: repeatDelay = arg.mid(13).toInt();
0
67 else if (arg.startsWith(QLatin1String("repeat-rate="))
arg.startsWith...epeat-rate="))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
68 repeatRate = arg.mid(12).toInt();
never executed: repeatRate = arg.mid(12).toInt();
0
69 else if (arg.startsWith(QLatin1String("grab="))
arg.startsWith...ring("grab="))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
70 grab = arg.mid(5).toInt();
never executed: grab = arg.mid(5).toInt();
0
71 }
never executed: end of block
0
72-
73 for (bool qt_category_enabled = qLcEvdevKey().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 123, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "Opening keyboard at" << device;
never executed: QMessageLogger(__FILE__, 123, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "Opening keyboard at" << device;
0
74-
75 QFdContainer fd(qt_safe_open(device.toLocal8Bit().constData(), 00 | 04000, 0));-
76 if (fd.get() >= 0
fd.get() >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
77 ::ioctl(fd.get(), (((1U) << (((0 +8)+8)+14)) | ((('E')) << (0 +8)) | (((0x90)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), grab);-
78 if (repeatDelay > 0
repeatDelay > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& repeatRate > 0
repeatRate > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
79 int kbdrep[2] = { repeatDelay, repeatRate };-
80 ::ioctl(fd.get(), (((1U) << (((0 +8)+8)+14)) | ((('E')) << (0 +8)) | (((0x03)) << 0) | ((((sizeof(unsigned int[2])))) << ((0 +8)+8))), kbdrep);-
81 }
never executed: end of block
0
82-
83 return
never executed: return new QEvdevKeyboardHandler(device, fd, disableZap, enableCompose, keymapFile);
new QEvdevKeyboardHandler(device, fd, disableZap, enableCompose, keymapFile);
never executed: return new QEvdevKeyboardHandler(device, fd, disableZap, enableCompose, keymapFile);
0
84 } else {-
85 QMessageLogger(__FILE__, 135, __PRETTY_FUNCTION__).warning("Cannot open keyboard input device '%s': %s", QString(device).toLocal8Bit().constData(), strerror((*__errno_location ())));-
86 return
never executed: return 0;
0;
never executed: return 0;
0
87 }-
88}-
89-
90void QEvdevKeyboardHandler::switchLed(int led, bool state)-
91{-
92 for (bool qt_category_enabled = qLcEvdevKey().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 142, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "switchLed" << led << state;
never executed: QMessageLogger(__FILE__, 142, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "switchLed" << led << state;
0
93-
94 struct ::input_event led_ie;-
95 ::gettimeofday(&led_ie.time, 0);-
96 led_ie.type = 0x11;-
97 led_ie.code = led;-
98 led_ie.value = state;-
99-
100 qt_safe_write(m_fd.get(), &led_ie, sizeof(led_ie));-
101}
never executed: end of block
0
102-
103void QEvdevKeyboardHandler::readKeycode()-
104{-
105 struct ::input_event buffer[32];-
106 int n = 0;-
107-
108 for(;;) {-
109 int result = qt_safe_read(m_fd.get(), reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);-
110-
111 if (result == 0
result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
112 QMessageLogger(__FILE__, 162, __PRETTY_FUNCTION__).warning("evdevkeyboard: Got EOF from the input device");-
113 return;
never executed: return;
0
114 } else if (result < 0
result < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
115 if ((*
(*__errno_location ()) != 4Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ()) != 4
(*__errno_location ()) != 4Description
TRUEnever evaluated
FALSEnever evaluated
&& (*
(*__errno_location ()) != 11Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ()) != 11
(*__errno_location ()) != 11Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
116 qErrnoWarning((*__errno_location ()), "evdevkeyboard: Could not read from input device");-
117-
118-
119 if ((*
(*__errno_location ()) == 19Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ()) == 19
(*__errno_location ()) == 19Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
120 delete m_notify;-
121 m_notify = nullptr;-
122 m_fd.reset();-
123 }
never executed: end of block
0
124 return;
never executed: return;
0
125 }-
126 }
never executed: end of block
else {
0
127 n += result;-
128 if (n % sizeof(buffer[0]) == 0
n % sizeof(buffer[0]) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
129 break;
never executed: break;
0
130 }
never executed: end of block
0
131 }-
132-
133 n /= sizeof(buffer[0]);-
134-
135 for (int i = 0; i < n
i < nDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
136 if (buffer[i].type != 0x01
buffer[i].type != 0x01Description
TRUEnever evaluated
FALSEnever evaluated
)
0
137 continue;
never executed: continue;
0
138-
139 quint16 code = buffer[i].code;-
140 qint32 value = buffer[i].value;-
141-
142 QEvdevKeyboardHandler::KeycodeAction ka;-
143 ka = processKeycode(code, value != 0, value == 2);-
144-
145 switch (ka) {-
146 case
never executed: case QEvdevKeyboardHandler::CapsLockOn:
QEvdevKeyboardHandler::CapsLockOn:
never executed: case QEvdevKeyboardHandler::CapsLockOn:
0
147 case
never executed: case QEvdevKeyboardHandler::CapsLockOff:
QEvdevKeyboardHandler::CapsLockOff:
never executed: case QEvdevKeyboardHandler::CapsLockOff:
0
148 switchLed(0x01, ka == QEvdevKeyboardHandler::CapsLockOn);-
149 break;
never executed: break;
0
150-
151 case
never executed: case QEvdevKeyboardHandler::NumLockOn:
QEvdevKeyboardHandler::NumLockOn:
never executed: case QEvdevKeyboardHandler::NumLockOn:
0
152 case
never executed: case QEvdevKeyboardHandler::NumLockOff:
QEvdevKeyboardHandler::NumLockOff:
never executed: case QEvdevKeyboardHandler::NumLockOff:
0
153 switchLed(0x00, ka == QEvdevKeyboardHandler::NumLockOn);-
154 break;
never executed: break;
0
155-
156 case
never executed: case QEvdevKeyboardHandler::ScrollLockOn:
QEvdevKeyboardHandler::ScrollLockOn:
never executed: case QEvdevKeyboardHandler::ScrollLockOn:
0
157 case
never executed: case QEvdevKeyboardHandler::ScrollLockOff:
QEvdevKeyboardHandler::ScrollLockOff:
never executed: case QEvdevKeyboardHandler::ScrollLockOff:
0
158 switchLed(0x02, ka == QEvdevKeyboardHandler::ScrollLockOn);-
159 break;
never executed: break;
0
160-
161 default
never executed: default:
:
never executed: default:
0
162-
163 break;
never executed: break;
0
164 }-
165 }-
166}
never executed: end of block
0
167-
168void QEvdevKeyboardHandler::processKeyEvent(int nativecode, int unicode, int qtcode,-
169 Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat)-
170{-
171 QWindowSystemInterface::handleExtendedKeyEvent(0, (isPress ? QEvent::KeyPress : QEvent::KeyRelease),-
172 qtcode, modifiers, nativecode + 8, 0, int(modifiers),-
173 (unicode != 0xffff ) ? QString(unicode) : QString(), autoRepeat);-
174}
never executed: end of block
0
175-
176QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint16 keycode, bool pressed, bool autorepeat)-
177{-
178 KeycodeAction result = None;-
179 bool first_press = pressed
pressedDescription
TRUEnever evaluated
FALSEnever evaluated
&& !autorepeat
!autorepeatDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
180-
181 const QEvdevKeyboardMap::Mapping *map_plain = 0;-
182 const QEvdevKeyboardMap::Mapping *map_withmod = 0;-
183-
184 quint8 modifiers = m_modifiers;-
185-
186-
187 for (int i = 0; i < m_keymap_size
i < m_keymap_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
&& !(map_plain
map_plainDescription
TRUEnever evaluated
FALSEnever evaluated
&& map_withmod
map_withmodDescription
TRUEnever evaluated
FALSEnever evaluated
); ++i) {
0
188 const QEvdevKeyboardMap::Mapping *m = m_keymap + i;-
189 if (m->keycode == keycode
m->keycode == keycodeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
190 if (m->modifiers == 0
m->modifiers == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
191 map_plain = m;
never executed: map_plain = m;
0
192-
193 quint8 testmods = m_modifiers;-
194 if (m_locks[0]
m_locks[0]Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(m->flags & QE...Map::IsLetter)Description
TRUEnever evaluated
FALSEnever evaluated
m->flags & QEvdevKeyboardMap::IsLetter)
(m->flags & QE...Map::IsLetter)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
195 testmods ^= QEvdevKeyboardMap::ModShift;
never executed: testmods ^= QEvdevKeyboardMap::ModShift;
0
196 if (m->modifiers == testmods
m->modifiers == testmodsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
197 map_withmod = m;
never executed: map_withmod = m;
0
198 }
never executed: end of block
0
199 }
never executed: end of block
0
200-
201 if (m_locks[0]
m_locks[0]Description
TRUEnever evaluated
FALSEnever evaluated
&& map_withmod
map_withmodDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(map_withmod->...Map::IsLetter)Description
TRUEnever evaluated
FALSEnever evaluated
map_withmod->flags & QEvdevKeyboardMap::IsLetter)
(map_withmod->...Map::IsLetter)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
202 modifiers ^= QEvdevKeyboardMap::ModShift;
never executed: modifiers ^= QEvdevKeyboardMap::ModShift;
0
203-
204 for (bool qt_category_enabled = qLcEvdevKeyMap().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(
never executed: QMessageLogger( __FILE__ , 258 , __PRETTY_FUNCTION__, qLcEvdevKeyMap().categoryName()).debug("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, int(map_plain ? map_plain - m_keymap : -1), int(map_withmod ? map_withmod - m_keymap : -1), m_keymap_size) ;
0
2050
2060
2070
208 __FILE__
never executed: QMessageLogger( __FILE__ , 258 , __PRETTY_FUNCTION__, qLcEvdevKeyMap().categoryName()).debug("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, int(map_plain ? map_plain - m_keymap : -1), int(map_withmod ? map_withmod - m_keymap : -1), m_keymap_size) ;
0
209 ,
never executed: QMessageLogger( __FILE__ , 258 , __PRETTY_FUNCTION__, qLcEvdevKeyMap().categoryName()).debug("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, int(map_plain ? map_plain - m_keymap : -1), int(map_withmod ? map_withmod - m_keymap : -1), m_keymap_size) ;
0
2100
2110
2120
213 258
never executed: QMessageLogger( __FILE__ , 258 , __PRETTY_FUNCTION__, qLcEvdevKeyMap().categoryName()).debug("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, int(map_plain ? map_plain - m_keymap : -1), int(map_withmod ? map_withmod - m_keymap : -1), m_keymap_size) ;
0
214 , __PRETTY_FUNCTION__, qLcEvdevKeyMap().categoryName()).debug("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, int(map_plain ? map_plain - m_keymap : -1), int(map_withmod ? map_withmod - m_keymap : -1), m_keymap_size)
never executed: QMessageLogger( __FILE__ , 258 , __PRETTY_FUNCTION__, qLcEvdevKeyMap().categoryName()).debug("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, int(map_plain ? map_plain - m_keymap : -1), int(map_withmod ? map_withmod - m_keymap : -1), m_keymap_size) ;
0
2150
2160
2170
218 ;
never executed: QMessageLogger( __FILE__ , 258 , __PRETTY_FUNCTION__, qLcEvdevKeyMap().categoryName()).debug("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, int(map_plain ? map_plain - m_keymap : -1), int(map_withmod ? map_withmod - m_keymap : -1), m_keymap_size) ;
0
219-
220 const QEvdevKeyboardMap::Mapping *it = map_withmod
map_withmodDescription
TRUEnever evaluated
FALSEnever evaluated
? map_withmod : map_plain;
0
221-
222 if (!it
!itDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
223-
224 for (bool qt_category_enabled = qLcEvdevKeyMap().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 264, __PRETTY_FUNCTION__, qLcEvdevKeyMap().categoryName()).debug("Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, modifiers);
never executed: QMessageLogger(__FILE__, 264, __PRETTY_FUNCTION__, qLcEvdevKeyMap().categoryName()).debug("Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, modifiers);
0
225 return
never executed: return result;
result;
never executed: return result;
0
226 }-
227-
228 bool skip = false;-
229 quint16 unicode = it->unicode;-
230 quint32 qtcode = it->qtcode;-
231-
232 if ((
(it->flags & Q...p::IsModifier)Description
TRUEnever evaluated
FALSEnever evaluated
it->flags & QEvdevKeyboardMap::IsModifier)
(it->flags & Q...p::IsModifier)Description
TRUEnever evaluated
FALSEnever evaluated
&& it->special
it->specialDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
233-
234 if (pressed
pressedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
235 m_modifiers |= quint8(it->special);
never executed: m_modifiers |= quint8(it->special);
0
236 else-
237 m_modifiers &= ~quint8(it->special);
never executed: m_modifiers &= ~quint8(it->special);
0
238 } else if (qtcode >= Qt::Key_CapsLock
qtcode >= Qt::Key_CapsLockDescription
TRUEnever evaluated
FALSEnever evaluated
&& qtcode <= Qt::Key_ScrollLock
qtcode <= Qt::Key_ScrollLockDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
239-
240 if (first_press
first_pressDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
241 quint8 &lock = m_locks[qtcode - Qt::Key_CapsLock];-
242 lock ^= 1;-
243-
244 switch (qtcode) {-
245 case
never executed: case Qt::Key_CapsLock :
Qt::Key_CapsLock :
never executed: case Qt::Key_CapsLock :
result = lock
lockDescription
TRUEnever evaluated
FALSEnever evaluated
? CapsLockOn : CapsLockOff; break;
never executed: break;
0
246 case
never executed: case Qt::Key_NumLock :
Qt::Key_NumLock :
never executed: case Qt::Key_NumLock :
result = lock
lockDescription
TRUEnever evaluated
FALSEnever evaluated
? NumLockOn : NumLockOff; break;
never executed: break;
0
247 case
never executed: case Qt::Key_ScrollLock:
Qt::Key_ScrollLock:
never executed: case Qt::Key_ScrollLock:
result = lock
lockDescription
TRUEnever evaluated
FALSEnever evaluated
? ScrollLockOn : ScrollLockOff; break;
never executed: break;
0
248 default
never executed: default :
:
never executed: default :
break;
never executed: break;
0
249 }-
250 }-
251 }
never executed: end of block
else if ((
(it->flags & Q...Map::IsSystem)Description
TRUEnever evaluated
FALSEnever evaluated
it->flags & QEvdevKeyboardMap::IsSystem)
(it->flags & Q...Map::IsSystem)Description
TRUEnever evaluated
FALSEnever evaluated
&& it->special
it->specialDescription
TRUEnever evaluated
FALSEnever evaluated
&& first_press
first_pressDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
252 switch (it->special) {-
253 case
never executed: case QEvdevKeyboardMap::SystemReboot:
QEvdevKeyboardMap::SystemReboot:
never executed: case QEvdevKeyboardMap::SystemReboot:
0
254 result = Reboot;-
255 break;
never executed: break;
0
256-
257 case
never executed: case QEvdevKeyboardMap::SystemZap:
QEvdevKeyboardMap::SystemZap:
never executed: case QEvdevKeyboardMap::SystemZap:
0
258 if (!m_no_zap
!m_no_zapDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
259 QCoreApplication::instance()->quit();
never executed: QCoreApplication::instance()->quit();
0
260 break;
never executed: break;
0
261-
262 case
never executed: case QEvdevKeyboardMap::SystemConsolePrevious:
QEvdevKeyboardMap::SystemConsolePrevious:
never executed: case QEvdevKeyboardMap::SystemConsolePrevious:
0
263 result = PreviousConsole;-
264 break;
never executed: break;
0
265-
266 case
never executed: case QEvdevKeyboardMap::SystemConsoleNext:
QEvdevKeyboardMap::SystemConsoleNext:
never executed: case QEvdevKeyboardMap::SystemConsoleNext:
0
267 result = NextConsole;-
268 break;
never executed: break;
0
269-
270 default
never executed: default:
:
never executed: default:
0
271 if (it->special >= QEvdevKeyboardMap::SystemConsoleFirst
it->special >=...emConsoleFirstDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
272 it->special <= QEvdevKeyboardMap::SystemConsoleLast
it->special <=...temConsoleLastDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
273 result = KeycodeAction(SwitchConsoleFirst + ((it->special & QEvdevKeyboardMap::SystemConsoleMask) & SwitchConsoleMask));-
274 }
never executed: end of block
0
275 break;
never executed: break;
0
276 }-
277-
278 skip = true;-
279 }
never executed: end of block
else if ((
(qtcode == Qt::Key_Multi_key)Description
TRUEnever evaluated
FALSEnever evaluated
qtcode == Qt::Key_Multi_key)
(qtcode == Qt::Key_Multi_key)Description
TRUEnever evaluated
FALSEnever evaluated
&& m_do_compose
m_do_composeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
280-
281 if (first_press
first_pressDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
282 m_composing = 2;
never executed: m_composing = 2;
0
283 skip = true;-
284 }
never executed: end of block
else if ((
(it->flags & Q...rdMap::IsDead)Description
TRUEnever evaluated
FALSEnever evaluated
it->flags & QEvdevKeyboardMap::IsDead)
(it->flags & Q...rdMap::IsDead)Description
TRUEnever evaluated
FALSEnever evaluated
&& m_do_compose
m_do_composeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
285-
286 if (first_press
first_pressDescription
TRUEnever evaluated
FALSEnever evaluated
&& m_composing == 1
m_composing == 1Description
TRUEnever evaluated
FALSEnever evaluated
&& m_dead_unicode == unicode
m_dead_unicode == unicodeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
287 m_composing = 0;-
288 qtcode = Qt::Key_unknown;-
289 }
never executed: end of block
else if (first_press
first_pressDescription
TRUEnever evaluated
FALSEnever evaluated
&& unicode != 0xffff
unicode != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
290 m_dead_unicode = unicode;-
291 m_composing = 1;-
292 skip = true;-
293 }
never executed: end of block
else {
0
294 skip = true;-
295 }
never executed: end of block
0
296 }-
297-
298 if (!skip
!skipDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
299-
300 const int modmask = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier;-
301-
302-
303-
304-
305 if ((it == map_plain
it == map_plainDescription
TRUEnever evaluated
FALSEnever evaluated
&& it != map_withmod
it != map_withmodDescription
TRUEnever evaluated
FALSEnever evaluated
) ||
0
306 (map_withmod
map_withmodDescription
TRUEnever evaluated
FALSEnever evaluated
&& !(map_withmod->qtcode & modmask)
!(map_withmod-...ode & modmask)Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
307 qtcode |= QEvdevKeyboardHandler::toQtModifiers(modifiers);-
308 }
never executed: end of block
0
309-
310 if (m_composing == 2
m_composing == 2Description
TRUEnever evaluated
FALSEnever evaluated
&& first_press
first_pressDescription
TRUEnever evaluated
FALSEnever evaluated
&& !(it->flags & QEvdevKeyboardMap::IsModifier)
!(it->flags & ...p::IsModifier)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
311-
312 if (unicode != 0xffff
unicode != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
313 int idx = 0;-
314-
315 for ( ; idx < m_keycompose_size
idx < m_keycompose_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
; ++idx) {
0
316 if (m_keycompose[idx].first == unicode
m_keycompose[i...rst == unicodeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
317 break;
never executed: break;
0
318 }
never executed: end of block
0
319 if (idx < m_keycompose_size
idx < m_keycompose_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
320-
321 m_dead_unicode = unicode;-
322 unicode = 0xffff;-
323 m_composing = 1;-
324 skip = true;-
325 }
never executed: end of block
else {
0
326 m_composing = 0;-
327 }
never executed: end of block
0
328 } else {-
329 m_composing = 0;-
330 }
never executed: end of block
0
331 } else if (m_composing == 1
m_composing == 1Description
TRUEnever evaluated
FALSEnever evaluated
&& first_press
first_pressDescription
TRUEnever evaluated
FALSEnever evaluated
&& !(it->flags & QEvdevKeyboardMap::IsModifier)
!(it->flags & ...p::IsModifier)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
332-
333 bool valid = false;-
334 if (unicode != 0xffff
unicode != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
335 int idx = 0;-
336-
337 for ( ; idx < m_keycompose_size
idx < m_keycompose_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
; ++idx) {
0
338 if (m_keycompose[idx].first == m_dead_unicode
m_keycompose[i...m_dead_unicodeDescription
TRUEnever evaluated
FALSEnever evaluated
&& m_keycompose[idx].second == unicode
m_keycompose[i...ond == unicodeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
339 break;
never executed: break;
0
340 }
never executed: end of block
0
341 if (idx < m_keycompose_size
idx < m_keycompose_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
342 quint16 composed = m_keycompose[idx].result;-
343 if (composed != 0xffff
composed != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
344 unicode = composed;-
345 qtcode = Qt::Key_unknown;-
346 valid = true;-
347 }
never executed: end of block
0
348 }
never executed: end of block
0
349 }
never executed: end of block
0
350 if (!valid
!validDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
351 unicode = m_dead_unicode;-
352 qtcode = Qt::Key_unknown;-
353 }
never executed: end of block
0
354 m_composing = 0;-
355 }
never executed: end of block
0
356-
357 if (!skip
!skipDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
358-
359 Qt::KeyboardModifiers qtmods = Qt::KeyboardModifiers(qtcode & modmask);-
360 qtcode &= ~modmask;-
361-
362 for (bool qt_category_enabled = qLcEvdevKeyMap().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 402, __PRETTY_FUNCTION__, qLcEvdevKeyMap().categoryName()).debug("Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode, int(qtmods));
never executed: QMessageLogger(__FILE__, 402, __PRETTY_FUNCTION__, qLcEvdevKeyMap().categoryName()).debug("Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode, int(qtmods));
0
363-
364-
365 if (!m_locks[1]
!m_locks[1]Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(qtmods & Qt::KeypadModifier)Description
TRUEnever evaluated
FALSEnever evaluated
qtmods & Qt::KeypadModifier)
(qtmods & Qt::KeypadModifier)Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
366 keycode >= 71
keycode >= 71Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
367 keycode <= 83
keycode <= 83Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
368 keycode != 74
keycode != 74Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
369 keycode != 78
keycode != 78Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
370-
371 unicode = 0xffff;-
372 switch (keycode) {-
373 case
never executed: case 71:
71:
never executed: case 71:
0
374 qtcode = Qt::Key_Home;-
375 break;
never executed: break;
0
376 case
never executed: case 72:
72:
never executed: case 72:
0
377 qtcode = Qt::Key_Up;-
378 break;
never executed: break;
0
379 case
never executed: case 73:
73:
never executed: case 73:
0
380 qtcode = Qt::Key_PageUp;-
381 break;
never executed: break;
0
382 case
never executed: case 75:
75:
never executed: case 75:
0
383 qtcode = Qt::Key_Left;-
384 break;
never executed: break;
0
385 case
never executed: case 76:
76:
never executed: case 76:
0
386 qtcode = Qt::Key_Clear;-
387 break;
never executed: break;
0
388 case
never executed: case 77:
77:
never executed: case 77:
0
389 qtcode = Qt::Key_Right;-
390 break;
never executed: break;
0
391 case
never executed: case 79:
79:
never executed: case 79:
0
392 qtcode = Qt::Key_End;-
393 break;
never executed: break;
0
394 case
never executed: case 80:
80:
never executed: case 80:
0
395 qtcode = Qt::Key_Down;-
396 break;
never executed: break;
0
397 case
never executed: case 81:
81:
never executed: case 81:
0
398 qtcode = Qt::Key_PageDown;-
399 break;
never executed: break;
0
400 case
never executed: case 82:
82:
never executed: case 82:
0
401 qtcode = Qt::Key_Insert;-
402 break;
never executed: break;
0
403 case
never executed: case 83:
83:
never executed: case 83:
0
404 qtcode = Qt::Key_Delete;-
405 break;
never executed: break;
0
406 }-
407 }
never executed: end of block
0
408-
409-
410 if (qtcode == Qt::Key_Tab
qtcode == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(qtmods & Qt::...:ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
qtmods & Qt::ShiftModifier) == Qt::ShiftModifier
(qtmods & Qt::...:ShiftModifierDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
411 qtcode = Qt::Key_Backtab;
never executed: qtcode = Qt::Key_Backtab;
0
412-
413-
414 processKeyEvent(keycode, unicode, qtcode, qtmods, pressed, autorepeat);-
415 }
never executed: end of block
0
416 }
never executed: end of block
0
417 return
never executed: return result;
result;
never executed: return result;
0
418}-
419-
420void QEvdevKeyboardHandler::unloadKeymap()-
421{-
422 for (bool qt_category_enabled = qLcEvdevKey().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 462, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "Unload current keymap and restore built-in";
never executed: QMessageLogger(__FILE__, 462, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "Unload current keymap and restore built-in";
0
423-
424 if (m_keymap
m_keymapDescription
TRUEnever evaluated
FALSEnever evaluated
&& m_keymap != s_keymap_default
m_keymap != s_keymap_defaultDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
425 delete [] m_keymap;
never executed: delete [] m_keymap;
0
426 if (m_keycompose
m_keycomposeDescription
TRUEnever evaluated
FALSEnever evaluated
&& m_keycompose != s_keycompose_default
m_keycompose !...ompose_defaultDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
427 delete [] m_keycompose;
never executed: delete [] m_keycompose;
0
428-
429 m_keymap = s_keymap_default;-
430 m_keymap_size = sizeof(s_keymap_default) / sizeof(s_keymap_default[0]);-
431 m_keycompose = s_keycompose_default;-
432 m_keycompose_size = sizeof(s_keycompose_default) / sizeof(s_keycompose_default[0]);-
433-
434-
435 m_modifiers = 0;-
436 memset(m_locks, 0, sizeof(m_locks));-
437 m_composing = 0;-
438 m_dead_unicode = 0xffff;-
439-
440-
441 quint16 ledbits[1];-
442 memset(ledbits, 0, sizeof(ledbits));-
443 if (::
::ioctl(m_fd.g..., ledbits) < 0Description
TRUEnever evaluated
FALSEnever evaluated
ioctl(m_fd.get(), (((2U) << (((0 +8)+8)+14)) | (('E') << (0 +8)) | ((0x19) << 0) | ((sizeof(ledbits)) << ((0 +8)+8))), ledbits) < 0
::ioctl(m_fd.g..., ledbits) < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
444 QMessageLogger(__FILE__, 484, __PRETTY_FUNCTION__).warning("evdevkeyboard: Failed to query led states");-
445 switchLed(0x00,false);-
446 switchLed(0x01, false);-
447 switchLed(0x02,false);-
448 }
never executed: end of block
else {
0
449-
450 if ((
(ledbits[0]&0x02) > 0Description
TRUEnever evaluated
FALSEnever evaluated
ledbits[0]&0x02) > 0
(ledbits[0]&0x02) > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
451 m_locks[0] = 1;
never executed: m_locks[0] = 1;
0
452-
453 if ((
(ledbits[0]&0x01) > 0Description
TRUEnever evaluated
FALSEnever evaluated
ledbits[0]&0x01) > 0
(ledbits[0]&0x01) > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
454 m_locks[1] = 1;
never executed: m_locks[1] = 1;
0
455-
456 if ((
(ledbits[0]&0x04) > 0Description
TRUEnever evaluated
FALSEnever evaluated
ledbits[0]&0x04) > 0
(ledbits[0]&0x04) > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
457 m_locks[2] = 1;
never executed: m_locks[2] = 1;
0
458 for (bool qt_category_enabled = qLcEvdevKey().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 498, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug("numlock=%d , capslock=%d, scrolllock=%d", m_locks[1], m_locks[0], m_locks[2]);
never executed: QMessageLogger(__FILE__, 498, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug("numlock=%d , capslock=%d, scrolllock=%d", m_locks[1], m_locks[0], m_locks[2]);
0
459 }
never executed: end of block
0
460}-
461-
462bool QEvdevKeyboardHandler::loadKeymap(const QString &file)-
463{-
464 for (bool qt_category_enabled = qLcEvdevKey().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 504, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "Loading keymap" << file;
never executed: QMessageLogger(__FILE__, 504, __PRETTY_FUNCTION__, qLcEvdevKey().categoryName()).debug() << "Loading keymap" << file;
0
465-
466 QFile f(file);-
467-
468 if (!f.open(QIODevice::ReadOnly)
!f.open(QIODevice::ReadOnly)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
469 QMessageLogger(__FILE__, 509, __PRETTY_FUNCTION__).warning("Could not open keymap file '%s'", QString(file).toLocal8Bit().constData());-
470 return
never executed: return false;
false;
never executed: return false;
0
471 }-
472 quint32 qmap_magic, qmap_version, qmap_keymap_size, qmap_keycompose_size;-
473-
474 QDataStream ds(&f);-
475-
476 ds >> qmap_magic >> qmap_version >> qmap_keymap_size >> qmap_keycompose_size;-
477-
478 if (ds.status() != QDataStream::Ok
ds.status() != QDataStream::OkDescription
TRUEnever evaluated
FALSEnever evaluated
|| qmap_magic != QEvdevKeyboardMap::FileMagic
qmap_magic != ...Map::FileMagicDescription
TRUEnever evaluated
FALSEnever evaluated
|| qmap_version != 1
qmap_version != 1Description
TRUEnever evaluated
FALSEnever evaluated
|| qmap_keymap_size == 0
qmap_keymap_size == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
479 QMessageLogger(__FILE__, 528, __PRETTY_FUNCTION__).warning("'%s' is not a valid .qmap keymap file", QString(file).toLocal8Bit().constData());-
480 return
never executed: return false;
false;
never executed: return false;
0
481 }-
482-
483 QEvdevKeyboardMap::Mapping *qmap_keymap = new QEvdevKeyboardMap::Mapping[qmap_keymap_size];-
484 QEvdevKeyboardMap::Composing *qmap_keycompose = qmap_keycompose_size
qmap_keycompose_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
? new QEvdevKeyboardMap::Composing[qmap_keycompose_size] : 0;
0
485-
486 for (quint32 i = 0; i < qmap_keymap_size
i < qmap_keymap_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
487 ds >> qmap_keymap[i];
never executed: ds >> qmap_keymap[i];
0
488 for (quint32 i = 0; i < qmap_keycompose_size
i < qmap_keycompose_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
489 ds >> qmap_keycompose[i];
never executed: ds >> qmap_keycompose[i];
0
490-
491 if (ds.status() != QDataStream::Ok
ds.status() != QDataStream::OkDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
492 delete [] qmap_keymap;-
493 delete [] qmap_keycompose;-
494-
495 QMessageLogger(__FILE__, 544, __PRETTY_FUNCTION__).warning("Keymap file '%s' can not be loaded.", QString(file).toLocal8Bit().constData());-
496 return
never executed: return false;
false;
never executed: return false;
0
497 }-
498-
499-
500 unloadKeymap();-
501-
502 m_keymap = qmap_keymap;-
503 m_keymap_size = qmap_keymap_size;-
504 m_keycompose = qmap_keycompose;-
505 m_keycompose_size = qmap_keycompose_size;-
506-
507 m_do_compose = true;-
508-
509 return
never executed: return true;
true;
never executed: return true;
0
510}-
511-
512-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9