1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: keysymnames.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
35 #include <tools/prex.h>
36 #include <X11/XKBlib.h>
37 #include <tools/postx.h>
40 #include <saldisp.hxx>
41 #include <X11/keysym.h>
43 #if !defined (SunXK_Undo)
44 #define SunXK_Undo 0x0000FF65 // XK_Undo
45 #define SunXK_Again 0x0000FF66 // XK_Redo
46 #define SunXK_Find 0x0000FF68 // XK_Find
47 #define SunXK_Stop 0x0000FF69 // XK_Cancel
48 #define SunXK_Props 0x1005FF70
49 #define SunXK_Front 0x1005FF71
50 #define SunXK_Copy 0x1005FF72
51 #define SunXK_Open 0x1005FF73
52 #define SunXK_Paste 0x1005FF74
53 #define SunXK_Cut 0x1005FF75
57 #include <sys/types.h>
58 #include <sys/ioctl.h>
72 struct KeysymNameReplacement
78 struct KeyboardReplacements
80 const char* pKeyboardName
;
81 const KeysymNameReplacement
* pReplacements
;
85 // ====================================================================
87 // CAUTION CAUTION CAUTION
88 // every string value in the replacements tables must be in UTF8
89 // be careful with your editor !
91 // ====================================================================
93 static const struct KeysymNameReplacement aImplReplacements_English
[] =
95 { XK_Control_L
, "Ctrl" },
96 { XK_Control_R
, "Ctrl" },
98 { XK_space
, "Space" },
103 static const struct KeysymNameReplacement aImplReplacements_Turkish
[] =
105 { XK_Control_L
, "Ctrl" },
106 { XK_Control_R
, "Ctrl" },
110 { XK_Down
, "Aşağı" },
111 { XK_space
, "Boşluk" }
114 static const struct KeysymNameReplacement aImplReplacements_Russian
[] =
116 { XK_Right
, "Вправо" },
117 { XK_Left
, "Влево" },
120 { XK_space
, "Пробел" }
123 static const struct KeysymNameReplacement aImplReplacements_German
[] =
125 { XK_Control_L
, "Strg" },
126 { XK_Control_R
, "Strg" },
127 { XK_Shift_L
, "Umschalt" },
128 { XK_Shift_R
, "Umschalt" },
130 { XK_Alt_R
, "Alt Gr" },
131 { XK_Page_Up
, "Bild auf" },
132 { XK_Page_Down
, "Bild ab" },
134 { XK_Home
, "Pos 1" },
135 { XK_Insert
, "Einfg" },
136 { XK_Delete
, "Entf" },
137 { XK_Escape
, "Esc" },
138 { XK_Right
, "Rechts" },
139 { XK_Left
, "Links" },
141 { XK_Down
, "Unten" },
142 { XK_BackSpace
, "Rückschritt" },
143 { XK_Return
, "Eingabe" },
144 { XK_slash
, "Schrägstrich" },
145 { XK_space
, "Leertaste" },
146 { SunXK_Stop
, "Stop" },
147 { SunXK_Again
, "Wiederholen" },
148 { SunXK_Props
, "Eigenschaften" },
149 { SunXK_Undo
, "Zurücknehmen" },
150 { SunXK_Front
, "Vordergrund" },
151 { SunXK_Copy
, "Kopieren" },
152 { SunXK_Open
, "Öffnen" },
153 { SunXK_Paste
, "Einsetzen" },
154 { SunXK_Find
, "Suchen" },
155 { SunXK_Cut
, "Ausschneiden" },
160 static const struct KeysymNameReplacement aImplReplacements_French
[] =
162 { XK_Shift_L
, "Maj" },
163 { XK_Shift_R
, "Maj" },
164 { XK_Page_Up
, "Pg. Préc" },
165 { XK_Page_Down
, "Pg. Suiv" },
167 { XK_Home
, "Origine" },
168 { XK_Insert
, "Insérer" },
169 { XK_Delete
, "Suppr" },
170 { XK_Escape
, "Esc" },
171 { XK_Right
, "Droite" },
172 { XK_Left
, "Gauche" },
175 { XK_BackSpace
, "Ret. Arr" },
176 { XK_Return
, "Retour" },
177 { XK_KP_Enter
, "Entrée" },
178 { SunXK_Stop
, "Stop" },
179 { SunXK_Again
, "Encore" },
180 { SunXK_Props
, "Props" },
181 { SunXK_Undo
, "Annuler" },
182 { SunXK_Front
, "Devant" },
183 { SunXK_Copy
, "Copy" },
184 { SunXK_Open
, "Ouvrir" },
185 { SunXK_Paste
, "Coller" },
186 { SunXK_Find
, "Cher." },
187 { SunXK_Cut
, "Couper" },
192 static const struct KeysymNameReplacement aImplReplacements_Italian
[] =
194 { XK_Shift_L
, "Maiusc" },
195 { XK_Shift_R
, "Maiusc" },
196 { XK_Page_Up
, "PgSu" },
197 { XK_Page_Down
, "PgGiu" },
199 { XK_Insert
, "Ins" },
200 { XK_Delete
, "Canc" },
201 { XK_Escape
, "Esc" },
202 { XK_Right
, "A destra" },
203 { XK_Left
, "A sinistra" },
204 { XK_Up
, "Sposta verso l'alto" },
205 { XK_Down
, "Sposta verso il basso" },
206 { XK_BackSpace
, "Backspace" },
207 { XK_Return
, "Invio" },
208 { XK_space
, "Spazio" },
209 { SunXK_Stop
, "Stop" },
210 { SunXK_Again
, "Ancora" },
211 { SunXK_Props
, "Proprietà" },
212 { SunXK_Undo
, "Annulla" },
213 { SunXK_Front
, "Davanti" },
214 { SunXK_Copy
, "Copia" },
215 { SunXK_Open
, "Apri" },
216 { SunXK_Paste
, "Incolla" },
217 { SunXK_Find
, "Trova" },
218 { SunXK_Cut
, "Taglia" },
223 static const struct KeysymNameReplacement aImplReplacements_Dutch
[] =
225 { XK_Page_Up
, "PageUp" },
226 { XK_Page_Down
, "PageDown" },
227 { XK_Escape
, "Esc" },
228 { XK_Right
, "Rechts" },
229 { XK_Left
, "Links" },
231 { XK_Down
, "Onder" },
232 { XK_BackSpace
, "Backspace" },
233 { XK_Return
, "Return" },
234 { XK_space
, "Spatiebalk" },
235 { SunXK_Stop
, "Stop" },
236 { SunXK_Again
, "Again" },
237 { SunXK_Props
, "Props" },
238 { SunXK_Undo
, "Undo" },
239 { SunXK_Front
, "Front" },
240 { SunXK_Copy
, "Copy" },
241 { SunXK_Open
, "Open" },
242 { SunXK_Paste
, "Paste" },
243 { SunXK_Find
, "Find" },
244 { SunXK_Cut
, "Cut" },
249 static const struct KeysymNameReplacement aImplReplacements_Norwegian
[] =
251 { XK_Shift_L
, "Skift" },
252 { XK_Shift_R
, "Skift" },
253 { XK_Page_Up
, "PageUp" },
254 { XK_Page_Down
, "PageDown" },
255 { XK_Escape
, "Esc" },
256 { XK_Right
, "Hyre" },
257 { XK_Left
, "Venstre" },
260 { XK_BackSpace
, "Tilbake" },
261 { XK_Return
, "Enter" },
262 { SunXK_Stop
, "Avbryt" },
263 { SunXK_Again
, "Gjenta" },
264 { SunXK_Props
, "Egenskaper" },
265 { SunXK_Undo
, "Angre" },
266 { SunXK_Front
, "Front" },
267 { SunXK_Copy
, "Kopi" },
268 { SunXK_Open
, "Åpne" },
269 { SunXK_Paste
, "Lim" },
270 { SunXK_Find
, "Søk" },
271 { SunXK_Cut
, "Klipp" },
276 static const struct KeysymNameReplacement aImplReplacements_Swedish
[] =
278 { XK_Shift_L
, "Skift" },
279 { XK_Shift_R
, "Skift" },
280 { XK_Page_Up
, "PageUp" },
281 { XK_Page_Down
, "PageDown" },
282 { XK_Escape
, "Esc" },
283 { XK_Right
, "Höger" },
284 { XK_Left
, "Vänster" },
287 { XK_BackSpace
, "Backsteg" },
288 { XK_Return
, "Retur" },
289 { XK_space
, "Blank" },
290 { SunXK_Stop
, "Avbryt" },
291 { SunXK_Again
, "Upprepa" },
292 { SunXK_Props
, "Egenskaper" },
293 { SunXK_Undo
, "Ångra" },
294 { SunXK_Front
, "Fram" },
295 { SunXK_Copy
, "Kopiera" },
296 { SunXK_Open
, "Öppna" },
297 { SunXK_Paste
, "Klistra in" },
298 { SunXK_Find
, "Sök" },
299 { SunXK_Cut
, "Klipp ut" },
304 static const struct KeysymNameReplacement aImplReplacements_Portuguese
[] =
306 { XK_Page_Up
, "PageUp" },
307 { XK_Page_Down
, "PageDown" },
308 { XK_Escape
, "Esc" },
309 { XK_Right
, "Direita" },
310 { XK_Left
, "Esquerda" },
312 { XK_Down
, "Abaixo" },
313 { XK_BackSpace
, "Backspace" },
314 { XK_Return
, "Enter" },
315 { XK_slash
, "Barra" },
316 { SunXK_Stop
, "Stop" },
317 { SunXK_Again
, "Again" },
318 { SunXK_Props
, "Props" },
319 { SunXK_Undo
, "Undo" },
320 { SunXK_Front
, "Front" },
321 { SunXK_Copy
, "Copy" },
322 { SunXK_Open
, "Open" },
323 { SunXK_Paste
, "Paste" },
324 { SunXK_Find
, "Find" },
325 { SunXK_Cut
, "Cut" },
330 static const struct KeysymNameReplacement aImplReplacements_Spanish
[] =
332 { XK_Shift_L
, "Mayús" },
333 { XK_Shift_R
, "Mayús" },
334 { XK_Page_Up
, "RePág" },
335 { XK_Page_Down
, "AvPág" },
337 { XK_Home
, "Inicio" },
338 { XK_Delete
, "Supr" },
339 { XK_Escape
, "Esc" },
340 { XK_Right
, "Hacia la derecha" },
341 { XK_Left
, "Hacia la izquierda" },
342 { XK_Up
, "Hacia arriba" },
343 { XK_Down
, "Hacia abajo" },
344 { XK_BackSpace
, "Ret" },
345 { XK_Return
, "Entrada" },
346 { XK_space
, "Espacio" },
347 { XK_KP_Enter
, "Intro" },
348 { SunXK_Stop
, "Stop" },
349 { SunXK_Again
, "Repetir" },
350 { SunXK_Props
, "Props" },
351 { SunXK_Undo
, "Anular" },
352 { SunXK_Front
, "Delante" },
353 { SunXK_Copy
, "Copiar" },
354 { SunXK_Open
, "Abrir" },
355 { SunXK_Paste
, "Pegar" },
356 { SunXK_Find
, "Buscar" },
357 { SunXK_Cut
, "Cortar" },
362 static const struct KeyboardReplacements aKeyboards
[] =
365 { "Germany5", aImplReplacements_German
, sizeof(aImplReplacements_German
)/sizeof(aImplReplacements_German
[0]) },
366 { "Germany4", aImplReplacements_German
, sizeof(aImplReplacements_German
)/sizeof(aImplReplacements_German
[0]) },
367 { "France5", aImplReplacements_French
, sizeof(aImplReplacements_French
)/sizeof(aImplReplacements_French
[0]) },
368 { "France6", aImplReplacements_French
, sizeof(aImplReplacements_French
)/sizeof(aImplReplacements_French
[0]) },
369 { "France_x86", aImplReplacements_French
, sizeof(aImplReplacements_French
)/sizeof(aImplReplacements_French
[0]) },
370 { "Italy5", aImplReplacements_Italian
, sizeof(aImplReplacements_Italian
)/sizeof(aImplReplacements_Italian
[0]) },
371 { "Italy5-Hobo", aImplReplacements_Italian
, sizeof(aImplReplacements_Italian
)/sizeof(aImplReplacements_Italian
[0]) },
372 { "Italy4", aImplReplacements_Italian
, sizeof(aImplReplacements_Italian
)/sizeof(aImplReplacements_Italian
[0]) },
373 { "Italy6", aImplReplacements_Italian
, sizeof(aImplReplacements_Italian
)/sizeof(aImplReplacements_Italian
[0]) },
374 { "Italy_x86", aImplReplacements_Italian
, sizeof(aImplReplacements_Italian
)/sizeof(aImplReplacements_Italian
[0]) },
375 { "Netherland4", aImplReplacements_Dutch
, sizeof(aImplReplacements_Dutch
)/sizeof(aImplReplacements_Dutch
[0]) },
376 { "Netherland5", aImplReplacements_Dutch
, sizeof(aImplReplacements_Dutch
)/sizeof(aImplReplacements_Dutch
[0]) },
377 { "Netherland5-Hobo", aImplReplacements_Dutch
, sizeof(aImplReplacements_Dutch
)/sizeof(aImplReplacements_Dutch
[0]) },
378 { "Netherland6", aImplReplacements_Dutch
, sizeof(aImplReplacements_Dutch
)/sizeof(aImplReplacements_Dutch
[0]) },
379 { "Netherland_x86", aImplReplacements_Dutch
, sizeof(aImplReplacements_Dutch
)/sizeof(aImplReplacements_Dutch
[0]) },
380 { "Norway5", aImplReplacements_Norwegian
, sizeof(aImplReplacements_Norwegian
)/sizeof(aImplReplacements_Norwegian
[0]) },
381 { "Norway5-Hobo", aImplReplacements_Norwegian
, sizeof(aImplReplacements_Norwegian
)/sizeof(aImplReplacements_Norwegian
[0]) },
382 { "Norway4", aImplReplacements_Norwegian
, sizeof(aImplReplacements_Norwegian
)/sizeof(aImplReplacements_Norwegian
[0]) },
383 { "Norway6", aImplReplacements_Norwegian
, sizeof(aImplReplacements_Norwegian
)/sizeof(aImplReplacements_Norwegian
[0]) },
384 { "Norway_x86", aImplReplacements_Norwegian
, sizeof(aImplReplacements_Norwegian
)/sizeof(aImplReplacements_Norwegian
[0]) },
385 { "Portugal5", aImplReplacements_Portuguese
, sizeof(aImplReplacements_Portuguese
)/sizeof(aImplReplacements_Portuguese
[0]) },
386 { "Portugal5-Hobo", aImplReplacements_Portuguese
, sizeof(aImplReplacements_Portuguese
)/sizeof(aImplReplacements_Portuguese
[0]) },
387 { "Portugal4", aImplReplacements_Portuguese
, sizeof(aImplReplacements_Portuguese
)/sizeof(aImplReplacements_Portuguese
[0]) },
388 { "Portugal6", aImplReplacements_Portuguese
, sizeof(aImplReplacements_Portuguese
)/sizeof(aImplReplacements_Portuguese
[0]) },
389 { "Portugal_x86", aImplReplacements_Portuguese
, sizeof(aImplReplacements_Portuguese
)/sizeof(aImplReplacements_Portuguese
[0]) },
390 { "Spain5", aImplReplacements_Spanish
, sizeof(aImplReplacements_Spanish
)/sizeof(aImplReplacements_Spanish
[0]) },
391 { "Spain5-Hobo", aImplReplacements_Spanish
, sizeof(aImplReplacements_Spanish
)/sizeof(aImplReplacements_Spanish
[0]) },
392 { "Spain4", aImplReplacements_Spanish
, sizeof(aImplReplacements_Spanish
)/sizeof(aImplReplacements_Spanish
[0]) },
393 { "Spain6", aImplReplacements_Spanish
, sizeof(aImplReplacements_Spanish
)/sizeof(aImplReplacements_Spanish
[0]) },
394 { "Spain_x86", aImplReplacements_Spanish
, sizeof(aImplReplacements_Spanish
)/sizeof(aImplReplacements_Spanish
[0]) },
395 { "Sweden5", aImplReplacements_Swedish
, sizeof(aImplReplacements_Swedish
)/sizeof(aImplReplacements_Swedish
[0]) },
396 { "Sweden5-Hobo", aImplReplacements_Swedish
, sizeof(aImplReplacements_Swedish
)/sizeof(aImplReplacements_Swedish
[0]) },
397 { "Sweden4", aImplReplacements_Swedish
, sizeof(aImplReplacements_Swedish
)/sizeof(aImplReplacements_Swedish
[0]) },
398 { "Sweden6", aImplReplacements_Swedish
, sizeof(aImplReplacements_Swedish
)/sizeof(aImplReplacements_Swedish
[0]) },
399 { "Sweden_x86", aImplReplacements_Swedish
, sizeof(aImplReplacements_Swedish
)/sizeof(aImplReplacements_Swedish
[0]) },
401 { "U.S. English", aImplReplacements_English
, sizeof(aImplReplacements_English
)/sizeof(aImplReplacements_English
[0]) },
402 { "United Kingdom", aImplReplacements_English
, sizeof(aImplReplacements_English
)/sizeof(aImplReplacements_English
[0]) },
404 { "German", aImplReplacements_German
, sizeof(aImplReplacements_German
)/sizeof(aImplReplacements_German
[0]) },
405 { "France", aImplReplacements_French
, sizeof(aImplReplacements_French
)/sizeof(aImplReplacements_French
[0]) },
406 { "French", aImplReplacements_French
, sizeof(aImplReplacements_French
)/sizeof(aImplReplacements_French
[0]) },
408 { "Ital", aImplReplacements_Italian
, sizeof(aImplReplacements_Italian
)/sizeof(aImplReplacements_Italian
[0]) },
410 { "Norw", aImplReplacements_Norwegian
, sizeof(aImplReplacements_Norwegian
)/sizeof(aImplReplacements_Norwegian
[0]) },
411 // Portugal, Portuguese
412 { "Portu", aImplReplacements_Portuguese
, sizeof(aImplReplacements_Portuguese
)/sizeof(aImplReplacements_Portuguese
[0]) },
413 { "Spain", aImplReplacements_Spanish
, sizeof(aImplReplacements_Spanish
)/sizeof(aImplReplacements_Spanish
[0]) },
414 { "Spanish", aImplReplacements_Spanish
, sizeof(aImplReplacements_Spanish
)/sizeof(aImplReplacements_Spanish
[0]) },
416 { "Swed", aImplReplacements_Swedish
, sizeof(aImplReplacements_Swedish
)/sizeof(aImplReplacements_Swedish
[0]) },
417 { "Netherland", aImplReplacements_Dutch
, sizeof(aImplReplacements_Dutch
)/sizeof(aImplReplacements_Dutch
[0]) },
418 { "Dutch", aImplReplacements_Dutch
, sizeof(aImplReplacements_Dutch
)/sizeof(aImplReplacements_Dutch
[0]) },
420 { "Turk", aImplReplacements_Turkish
, sizeof(aImplReplacements_Turkish
)/sizeof(aImplReplacements_Turkish
[0]) },
422 { "Russia", aImplReplacements_Russian
, sizeof(aImplReplacements_Russian
)/sizeof(aImplReplacements_Russian
[0]) },
423 { "English", aImplReplacements_English
, sizeof(aImplReplacements_English
)/sizeof(aImplReplacements_English
[0]) }
426 String
getKeysymReplacementName( const char* pKeyboard
, KeySym nSymbol
)
428 for( unsigned int n
= 0; n
< sizeof(aKeyboards
)/sizeof(aKeyboards
[0]); n
++ )
430 if( ! strncasecmp( pKeyboard
, aKeyboards
[n
].pKeyboardName
, strlen( aKeyboards
[n
].pKeyboardName
) ) )
432 const struct KeysymNameReplacement
* pRepl
= aKeyboards
[n
].pReplacements
;
433 for( int m
= aKeyboards
[n
].nReplacements
; m
; )
435 if( nSymbol
== pRepl
[--m
].aSymbol
)
436 return String( pRepl
[m
].pName
, RTL_TEXTENCODING_UTF8
);
440 // try english fallbacks
441 const struct KeysymNameReplacement
* pRepl
= aImplReplacements_English
;
442 for( int m
= sizeof(aImplReplacements_English
)/sizeof(aImplReplacements_English
[0]) ; m
; )
444 if( nSymbol
== pRepl
[--m
].aSymbol
)
445 return String( pRepl
[m
].pName
, RTL_TEXTENCODING_UTF8
);
455 const char* p_description
;
458 static const keyboard_layout type0_layout
[] =
464 static const keyboard_layout type3_layout
[] =
470 static const keyboard_layout type4_layout
[] =
474 { 2, "FranceBelg4" },
479 { 7, "Netherland4" },
482 { 10, "SpainLatAm4" },
483 { 11, "SwedenFin4" },
484 { 12, "Switzer_Fr4" },
485 { 13, "Switzer_Ge4" },
490 { 19, "US101A_Sun" },
498 { 39, "Netherland5" },
503 { 44, "Switzer_Fr5" },
504 { 45, "Switzer_Ge5" },
509 { 50, "Canada_Fr5" },
518 { 59, "Lithuania5" },
519 { 63, "Canada_Fr5_TBITS5" },
521 { 81, "US_UNIX5_Hobo" },
522 { 82, "France5_Hobo" },
523 { 83, "Denmark5_Hobo" },
524 { 84, "Germany5_Hobo" },
525 { 85, "Italy5_Hobo" },
526 { 86, "Netherland5_Hobo" },
527 { 87, "Norway5_Hobo" },
528 { 88, "Portugal5_Hobo" },
529 { 89, "Spain5_Hobo" },
530 { 90, "Sweden5_Hobo" },
531 { 91, "Switzer_Fr5_Hobo" },
532 { 92, "Switzer_Ge5_Hobo" },
534 { 94, "Korea5_Hobo" },
535 { 95, "Taiwan5_Hobo" },
536 { 96, "Japan5_Hobo" },
537 { 97, "Canada_Fr5_Hobo" },
541 static const keyboard_layout type101_layout
[] =
546 { 35, "France_x86" },
547 { 36, "Denmark_x86" },
548 { 37, "Germany_x86" },
550 { 39, "Netherland_x86" },
551 { 40, "Norway_x86" },
552 { 41, "Portugal_x86" },
554 { 43, "Sweden_x86" },
555 { 44, "Switzer_Fr_x86" },
556 { 45, "Switzer_Ge_x86" },
559 { 48, "Taiwan_x86" },
561 { 50, "Canada_Fr2_x86" },
562 { 51, "Hungary_x86" },
563 { 52, "Poland_x86" },
565 { 54, "Russia_x86" },
566 { 55, "Latvia_x86" },
567 { 56, "Turkey_x86" },
568 { 57, "Greece_x86" },
569 { 59, "Lithuania_x86" },
570 { 1001, "MS_US101A_x86" },
574 static const keyboard_layout type6_layout
[] =
584 { 18, "Netherland6" },
589 { 27, "Switzer_Fr6" },
590 { 28, "Switzer_Ge6" },
599 #if OSL_DEBUG_LEVEL > 1
603 const char* SalDisplay::GetKeyboardName( BOOL bRefresh
)
605 if( bRefresh
|| ! m_aKeyboardName
.Len() )
610 int kbd
= open( "/dev/kbd", O_RDONLY
);
614 if( ! ioctl( kbd
, KIOCTYPE
, &kbd_type
) )
617 if( ! ioctl( kbd
, KIOCLAYOUT
, &kbd_layout
) )
619 const keyboard_layout
*p_layout
= NULL
;
622 case KB_KLUNK
: p_layout
= type0_layout
; break;
623 case KB_SUN3
: p_layout
= type3_layout
; break;
624 case KB_SUN4
: p_layout
= type4_layout
; break;
625 case KB_USB
: p_layout
= type6_layout
; break;
626 case KB_PC
: p_layout
= type101_layout
; break;
631 while( p_layout
->n_layout
!= -1 )
633 if ( p_layout
->n_layout
== kbd_layout
)
635 m_aKeyboardName
= p_layout
->p_description
;
646 int opcode
, event
, error
;
647 int major
= XkbMajorVersion
, minor
= XkbMinorVersion
;
648 if( XkbQueryExtension( GetDisplay(), &opcode
, &event
,&error
, &major
, &minor
) )
650 XkbDescPtr pXkbDesc
= NULL
;
651 // try X keyboard extension
652 if( (pXkbDesc
= XkbGetKeyboard( GetDisplay(), XkbAllComponentsMask
, XkbUseCoreKbd
)) )
654 const char* pAtom
= NULL
;
655 if( pXkbDesc
->names
->groups
[0] )
657 pAtom
= XGetAtomName( GetDisplay(), pXkbDesc
->names
->groups
[0] );
658 m_aKeyboardName
= pAtom
;
659 XFree( (void*)pAtom
);
662 m_aKeyboardName
= "<unknown keyboard>";
663 #if OSL_DEBUG_LEVEL > 1
664 #define PRINT_ATOM( x ) { if( pXkbDesc->names->x ) { pAtom = XGetAtomName( GetDisplay(), pXkbDesc->names->x ); fprintf( stderr, "%s: %s\n", #x, pAtom ); XFree( (void*)pAtom ); } else fprintf( stderr, "%s: <nil>\n", #x ); }
666 PRINT_ATOM( keycodes
);
667 PRINT_ATOM( geometry
);
668 PRINT_ATOM( symbols
);
670 PRINT_ATOM( compat
);
671 PRINT_ATOM( phys_symbols
);
673 #define PRINT_ATOM_2( x ) { if( pXkbDesc->names->x[i] ) { pAtom = XGetAtomName( GetDisplay(), pXkbDesc->names->x[i] ); fprintf( stderr, "%s[%d]: %s\n", #x, i, pAtom ); XFree( (void*)pAtom ); } else fprintf( stderr, "%s[%d]: <nil>\n", #x, i ); }
675 for( i
= 0; i
< XkbNumVirtualMods
; i
++ )
676 PRINT_ATOM_2( vmods
);
677 for( i
= 0; i
< XkbNumIndicators
; i
++ )
678 PRINT_ATOM_2( indicators
);
679 for( i
= 0; i
< XkbNumKbdGroups
; i
++ )
680 PRINT_ATOM_2( groups
);
682 XkbFreeKeyboard( pXkbDesc
, XkbAllComponentsMask
, True
);
686 if( ! m_aKeyboardName
.Len() )
687 m_aKeyboardName
= "<unknown keyboard>";
689 return m_aKeyboardName
.GetBuffer();