Update ooo320-m1
[ooovba.git] / vcl / unx / source / app / keysymnames.cxx
blob62210485bba31233791093657ff2f3093d5533a2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: keysymnames.cxx,v $
10 * $Revision: 1.22 $
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"
34 #ifndef SOLARIS
35 #include <tools/prex.h>
36 #include <X11/XKBlib.h>
37 #include <tools/postx.h>
38 #endif
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
54 #endif
56 #ifdef SOLARIS
57 #include <sys/types.h>
58 #include <sys/ioctl.h>
59 #include <sys/kbio.h>
60 #include <sys/kbd.h>
61 #include <stdio.h>
62 #include <fcntl.h>
63 #include <deflt.h>
64 #include <unistd.h>
65 #include <stdlib.h>
66 #endif
68 #include <string.h>
70 namespace vcl_sal {
72 struct KeysymNameReplacement
74 KeySym aSymbol;
75 const char* pName;
78 struct KeyboardReplacements
80 const char* pKeyboardName;
81 const KeysymNameReplacement* pReplacements;
82 int nReplacements;
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" },
97 { XK_Escape, "Esc" },
98 { XK_space, "Space" },
99 { XK_minus, "-" },
100 { XK_plus, "+" }
103 static const struct KeysymNameReplacement aImplReplacements_Turkish[] =
105 { XK_Control_L, "Ctrl" },
106 { XK_Control_R, "Ctrl" },
107 { XK_Right, "Sağ" },
108 { XK_Left, "Sol" },
109 { XK_Up, "Yukarı" },
110 { XK_Down, "Aşağı" },
111 { XK_space, "Boşluk" }
114 static const struct KeysymNameReplacement aImplReplacements_Russian[] =
116 { XK_Right, "Вправо" },
117 { XK_Left, "Влево" },
118 { XK_Up, "Вверх" },
119 { XK_Down, "Вниз" },
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" },
129 { XK_Alt_L, "Alt" },
130 { XK_Alt_R, "Alt Gr" },
131 { XK_Page_Up, "Bild auf" },
132 { XK_Page_Down, "Bild ab" },
133 { XK_End, "Ende" },
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" },
140 { XK_Up, "Oben" },
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" },
156 { XK_minus, "-" },
157 { XK_plus, "+" }
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" },
166 { XK_End, "Fin" },
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" },
173 { XK_Up, "Haut" },
174 { XK_Down, "Bas" },
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" },
188 { XK_minus, "-" },
189 { XK_plus, "+" }
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" },
198 { XK_End, "Fine" },
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" },
219 { XK_minus, "-" },
220 { XK_plus, "+" }
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" },
230 { XK_Up, "Boven" },
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" },
245 { XK_minus, "-" },
246 { XK_plus, "+" }
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" },
258 { XK_Up, "Opp" },
259 { XK_Down, "Ned" },
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" },
272 { XK_minus, "-" },
273 { XK_plus, "+" }
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" },
285 { XK_Up, "Up" },
286 { XK_Down, "Ned" },
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" },
300 { XK_minus, "-" },
301 { XK_plus, "+" }
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" },
311 { XK_Up, "Acima" },
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" },
326 { XK_minus, "-" },
327 { XK_plus, "+" }
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" },
336 { XK_End, "Fin" },
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" },
358 { XK_minus, "-" },
359 { XK_plus, "+" }
362 static const struct KeyboardReplacements aKeyboards[] =
364 #ifdef SOLARIS
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]) },
400 #endif
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]) },
403 // Germany, German
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]) },
407 // Italy, Italian
408 { "Ital", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
409 // Norway, Norwegian
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]) },
415 // Sweden, Swedish
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]) },
419 // Turkish, Turkey
420 { "Turk", aImplReplacements_Turkish, sizeof(aImplReplacements_Turkish)/sizeof(aImplReplacements_Turkish[0]) },
421 // Russian, Russia
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 );
447 return String();
452 #ifdef SOLARIS
453 typedef struct {
454 int n_layout;
455 const char* p_description;
456 } keyboard_layout;
458 static const keyboard_layout type0_layout[] =
460 { 0, "US4" },
461 { -1, NULL }
464 static const keyboard_layout type3_layout[] =
466 { 0, "US3" },
467 { -1, NULL }
470 static const keyboard_layout type4_layout[] =
472 { 0, "US4" },
473 { 1, "US4" },
474 { 2, "FranceBelg4" },
475 { 3, "Canada4" },
476 { 4, "Denmark4" },
477 { 5, "Germany4" },
478 { 6, "Italy4" },
479 { 7, "Netherland4" },
480 { 8, "Norway4" },
481 { 9, "Portugal4" },
482 { 10, "SpainLatAm4" },
483 { 11, "SwedenFin4" },
484 { 12, "Switzer_Fr4" },
485 { 13, "Switzer_Ge4" },
486 { 14, "UK4" },
487 { 16, "Korea4" },
488 { 17, "Taiwan4" },
489 { 19, "US101A_PC" },
490 { 19, "US101A_Sun" },
491 { 32, "Japan4" },
492 { 33, "US5" },
493 { 34, "US_UNIX5" },
494 { 35, "France5" },
495 { 36, "Denmark5" },
496 { 37, "Germany5" },
497 { 38, "Italy5" },
498 { 39, "Netherland5" },
499 { 40, "Norway5" },
500 { 41, "Portugal5" },
501 { 42, "Spain5" },
502 { 43, "Sweden5" },
503 { 44, "Switzer_Fr5" },
504 { 45, "Switzer_Ge5" },
505 { 46, "UK5" },
506 { 47, "Korea5" },
507 { 48, "Taiwan5" },
508 { 49, "Japan5" },
509 { 50, "Canada_Fr5" },
510 { 51, "Hungary5" },
511 { 52, "Poland5" },
512 { 53, "Czech5" },
513 { 54, "Russia5" },
514 { 55, "Latvia5" },
515 { 56, "Turkey5" },
516 { 57, "Greece5" },
517 { 58, "Estonia5" },
518 { 59, "Lithuania5" },
519 { 63, "Canada_Fr5_TBITS5" },
520 { 80, "US5_Hobo" },
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" },
533 { 93, "UK5_Hobo" },
534 { 94, "Korea5_Hobo" },
535 { 95, "Taiwan5_Hobo" },
536 { 96, "Japan5_Hobo" },
537 { 97, "Canada_Fr5_Hobo" },
538 { -1, NULL }
541 static const keyboard_layout type101_layout[] =
543 { 0, "US101A_x86" },
544 { 1, "US101A_x86" },
545 { 34, "J3100_x86" },
546 { 35, "France_x86" },
547 { 36, "Denmark_x86" },
548 { 37, "Germany_x86" },
549 { 38, "Italy_x86" },
550 { 39, "Netherland_x86" },
551 { 40, "Norway_x86" },
552 { 41, "Portugal_x86" },
553 { 42, "Spain_x86" },
554 { 43, "Sweden_x86" },
555 { 44, "Switzer_Fr_x86" },
556 { 45, "Switzer_Ge_x86" },
557 { 46, "UK_x86" },
558 { 47, "Korea_x86" },
559 { 48, "Taiwan_x86" },
560 { 49, "Japan_x86" },
561 { 50, "Canada_Fr2_x86" },
562 { 51, "Hungary_x86" },
563 { 52, "Poland_x86" },
564 { 53, "Czech_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" },
571 { -1, NULL }
574 static const keyboard_layout type6_layout[] =
576 { 0, "US6" },
577 { 6, "Denmark6" },
578 { 7, "Finnish6" },
579 { 8, "France6" },
580 { 9, "Germany6" },
581 { 14, "Italy6" },
582 { 15, "Japan6" },
583 { 16, "Korea6" },
584 { 18, "Netherland6" },
585 { 19, "Norway6" },
586 { 22, "Portugal6" },
587 { 25, "Spain6" },
588 { 26, "Sweden6" },
589 { 27, "Switzer_Fr6" },
590 { 28, "Switzer_Ge6" },
591 { 30, "Taiwan6" },
592 { 32, "UK6" },
593 { 33, "US6" },
594 { -1, NULL }
596 #endif
599 #if OSL_DEBUG_LEVEL > 1
600 #include <stdio.h>
601 #endif
603 const char* SalDisplay::GetKeyboardName( BOOL bRefresh )
605 if( bRefresh || ! m_aKeyboardName.Len() )
607 #ifdef SOLARIS
608 if( IsLocal() )
610 int kbd = open( "/dev/kbd", O_RDONLY );
611 if( kbd >= 0 )
613 int kbd_type = 0;
614 if( ! ioctl( kbd, KIOCTYPE, &kbd_type ) )
616 int kbd_layout = 0;
617 if( ! ioctl( kbd, KIOCLAYOUT, &kbd_layout ) )
619 const keyboard_layout *p_layout = NULL;
620 switch( kbd_type )
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;
629 if( p_layout )
631 while( p_layout->n_layout != -1 )
633 if ( p_layout->n_layout == kbd_layout )
635 m_aKeyboardName = p_layout->p_description;
636 break;
638 p_layout++;
645 #else
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 );
661 else
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 );
669 PRINT_ATOM( types );
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 ); }
674 int 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 );
681 #endif
682 XkbFreeKeyboard( pXkbDesc, XkbAllComponentsMask, True );
685 #endif
686 if( ! m_aKeyboardName.Len() )
687 m_aKeyboardName = "<unknown keyboard>";
689 return m_aKeyboardName.GetBuffer();