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