Debian Codegraph @

qt6/platforminputcontext/qtkey.cpp

raw
1 /*
2 * Copyright (C) 2017~2017 by CSSlayer
3 * [email protected]
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above Copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above Copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * 3. Neither the name of the authors nor the names of its contributors
17 * may be used to endorse or promote products derived from this
18 * software without specific prior written permission.
19 */
20
21 #include "qtkey.h"
22
23 #include <QHash>
24 #include <QString>
25 #include <X11/XF86keysym.h>
26 #include <X11/keysym.h>
27 #include <ctype.h>
28 #include <qnamespace.h>
29 #include <unordered_map>
30
31 const std::unordered_map<uint32_t, int> &KeyTbl() {
32 static std::unordered_map<uint32_t, int> keyTbl{
33 std::make_pair(XK_KP_Space, Qt::Key_Space),
34 std::make_pair(XK_KP_Tab, Qt::Key_Tab),
35 std::make_pair(XK_KP_Enter, Qt::Key_Enter),
36 std::make_pair(XK_KP_F1, Qt::Key_F1),
37 std::make_pair(XK_KP_F2, Qt::Key_F2),
38 std::make_pair(XK_KP_F3, Qt::Key_F3),
39 std::make_pair(XK_KP_F4, Qt::Key_F4),
40 std::make_pair(XK_KP_Home, Qt::Key_Home),
41 std::make_pair(XK_KP_Left, Qt::Key_Left),
42 std::make_pair(XK_KP_Up, Qt::Key_Up),
43 std::make_pair(XK_KP_Right, Qt::Key_Right),
44 std::make_pair(XK_KP_Down, Qt::Key_Down),
45 std::make_pair(XK_KP_Page_Up, Qt::Key_PageUp),
46 std::make_pair(XK_KP_Page_Down, Qt::Key_PageDown),
47 std::make_pair(XK_KP_End, Qt::Key_End),
48 std::make_pair(XK_KP_Begin, Qt::Key_Clear),
49 std::make_pair(XK_KP_Insert, Qt::Key_Insert),
50 std::make_pair(XK_KP_Delete, Qt::Key_Delete),
51 std::make_pair(XK_KP_Equal, Qt::Key_Equal),
52 std::make_pair(XK_KP_Multiply, Qt::Key_multiply),
53 std::make_pair(XK_KP_Add, Qt::Key_Plus),
54 std::make_pair(XK_KP_Separator, Qt::Key_Comma),
55 std::make_pair(XK_KP_Subtract, Qt::Key_Minus),
56 std::make_pair(XK_KP_Decimal, Qt::Key_Period),
57 std::make_pair(XK_KP_Divide, Qt::Key_Slash),
58
59 std::make_pair(XK_KP_0, Qt::Key_0),
60 std::make_pair(XK_KP_1, Qt::Key_1),
61 std::make_pair(XK_KP_2, Qt::Key_2),
62 std::make_pair(XK_KP_3, Qt::Key_3),
63 std::make_pair(XK_KP_4, Qt::Key_4),
64 std::make_pair(XK_KP_5, Qt::Key_5),
65 std::make_pair(XK_KP_6, Qt::Key_6),
66 std::make_pair(XK_KP_7, Qt::Key_7),
67 std::make_pair(XK_KP_8, Qt::Key_8),
68 std::make_pair(XK_KP_9, Qt::Key_9),
69
70 std::make_pair(XK_Escape, Qt::Key_Escape),
71 std::make_pair(XK_Tab, Qt::Key_Tab),
72 std::make_pair(XK_ISO_Left_Tab, Qt::Key_Backtab),
73 std::make_pair(XK_BackSpace, Qt::Key_Backspace),
74 std::make_pair(XK_Return, Qt::Key_Return),
75 std::make_pair(XK_KP_Enter, Qt::Key_Enter),
76 std::make_pair(XK_Insert, Qt::Key_Insert),
77 std::make_pair(XK_Delete, Qt::Key_Delete),
78 std::make_pair(XK_Clear, Qt::Key_Delete),
79 std::make_pair(XK_Pause, Qt::Key_Pause),
80 std::make_pair(XK_Print, Qt::Key_Print),
81 std::make_pair(XK_Sys_Req, Qt::Key_SysReq),
82 std::make_pair(0x1005FF60, Qt::Key_SysReq),
83 std::make_pair(0x1007ff00, Qt::Key_SysReq),
84
85 std::make_pair(XK_Home, Qt::Key_Home),
86 std::make_pair(XK_End, Qt::Key_End),
87 std::make_pair(XK_Left, Qt::Key_Left),
88 std::make_pair(XK_Up, Qt::Key_Up),
89 std::make_pair(XK_Right, Qt::Key_Right),
90 std::make_pair(XK_Down, Qt::Key_Down),
91 std::make_pair(XK_Page_Up, Qt::Key_PageUp),
92 std::make_pair(XK_Page_Down, Qt::Key_PageDown),
93 std::make_pair(XK_Shift_L, Qt::Key_Shift),
94 std::make_pair(XK_Shift_R, Qt::Key_Shift),
95 std::make_pair(XK_Shift_Lock, Qt::Key_Shift),
96 std::make_pair(XK_Control_L, Qt::Key_Control),
97 std::make_pair(XK_Control_R, Qt::Key_Control),
98 std::make_pair(XK_Meta_L, Qt::Key_Meta),
99 std::make_pair(XK_Meta_R, Qt::Key_Meta),
100 std::make_pair(XK_Alt_L, Qt::Key_Alt),
101 std::make_pair(XK_Alt_R, Qt::Key_Alt),
102 std::make_pair(XK_Caps_Lock, Qt::Key_CapsLock),
103 std::make_pair(XK_Num_Lock, Qt::Key_NumLock),
104 std::make_pair(XK_Scroll_Lock, Qt::Key_ScrollLock),
105 std::make_pair(XK_F1, Qt::Key_F1),
106 std::make_pair(XK_F2, Qt::Key_F2),
107 std::make_pair(XK_F3, Qt::Key_F3),
108 std::make_pair(XK_F4, Qt::Key_F4),
109 std::make_pair(XK_F5, Qt::Key_F5),
110 std::make_pair(XK_F6, Qt::Key_F6),
111 std::make_pair(XK_F7, Qt::Key_F7),
112 std::make_pair(XK_F8, Qt::Key_F8),
113 std::make_pair(XK_F9, Qt::Key_F9),
114 std::make_pair(XK_F10, Qt::Key_F10),
115 std::make_pair(XK_F11, Qt::Key_F11),
116 std::make_pair(XK_F12, Qt::Key_F12),
117 std::make_pair(XK_F13, Qt::Key_F13),
118 std::make_pair(XK_F14, Qt::Key_F14),
119 std::make_pair(XK_F15, Qt::Key_F15),
120 std::make_pair(XK_F16, Qt::Key_F16),
121 std::make_pair(XK_F17, Qt::Key_F17),
122 std::make_pair(XK_F18, Qt::Key_F18),
123 std::make_pair(XK_F19, Qt::Key_F19),
124 std::make_pair(XK_F20, Qt::Key_F20),
125 std::make_pair(XK_F21, Qt::Key_F21),
126 std::make_pair(XK_F22, Qt::Key_F22),
127 std::make_pair(XK_F23, Qt::Key_F23),
128 std::make_pair(XK_F24, Qt::Key_F24),
129 std::make_pair(XK_F25, Qt::Key_F25),
130 std::make_pair(XK_F26, Qt::Key_F26),
131 std::make_pair(XK_F27, Qt::Key_F27),
132 std::make_pair(XK_F28, Qt::Key_F28),
133 std::make_pair(XK_F29, Qt::Key_F29),
134 std::make_pair(XK_F30, Qt::Key_F30),
135 std::make_pair(XK_F31, Qt::Key_F31),
136 std::make_pair(XK_F32, Qt::Key_F32),
137 std::make_pair(XK_F33, Qt::Key_F33),
138 std::make_pair(XK_F34, Qt::Key_F34),
139 std::make_pair(XK_F35, Qt::Key_F35),
140 std::make_pair(XK_Super_L, Qt::Key_Super_L),
141 std::make_pair(XK_Super_R, Qt::Key_Super_R),
142 std::make_pair(XK_Menu, Qt::Key_Menu),
143 std::make_pair(XK_Hyper_L, Qt::Key_Hyper_L),
144 std::make_pair(XK_Hyper_R, Qt::Key_Hyper_R),
145 std::make_pair(XK_Help, Qt::Key_Help),
146 std::make_pair(XK_ISO_Level3_Shift, Qt::Key_AltGr),
147 std::make_pair(XK_Multi_key, Qt::Key_Multi_key),
148 std::make_pair(XK_Codeinput, Qt::Key_Codeinput),
149 std::make_pair(XK_SingleCandidate, Qt::Key_SingleCandidate),
150 std::make_pair(XK_MultipleCandidate, Qt::Key_MultipleCandidate),
151 std::make_pair(XK_PreviousCandidate, Qt::Key_PreviousCandidate),
152 std::make_pair(XK_Mode_switch, Qt::Key_Mode_switch),
153 std::make_pair(XK_script_switch, Qt::Key_Mode_switch),
154 std::make_pair(XK_Kanji, Qt::Key_Kanji),
155 std::make_pair(XK_Muhenkan, Qt::Key_Muhenkan),
156 std::make_pair(XK_Henkan, Qt::Key_Henkan),
157 std::make_pair(XK_Romaji, Qt::Key_Romaji),
158 std::make_pair(XK_Hiragana, Qt::Key_Hiragana),
159 std::make_pair(XK_Katakana, Qt::Key_Katakana),
160 std::make_pair(XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana),
161 std::make_pair(XK_Zenkaku, Qt::Key_Zenkaku),
162 std::make_pair(XK_Hankaku, Qt::Key_Hankaku),
163 std::make_pair(XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku),
164 std::make_pair(XK_Touroku, Qt::Key_Touroku),
165 std::make_pair(XK_Massyo, Qt::Key_Massyo),
166 std::make_pair(XK_Kana_Lock, Qt::Key_Kana_Lock),
167 std::make_pair(XK_Kana_Shift, Qt::Key_Kana_Shift),
168 std::make_pair(XK_Eisu_Shift, Qt::Key_Eisu_Shift),
169 std::make_pair(XK_Eisu_toggle, Qt::Key_Eisu_toggle),
170 std::make_pair(XK_Kanji_Bangou, Qt::Key_Codeinput),
171 std::make_pair(XK_Zen_Koho, Qt::Key_MultipleCandidate),
172 std::make_pair(XK_Mae_Koho, Qt::Key_PreviousCandidate),
173 std::make_pair(XK_Hangul, Qt::Key_Hangul),
174 std::make_pair(XK_Hangul_Start, Qt::Key_Hangul_Start),
175 std::make_pair(XK_Hangul_End, Qt::Key_Hangul_End),
176 std::make_pair(XK_Hangul_Hanja, Qt::Key_Hangul_Hanja),
177 std::make_pair(XK_Hangul_Jamo, Qt::Key_Hangul_Jamo),
178 std::make_pair(XK_Hangul_Romaja, Qt::Key_Hangul_Romaja),
179 std::make_pair(XK_Hangul_Codeinput, Qt::Key_Codeinput),
180 std::make_pair(XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja),
181 std::make_pair(XK_Hangul_Banja, Qt::Key_Hangul_Banja),
182 std::make_pair(XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja),
183 std::make_pair(XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja),
184 std::make_pair(XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate),
185 std::make_pair(XK_Hangul_MultipleCandidate, Qt::Key_MultipleCandidate),
186 std::make_pair(XK_Hangul_PreviousCandidate, Qt::Key_PreviousCandidate),
187 std::make_pair(XK_Hangul_Special, Qt::Key_Hangul_Special),
188 std::make_pair(XK_Hangul_switch, Qt::Key_Mode_switch),
189 std::make_pair(XK_dead_grave, Qt::Key_Dead_Grave),
190 std::make_pair(XK_dead_acute, Qt::Key_Dead_Acute),
191 std::make_pair(XK_dead_circumflex, Qt::Key_Dead_Circumflex),
192 std::make_pair(XK_dead_tilde, Qt::Key_Dead_Tilde),
193 std::make_pair(XK_dead_macron, Qt::Key_Dead_Macron),
194 std::make_pair(XK_dead_breve, Qt::Key_Dead_Breve),
195 std::make_pair(XK_dead_abovedot, Qt::Key_Dead_Abovedot),
196 std::make_pair(XK_dead_diaeresis, Qt::Key_Dead_Diaeresis),
197 std::make_pair(XK_dead_abovering, Qt::Key_Dead_Abovering),
198 std::make_pair(XK_dead_doubleacute, Qt::Key_Dead_Doubleacute),
199 std::make_pair(XK_dead_caron, Qt::Key_Dead_Caron),
200 std::make_pair(XK_dead_cedilla, Qt::Key_Dead_Cedilla),
201 std::make_pair(XK_dead_ogonek, Qt::Key_Dead_Ogonek),
202 std::make_pair(XK_dead_iota, Qt::Key_Dead_Iota),
203 std::make_pair(XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound),
204 std::make_pair(XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound),
205 std::make_pair(XK_dead_belowdot, Qt::Key_Dead_Belowdot),
206 std::make_pair(XK_dead_hook, Qt::Key_Dead_Hook),
207 std::make_pair(XK_dead_horn, Qt::Key_Dead_Horn),
208 std::make_pair(XF86XK_Back, Qt::Key_Back),
209 std::make_pair(XF86XK_Forward, Qt::Key_Forward),
210 std::make_pair(XF86XK_Stop, Qt::Key_Stop),
211 std::make_pair(XF86XK_Refresh, Qt::Key_Refresh),
212 std::make_pair(XF86XK_AudioLowerVolume, Qt::Key_VolumeDown),
213 std::make_pair(XF86XK_AudioMute, Qt::Key_VolumeMute),
214 std::make_pair(XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp),
215 std::make_pair(XF86XK_AudioPlay, Qt::Key_MediaPlay),
216 std::make_pair(XF86XK_AudioStop, Qt::Key_MediaStop),
217 std::make_pair(XF86XK_AudioPrev, Qt::Key_MediaPrevious),
218 std::make_pair(XF86XK_AudioNext, Qt::Key_MediaNext),
219 std::make_pair(XF86XK_AudioRecord, Qt::Key_MediaRecord),
220 std::make_pair(XF86XK_AudioPause, Qt::Key_MediaPause),
221 std::make_pair(XF86XK_HomePage, Qt::Key_HomePage),
222 std::make_pair(XF86XK_Favorites, Qt::Key_Favorites),
223 std::make_pair(XF86XK_Search, Qt::Key_Search),
224 std::make_pair(XF86XK_Standby, Qt::Key_Standby),
225 std::make_pair(XF86XK_OpenURL, Qt::Key_OpenUrl),
226 std::make_pair(XF86XK_Mail, Qt::Key_LaunchMail),
227 std::make_pair(XF86XK_AudioMedia, Qt::Key_LaunchMedia),
228 std::make_pair(XF86XK_MyComputer, Qt::Key_Launch0),
229 std::make_pair(XF86XK_Calculator, Qt::Key_Launch1),
230 std::make_pair(XF86XK_Launch0, Qt::Key_Launch2),
231 std::make_pair(XF86XK_Launch1, Qt::Key_Launch3),
232 std::make_pair(XF86XK_Launch2, Qt::Key_Launch4),
233 std::make_pair(XF86XK_Launch3, Qt::Key_Launch5),
234 std::make_pair(XF86XK_Launch4, Qt::Key_Launch6),
235 std::make_pair(XF86XK_Launch5, Qt::Key_Launch7),
236 std::make_pair(XF86XK_Launch6, Qt::Key_Launch8),
237 std::make_pair(XF86XK_Launch7, Qt::Key_Launch9),
238 std::make_pair(XF86XK_Launch8, Qt::Key_LaunchA),
239 std::make_pair(XF86XK_Launch9, Qt::Key_LaunchB),
240 std::make_pair(XF86XK_LaunchA, Qt::Key_LaunchC),
241 std::make_pair(XF86XK_LaunchB, Qt::Key_LaunchD),
242 std::make_pair(XF86XK_LaunchC, Qt::Key_LaunchE),
243 std::make_pair(XF86XK_LaunchD, Qt::Key_LaunchF),
244 std::make_pair(XF86XK_MonBrightnessUp, Qt::Key_MonBrightnessUp),
245 std::make_pair(XF86XK_MonBrightnessDown, Qt::Key_MonBrightnessDown),
246 std::make_pair(XF86XK_KbdLightOnOff, Qt::Key_KeyboardLightOnOff),
247 std::make_pair(XF86XK_KbdBrightnessUp, Qt::Key_KeyboardBrightnessUp),
248 std::make_pair(XF86XK_KbdBrightnessDown,
249 Qt::Key_KeyboardBrightnessDown),
250 std::make_pair(XF86XK_PowerOff, Qt::Key_PowerOff),
251 std::make_pair(XF86XK_WakeUp, Qt::Key_WakeUp),
252 std::make_pair(XF86XK_Eject, Qt::Key_Eject),
253 std::make_pair(XF86XK_ScreenSaver, Qt::Key_ScreenSaver),
254 std::make_pair(XF86XK_WWW, Qt::Key_WWW),
255 std::make_pair(XF86XK_Memo, Qt::Key_Memo),
256 std::make_pair(XF86XK_LightBulb, Qt::Key_LightBulb),
257 std::make_pair(XF86XK_Shop, Qt::Key_Shop),
258 std::make_pair(XF86XK_History, Qt::Key_History),
259 std::make_pair(XF86XK_AddFavorite, Qt::Key_AddFavorite),
260 std::make_pair(XF86XK_HotLinks, Qt::Key_HotLinks),
261 std::make_pair(XF86XK_BrightnessAdjust, Qt::Key_BrightnessAdjust),
262 std::make_pair(XF86XK_Finance, Qt::Key_Finance),
263 std::make_pair(XF86XK_Community, Qt::Key_Community),
264 std::make_pair(XF86XK_AudioRewind, Qt::Key_AudioRewind),
265 std::make_pair(XF86XK_BackForward, Qt::Key_BackForward),
266 std::make_pair(XF86XK_ApplicationLeft, Qt::Key_ApplicationLeft),
267 std::make_pair(XF86XK_ApplicationRight, Qt::Key_ApplicationRight),
268 std::make_pair(XF86XK_Book, Qt::Key_Book),
269 std::make_pair(XF86XK_CD, Qt::Key_CD),
270 std::make_pair(XF86XK_Calculater, Qt::Key_Calculator),
271 std::make_pair(XF86XK_ToDoList, Qt::Key_ToDoList),
272 std::make_pair(XF86XK_ClearGrab, Qt::Key_ClearGrab),
273 std::make_pair(XF86XK_Close, Qt::Key_Close),
274 std::make_pair(XF86XK_Copy, Qt::Key_Copy),
275 std::make_pair(XF86XK_Cut, Qt::Key_Cut),
276 std::make_pair(XF86XK_Display, Qt::Key_Display),
277 std::make_pair(XF86XK_DOS, Qt::Key_DOS),
278 std::make_pair(XF86XK_Documents, Qt::Key_Documents),
279 std::make_pair(XF86XK_Excel, Qt::Key_Excel),
280 std::make_pair(XF86XK_Explorer, Qt::Key_Explorer),
281 std::make_pair(XF86XK_Game, Qt::Key_Game),
282 std::make_pair(XF86XK_Go, Qt::Key_Go),
283 std::make_pair(XF86XK_iTouch, Qt::Key_iTouch),
284 std::make_pair(XF86XK_LogOff, Qt::Key_LogOff),
285 std::make_pair(XF86XK_Market, Qt::Key_Market),
286 std::make_pair(XF86XK_Meeting, Qt::Key_Meeting),
287 std::make_pair(XF86XK_MenuKB, Qt::Key_MenuKB),
288 std::make_pair(XF86XK_MenuPB, Qt::Key_MenuPB),
289 std::make_pair(XF86XK_MySites, Qt::Key_MySites),
290 std::make_pair(XF86XK_News, Qt::Key_News),
291 std::make_pair(XF86XK_OfficeHome, Qt::Key_OfficeHome),
292 std::make_pair(XF86XK_Option, Qt::Key_Option),
293 std::make_pair(XF86XK_Paste, Qt::Key_Paste),
294 std::make_pair(XF86XK_Phone, Qt::Key_Phone),
295 std::make_pair(XF86XK_Calendar, Qt::Key_Calendar),
296 std::make_pair(XF86XK_Reply, Qt::Key_Reply),
297 std::make_pair(XF86XK_Reload, Qt::Key_Reload),
298 std::make_pair(XF86XK_RotateWindows, Qt::Key_RotateWindows),
299 std::make_pair(XF86XK_RotationPB, Qt::Key_RotationPB),
300 std::make_pair(XF86XK_RotationKB, Qt::Key_RotationKB),
301 std::make_pair(XF86XK_Save, Qt::Key_Save),
302 std::make_pair(XF86XK_Send, Qt::Key_Send),
303 std::make_pair(XF86XK_Spell, Qt::Key_Spell),
304 std::make_pair(XF86XK_SplitScreen, Qt::Key_SplitScreen),
305 std::make_pair(XF86XK_Support, Qt::Key_Support),
306 std::make_pair(XF86XK_TaskPane, Qt::Key_TaskPane),
307 std::make_pair(XF86XK_Terminal, Qt::Key_Terminal),
308 std::make_pair(XF86XK_Tools, Qt::Key_Tools),
309 std::make_pair(XF86XK_Travel, Qt::Key_Travel),
310 std::make_pair(XF86XK_Video, Qt::Key_Video),
311 std::make_pair(XF86XK_Word, Qt::Key_Word),
312 std::make_pair(XF86XK_Xfer, Qt::Key_Xfer),
313 std::make_pair(XF86XK_ZoomIn, Qt::Key_ZoomIn),
314 std::make_pair(XF86XK_ZoomOut, Qt::Key_ZoomOut),
315 std::make_pair(XF86XK_Away, Qt::Key_Away),
316 std::make_pair(XF86XK_Messenger, Qt::Key_Messenger),
317 std::make_pair(XF86XK_WebCam, Qt::Key_WebCam),
318 std::make_pair(XF86XK_MailForward, Qt::Key_MailForward),
319 std::make_pair(XF86XK_Pictures, Qt::Key_Pictures),
320 std::make_pair(XF86XK_Music, Qt::Key_Music),
321 std::make_pair(XF86XK_Battery, Qt::Key_Battery),
322 std::make_pair(XF86XK_Bluetooth, Qt::Key_Bluetooth),
323 std::make_pair(XF86XK_WLAN, Qt::Key_WLAN),
324 std::make_pair(XF86XK_UWB, Qt::Key_UWB),
325 std::make_pair(XF86XK_AudioForward, Qt::Key_AudioForward),
326 std::make_pair(XF86XK_AudioRepeat, Qt::Key_AudioRepeat),
327 std::make_pair(XF86XK_AudioRandomPlay, Qt::Key_AudioRandomPlay),
328 std::make_pair(XF86XK_Subtitle, Qt::Key_Subtitle),
329 std::make_pair(XF86XK_AudioCycleTrack, Qt::Key_AudioCycleTrack),
330 std::make_pair(XF86XK_Time, Qt::Key_Time),
331 std::make_pair(XF86XK_Hibernate, Qt::Key_Hibernate),
332 std::make_pair(XF86XK_View, Qt::Key_View),
333 std::make_pair(XF86XK_TopMenu, Qt::Key_TopMenu),
334 std::make_pair(XF86XK_PowerDown, Qt::Key_PowerDown),
335 std::make_pair(XF86XK_Suspend, Qt::Key_Suspend),
336 std::make_pair(XF86XK_ContrastAdjust, Qt::Key_ContrastAdjust),
337
338 std::make_pair(XF86XK_LaunchE, Qt::Key_LaunchG),
339 std::make_pair(XF86XK_LaunchF, Qt::Key_LaunchH),
340
341 std::make_pair(XF86XK_Select, Qt::Key_Select),
342 std::make_pair(XK_Cancel, Qt::Key_Cancel),
343 std::make_pair(XK_Execute, Qt::Key_Execute),
344 std::make_pair(XF86XK_Sleep, Qt::Key_Sleep),
345 };
346 return keyTbl;
347 }
348
349 int keysymToQtKey(uint32_t key) {
350 auto iter = KeyTbl().find(key);
351 if (iter != KeyTbl().end()) {
352 return iter->second;
353 }
354 return 0;
355 }
356
357 int keysymToQtKey(uint32_t keysym, const QString &text) {
358 int code = 0;
359 if (keysym < 128) {
360 // upper-case key, if known
361 code = isprint((int)keysym) ? toupper((int)keysym) : 0;
362 } else if (text.length() == 1 && text.unicode()->unicode() > 0x1f &&
363 text.unicode()->unicode() != 0x7f &&
364 !(keysym >= XK_dead_grave && keysym <= XK_dead_currency)) {
365 code = text.unicode()->toUpper().unicode();
366 } else {
367 // any other keys
368 code = keysymToQtKey(keysym);
369 }
370
371 return code;
372 }