xref: /aoo41x/main/vcl/unx/generic/app/keysymnames.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_vcl.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #ifndef SOLARIS
32*cdf0e10cSrcweir #include <tools/prex.h>
33*cdf0e10cSrcweir #include <X11/XKBlib.h>
34*cdf0e10cSrcweir #include <tools/postx.h>
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <unx/saldisp.hxx>
38*cdf0e10cSrcweir #include <X11/keysym.h>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #if !defined (SunXK_Undo)
41*cdf0e10cSrcweir #define SunXK_Undo		0x0000FF65	// XK_Undo
42*cdf0e10cSrcweir #define SunXK_Again		0x0000FF66	// XK_Redo
43*cdf0e10cSrcweir #define SunXK_Find		0x0000FF68	// XK_Find
44*cdf0e10cSrcweir #define SunXK_Stop		0x0000FF69	// XK_Cancel
45*cdf0e10cSrcweir #define SunXK_Props		0x1005FF70
46*cdf0e10cSrcweir #define SunXK_Front		0x1005FF71
47*cdf0e10cSrcweir #define SunXK_Copy		0x1005FF72
48*cdf0e10cSrcweir #define SunXK_Open		0x1005FF73
49*cdf0e10cSrcweir #define SunXK_Paste		0x1005FF74
50*cdf0e10cSrcweir #define SunXK_Cut		0x1005FF75
51*cdf0e10cSrcweir #endif
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir #ifdef SOLARIS
54*cdf0e10cSrcweir #include <sys/types.h>
55*cdf0e10cSrcweir #include <sys/ioctl.h>
56*cdf0e10cSrcweir #include <sys/kbio.h>
57*cdf0e10cSrcweir #include <sys/kbd.h>
58*cdf0e10cSrcweir #include <stdio.h>
59*cdf0e10cSrcweir #include <fcntl.h>
60*cdf0e10cSrcweir #include <deflt.h>
61*cdf0e10cSrcweir #include <unistd.h>
62*cdf0e10cSrcweir #include <stdlib.h>
63*cdf0e10cSrcweir #endif
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir #include <string.h>
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir namespace vcl_sal {
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 	struct KeysymNameReplacement
70*cdf0e10cSrcweir 	{
71*cdf0e10cSrcweir 		KeySym			aSymbol;
72*cdf0e10cSrcweir 		const char*		pName;
73*cdf0e10cSrcweir 	};
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	struct KeyboardReplacements
76*cdf0e10cSrcweir 	{
77*cdf0e10cSrcweir 		const char*						pKeyboardName;
78*cdf0e10cSrcweir 		const KeysymNameReplacement*	pReplacements;
79*cdf0e10cSrcweir 		int								nReplacements;
80*cdf0e10cSrcweir 	};
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     // ====================================================================
83*cdf0e10cSrcweir     //
84*cdf0e10cSrcweir     // CAUTION CAUTION CAUTION
85*cdf0e10cSrcweir     // every string value in the replacements tables must be in UTF8
86*cdf0e10cSrcweir     // be careful with your editor !
87*cdf0e10cSrcweir     //
88*cdf0e10cSrcweir     // ====================================================================
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	static const struct KeysymNameReplacement aImplReplacements_English[] =
91*cdf0e10cSrcweir 	{
92*cdf0e10cSrcweir 		{ XK_Control_L, "Ctrl" },
93*cdf0e10cSrcweir 		{ XK_Control_R, "Ctrl" },
94*cdf0e10cSrcweir 		{ XK_Escape, "Esc" },
95*cdf0e10cSrcweir 		{ XK_space, "Space" },
96*cdf0e10cSrcweir         { XK_minus, "-" },
97*cdf0e10cSrcweir         { XK_plus, "+" }
98*cdf0e10cSrcweir 	};
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	static const struct KeysymNameReplacement aImplReplacements_Turkish[] =
101*cdf0e10cSrcweir 	{
102*cdf0e10cSrcweir 		{ XK_Control_L, "Ctrl" },
103*cdf0e10cSrcweir 		{ XK_Control_R, "Ctrl" },
104*cdf0e10cSrcweir 		{ XK_Right, "Sağ" },
105*cdf0e10cSrcweir 		{ XK_Left, "Sol" },
106*cdf0e10cSrcweir 		{ XK_Up, "Yukarı" },
107*cdf0e10cSrcweir 		{ XK_Down, "Aşağı" },
108*cdf0e10cSrcweir 		{ XK_space, "Boşluk" }
109*cdf0e10cSrcweir 	};
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	static const struct KeysymNameReplacement aImplReplacements_Russian[] =
112*cdf0e10cSrcweir 	{
113*cdf0e10cSrcweir 		{ XK_Right, "Вправо" },
114*cdf0e10cSrcweir 		{ XK_Left, "Влево" },
115*cdf0e10cSrcweir 		{ XK_Up, "Вверх" },
116*cdf0e10cSrcweir 		{ XK_Down, "Вниз" },
117*cdf0e10cSrcweir 		{ XK_space, "Пробел" }
118*cdf0e10cSrcweir 	};
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	static const struct KeysymNameReplacement aImplReplacements_German[] =
121*cdf0e10cSrcweir 	{
122*cdf0e10cSrcweir 		{ XK_Control_L, "Strg" },
123*cdf0e10cSrcweir 		{ XK_Control_R, "Strg" },
124*cdf0e10cSrcweir 		{ XK_Shift_L, "Umschalt" },
125*cdf0e10cSrcweir 		{ XK_Shift_R, "Umschalt" },
126*cdf0e10cSrcweir 		{ XK_Alt_L, "Alt" },
127*cdf0e10cSrcweir 		{ XK_Alt_R, "Alt Gr" },
128*cdf0e10cSrcweir 		{ XK_Page_Up, "Bild auf" },
129*cdf0e10cSrcweir 		{ XK_Page_Down, "Bild ab" },
130*cdf0e10cSrcweir 		{ XK_End, "Ende" },
131*cdf0e10cSrcweir 		{ XK_Home, "Pos 1" },
132*cdf0e10cSrcweir 		{ XK_Insert, "Einfg" },
133*cdf0e10cSrcweir 		{ XK_Delete, "Entf" },
134*cdf0e10cSrcweir 		{ XK_Escape, "Esc" },
135*cdf0e10cSrcweir 		{ XK_Right, "Rechts" },
136*cdf0e10cSrcweir 		{ XK_Left, "Links" },
137*cdf0e10cSrcweir 		{ XK_Up, "Oben" },
138*cdf0e10cSrcweir 		{ XK_Down, "Unten" },
139*cdf0e10cSrcweir 		{ XK_BackSpace, "Rückschritt" },
140*cdf0e10cSrcweir 		{ XK_Return, "Eingabe" },
141*cdf0e10cSrcweir 		{ XK_slash, "Schrägstrich" },
142*cdf0e10cSrcweir 		{ XK_space, "Leertaste" },
143*cdf0e10cSrcweir         { SunXK_Stop,  "Stop" },
144*cdf0e10cSrcweir         { SunXK_Again, "Wiederholen" },
145*cdf0e10cSrcweir         { SunXK_Props, "Eigenschaften" },
146*cdf0e10cSrcweir         { SunXK_Undo,  "Zurücknehmen" },
147*cdf0e10cSrcweir         { SunXK_Front, "Vordergrund" },
148*cdf0e10cSrcweir         { SunXK_Copy,  "Kopieren" },
149*cdf0e10cSrcweir         { SunXK_Open,  "Öffnen" },
150*cdf0e10cSrcweir         { SunXK_Paste, "Einsetzen" },
151*cdf0e10cSrcweir         { SunXK_Find,  "Suchen" },
152*cdf0e10cSrcweir         { SunXK_Cut,   "Ausschneiden" },
153*cdf0e10cSrcweir         { XK_minus, "-" },
154*cdf0e10cSrcweir         { XK_plus, "+" }
155*cdf0e10cSrcweir 	};
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 	static const struct KeysymNameReplacement aImplReplacements_French[] =
158*cdf0e10cSrcweir 	{
159*cdf0e10cSrcweir 		{ XK_Shift_L, "Maj" },
160*cdf0e10cSrcweir 		{ XK_Shift_R, "Maj" },
161*cdf0e10cSrcweir 		{ XK_Page_Up, "Pg. Préc" },
162*cdf0e10cSrcweir 		{ XK_Page_Down, "Pg. Suiv" },
163*cdf0e10cSrcweir 		{ XK_End, "Fin" },
164*cdf0e10cSrcweir 		{ XK_Home, "Origine" },
165*cdf0e10cSrcweir 		{ XK_Insert, "Insérer" },
166*cdf0e10cSrcweir 		{ XK_Delete, "Suppr" },
167*cdf0e10cSrcweir 		{ XK_Escape, "Esc" },
168*cdf0e10cSrcweir 		{ XK_Right, "Droite" },
169*cdf0e10cSrcweir 		{ XK_Left, "Gauche" },
170*cdf0e10cSrcweir 		{ XK_Up, "Haut" },
171*cdf0e10cSrcweir 		{ XK_Down, "Bas" },
172*cdf0e10cSrcweir 		{ XK_BackSpace, "Ret. Arr" },
173*cdf0e10cSrcweir 		{ XK_Return, "Retour" },
174*cdf0e10cSrcweir 		{ XK_KP_Enter, "Entrée" },
175*cdf0e10cSrcweir         { SunXK_Stop,  "Stop" },
176*cdf0e10cSrcweir         { SunXK_Again, "Encore" },
177*cdf0e10cSrcweir         { SunXK_Props, "Props" },
178*cdf0e10cSrcweir         { SunXK_Undo,  "Annuler" },
179*cdf0e10cSrcweir         { SunXK_Front, "Devant" },
180*cdf0e10cSrcweir         { SunXK_Copy,  "Copy" },
181*cdf0e10cSrcweir         { SunXK_Open,  "Ouvrir" },
182*cdf0e10cSrcweir         { SunXK_Paste, "Coller" },
183*cdf0e10cSrcweir         { SunXK_Find,  "Cher." },
184*cdf0e10cSrcweir         { SunXK_Cut,   "Couper" },
185*cdf0e10cSrcweir         { XK_minus, "-" },
186*cdf0e10cSrcweir         { XK_plus, "+" }
187*cdf0e10cSrcweir 	};
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	static const struct KeysymNameReplacement aImplReplacements_Italian[] =
190*cdf0e10cSrcweir 	{
191*cdf0e10cSrcweir 		{ XK_Shift_L, "Maiusc" },
192*cdf0e10cSrcweir 		{ XK_Shift_R, "Maiusc" },
193*cdf0e10cSrcweir 		{ XK_Page_Up, "PgSu" },
194*cdf0e10cSrcweir 		{ XK_Page_Down, "PgGiu" },
195*cdf0e10cSrcweir 		{ XK_End, "Fine" },
196*cdf0e10cSrcweir 		{ XK_Insert, "Ins" },
197*cdf0e10cSrcweir 		{ XK_Delete, "Canc" },
198*cdf0e10cSrcweir 		{ XK_Escape, "Esc" },
199*cdf0e10cSrcweir 		{ XK_Right, "A destra" },
200*cdf0e10cSrcweir 		{ XK_Left, "A sinistra" },
201*cdf0e10cSrcweir 		{ XK_Up, "Sposta verso l'alto" },
202*cdf0e10cSrcweir 		{ XK_Down, "Sposta verso il basso" },
203*cdf0e10cSrcweir 		{ XK_BackSpace, "Backspace" },
204*cdf0e10cSrcweir 		{ XK_Return, "Invio" },
205*cdf0e10cSrcweir 		{ XK_space, "Spazio" },
206*cdf0e10cSrcweir         { SunXK_Stop,  "Stop" },
207*cdf0e10cSrcweir         { SunXK_Again, "Ancora" },
208*cdf0e10cSrcweir         { SunXK_Props, "Proprietà" },
209*cdf0e10cSrcweir         { SunXK_Undo,  "Annulla" },
210*cdf0e10cSrcweir         { SunXK_Front, "Davanti" },
211*cdf0e10cSrcweir         { SunXK_Copy,  "Copia" },
212*cdf0e10cSrcweir         { SunXK_Open,  "Apri" },
213*cdf0e10cSrcweir         { SunXK_Paste, "Incolla" },
214*cdf0e10cSrcweir         { SunXK_Find,  "Trova" },
215*cdf0e10cSrcweir         { SunXK_Cut,   "Taglia" },
216*cdf0e10cSrcweir         { XK_minus, "-" },
217*cdf0e10cSrcweir         { XK_plus, "+" }
218*cdf0e10cSrcweir 	};
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 	static const struct KeysymNameReplacement aImplReplacements_Dutch[] =
221*cdf0e10cSrcweir 	{
222*cdf0e10cSrcweir 		{ XK_Page_Up, "PageUp" },
223*cdf0e10cSrcweir 		{ XK_Page_Down, "PageDown" },
224*cdf0e10cSrcweir 		{ XK_Escape, "Esc" },
225*cdf0e10cSrcweir 		{ XK_Right, "Rechts" },
226*cdf0e10cSrcweir 		{ XK_Left, "Links" },
227*cdf0e10cSrcweir 		{ XK_Up, "Boven" },
228*cdf0e10cSrcweir 		{ XK_Down, "Onder" },
229*cdf0e10cSrcweir 		{ XK_BackSpace, "Backspace" },
230*cdf0e10cSrcweir 		{ XK_Return, "Return" },
231*cdf0e10cSrcweir 		{ XK_space, "Spatiebalk" },
232*cdf0e10cSrcweir         { SunXK_Stop,  "Stop" },
233*cdf0e10cSrcweir         { SunXK_Again, "Again" },
234*cdf0e10cSrcweir         { SunXK_Props, "Props" },
235*cdf0e10cSrcweir         { SunXK_Undo,  "Undo" },
236*cdf0e10cSrcweir         { SunXK_Front, "Front" },
237*cdf0e10cSrcweir         { SunXK_Copy,  "Copy" },
238*cdf0e10cSrcweir         { SunXK_Open,  "Open" },
239*cdf0e10cSrcweir         { SunXK_Paste, "Paste" },
240*cdf0e10cSrcweir         { SunXK_Find,  "Find" },
241*cdf0e10cSrcweir         { SunXK_Cut,   "Cut" },
242*cdf0e10cSrcweir         { XK_minus, "-" },
243*cdf0e10cSrcweir         { XK_plus, "+" }
244*cdf0e10cSrcweir 	};
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 	static const struct KeysymNameReplacement aImplReplacements_Norwegian[] =
247*cdf0e10cSrcweir 	{
248*cdf0e10cSrcweir 		{ XK_Shift_L, "Skift" },
249*cdf0e10cSrcweir 		{ XK_Shift_R, "Skift" },
250*cdf0e10cSrcweir 		{ XK_Page_Up, "PageUp" },
251*cdf0e10cSrcweir 		{ XK_Page_Down, "PageDown" },
252*cdf0e10cSrcweir 		{ XK_Escape, "Esc" },
253*cdf0e10cSrcweir 		{ XK_Right, "Hyre" },
254*cdf0e10cSrcweir 		{ XK_Left, "Venstre" },
255*cdf0e10cSrcweir 		{ XK_Up, "Opp" },
256*cdf0e10cSrcweir 		{ XK_Down, "Ned" },
257*cdf0e10cSrcweir 		{ XK_BackSpace, "Tilbake" },
258*cdf0e10cSrcweir 		{ XK_Return, "Enter" },
259*cdf0e10cSrcweir         { SunXK_Stop,  "Avbryt" },
260*cdf0e10cSrcweir         { SunXK_Again, "Gjenta" },
261*cdf0e10cSrcweir         { SunXK_Props, "Egenskaper" },
262*cdf0e10cSrcweir         { SunXK_Undo,  "Angre" },
263*cdf0e10cSrcweir         { SunXK_Front, "Front" },
264*cdf0e10cSrcweir         { SunXK_Copy,  "Kopi" },
265*cdf0e10cSrcweir         { SunXK_Open,  "Åpne" },
266*cdf0e10cSrcweir         { SunXK_Paste, "Lim" },
267*cdf0e10cSrcweir         { SunXK_Find,  "Søk" },
268*cdf0e10cSrcweir         { SunXK_Cut,   "Klipp" },
269*cdf0e10cSrcweir         { XK_minus, "-" },
270*cdf0e10cSrcweir         { XK_plus, "+" }
271*cdf0e10cSrcweir 	};
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir 	static const struct KeysymNameReplacement aImplReplacements_Swedish[] =
274*cdf0e10cSrcweir 	{
275*cdf0e10cSrcweir 		{ XK_Shift_L, "Skift" },
276*cdf0e10cSrcweir 		{ XK_Shift_R, "Skift" },
277*cdf0e10cSrcweir 		{ XK_Page_Up, "PageUp" },
278*cdf0e10cSrcweir 		{ XK_Page_Down, "PageDown" },
279*cdf0e10cSrcweir 		{ XK_Escape, "Esc" },
280*cdf0e10cSrcweir 		{ XK_Right, "Höger" },
281*cdf0e10cSrcweir 		{ XK_Left, "Vänster" },
282*cdf0e10cSrcweir 		{ XK_Up, "Up" },
283*cdf0e10cSrcweir 		{ XK_Down, "Ned" },
284*cdf0e10cSrcweir 		{ XK_BackSpace, "Backsteg" },
285*cdf0e10cSrcweir 		{ XK_Return, "Retur" },
286*cdf0e10cSrcweir 		{ XK_space, "Blank" },
287*cdf0e10cSrcweir         { SunXK_Stop,  "Avbryt" },
288*cdf0e10cSrcweir         { SunXK_Again, "Upprepa" },
289*cdf0e10cSrcweir         { SunXK_Props, "Egenskaper" },
290*cdf0e10cSrcweir         { SunXK_Undo,  "Ångra" },
291*cdf0e10cSrcweir         { SunXK_Front, "Fram" },
292*cdf0e10cSrcweir         { SunXK_Copy,  "Kopiera" },
293*cdf0e10cSrcweir         { SunXK_Open,  "Öppna" },
294*cdf0e10cSrcweir         { SunXK_Paste, "Klistra in" },
295*cdf0e10cSrcweir         { SunXK_Find,  "Sök" },
296*cdf0e10cSrcweir         { SunXK_Cut,   "Klipp ut" },
297*cdf0e10cSrcweir         { XK_minus, "-" },
298*cdf0e10cSrcweir         { XK_plus, "+" }
299*cdf0e10cSrcweir 	};
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir 	static const struct KeysymNameReplacement aImplReplacements_Portuguese[] =
302*cdf0e10cSrcweir 	{
303*cdf0e10cSrcweir 		{ XK_Page_Up, "PageUp" },
304*cdf0e10cSrcweir 		{ XK_Page_Down, "PageDown" },
305*cdf0e10cSrcweir 		{ XK_Escape, "Esc" },
306*cdf0e10cSrcweir 		{ XK_Right, "Direita" },
307*cdf0e10cSrcweir 		{ XK_Left, "Esquerda" },
308*cdf0e10cSrcweir 		{ XK_Up, "Acima" },
309*cdf0e10cSrcweir 		{ XK_Down, "Abaixo" },
310*cdf0e10cSrcweir 		{ XK_BackSpace, "Backspace" },
311*cdf0e10cSrcweir 		{ XK_Return, "Enter" },
312*cdf0e10cSrcweir 		{ XK_slash, "Barra" },
313*cdf0e10cSrcweir         { SunXK_Stop,  "Stop" },
314*cdf0e10cSrcweir         { SunXK_Again, "Again" },
315*cdf0e10cSrcweir         { SunXK_Props, "Props" },
316*cdf0e10cSrcweir         { SunXK_Undo,  "Undo" },
317*cdf0e10cSrcweir         { SunXK_Front, "Front" },
318*cdf0e10cSrcweir         { SunXK_Copy,  "Copy" },
319*cdf0e10cSrcweir         { SunXK_Open,  "Open" },
320*cdf0e10cSrcweir         { SunXK_Paste, "Paste" },
321*cdf0e10cSrcweir         { SunXK_Find,  "Find" },
322*cdf0e10cSrcweir         { SunXK_Cut,   "Cut" },
323*cdf0e10cSrcweir         { XK_minus, "-" },
324*cdf0e10cSrcweir         { XK_plus, "+" }
325*cdf0e10cSrcweir 	};
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir 	static const struct KeysymNameReplacement aImplReplacements_Spanish[] =
328*cdf0e10cSrcweir 	{
329*cdf0e10cSrcweir 		{ XK_Shift_L, "Mayús" },
330*cdf0e10cSrcweir 		{ XK_Shift_R, "Mayús" },
331*cdf0e10cSrcweir 		{ XK_Page_Up, "RePág" },
332*cdf0e10cSrcweir 		{ XK_Page_Down, "AvPág" },
333*cdf0e10cSrcweir 		{ XK_End, "Fin" },
334*cdf0e10cSrcweir 		{ XK_Home, "Inicio" },
335*cdf0e10cSrcweir 		{ XK_Delete, "Supr" },
336*cdf0e10cSrcweir 		{ XK_Escape, "Esc" },
337*cdf0e10cSrcweir 		{ XK_Right, "Hacia la derecha" },
338*cdf0e10cSrcweir 		{ XK_Left, "Hacia la izquierda" },
339*cdf0e10cSrcweir 		{ XK_Up, "Hacia arriba" },
340*cdf0e10cSrcweir 		{ XK_Down, "Hacia abajo" },
341*cdf0e10cSrcweir 		{ XK_BackSpace, "Ret" },
342*cdf0e10cSrcweir 		{ XK_Return, "Entrada" },
343*cdf0e10cSrcweir 		{ XK_space, "Espacio" },
344*cdf0e10cSrcweir 		{ XK_KP_Enter, "Intro" },
345*cdf0e10cSrcweir         { SunXK_Stop,  "Stop" },
346*cdf0e10cSrcweir         { SunXK_Again, "Repetir" },
347*cdf0e10cSrcweir         { SunXK_Props, "Props" },
348*cdf0e10cSrcweir         { SunXK_Undo,  "Anular" },
349*cdf0e10cSrcweir         { SunXK_Front, "Delante" },
350*cdf0e10cSrcweir         { SunXK_Copy,  "Copiar" },
351*cdf0e10cSrcweir         { SunXK_Open,  "Abrir" },
352*cdf0e10cSrcweir         { SunXK_Paste, "Pegar" },
353*cdf0e10cSrcweir         { SunXK_Find,  "Buscar" },
354*cdf0e10cSrcweir         { SunXK_Cut,   "Cortar" },
355*cdf0e10cSrcweir         { XK_minus, "-" },
356*cdf0e10cSrcweir         { XK_plus, "+" }
357*cdf0e10cSrcweir 	};
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir 	static const struct KeyboardReplacements aKeyboards[] =
360*cdf0e10cSrcweir 	{
361*cdf0e10cSrcweir #ifdef SOLARIS
362*cdf0e10cSrcweir 		{ "Germany5", aImplReplacements_German, sizeof(aImplReplacements_German)/sizeof(aImplReplacements_German[0]) },
363*cdf0e10cSrcweir 		{ "Germany4", aImplReplacements_German, sizeof(aImplReplacements_German)/sizeof(aImplReplacements_German[0]) },
364*cdf0e10cSrcweir 		{ "France5", aImplReplacements_French, sizeof(aImplReplacements_French)/sizeof(aImplReplacements_French[0]) },
365*cdf0e10cSrcweir 		{ "France6", aImplReplacements_French, sizeof(aImplReplacements_French)/sizeof(aImplReplacements_French[0]) },
366*cdf0e10cSrcweir 		{ "France_x86", aImplReplacements_French, sizeof(aImplReplacements_French)/sizeof(aImplReplacements_French[0]) },
367*cdf0e10cSrcweir 		{ "Italy5", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
368*cdf0e10cSrcweir 		{ "Italy5-Hobo", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
369*cdf0e10cSrcweir 		{ "Italy4", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
370*cdf0e10cSrcweir 		{ "Italy6", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
371*cdf0e10cSrcweir 		{ "Italy_x86", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
372*cdf0e10cSrcweir 		{ "Netherland4", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
373*cdf0e10cSrcweir 		{ "Netherland5", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
374*cdf0e10cSrcweir 		{ "Netherland5-Hobo", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
375*cdf0e10cSrcweir 		{ "Netherland6", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
376*cdf0e10cSrcweir 		{ "Netherland_x86", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
377*cdf0e10cSrcweir 		{ "Norway5", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
378*cdf0e10cSrcweir 		{ "Norway5-Hobo", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
379*cdf0e10cSrcweir 		{ "Norway4", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
380*cdf0e10cSrcweir 		{ "Norway6", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
381*cdf0e10cSrcweir 		{ "Norway_x86", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
382*cdf0e10cSrcweir 		{ "Portugal5", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
383*cdf0e10cSrcweir 		{ "Portugal5-Hobo", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
384*cdf0e10cSrcweir 		{ "Portugal4", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
385*cdf0e10cSrcweir 		{ "Portugal6", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
386*cdf0e10cSrcweir 		{ "Portugal_x86", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
387*cdf0e10cSrcweir 		{ "Spain5", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
388*cdf0e10cSrcweir 		{ "Spain5-Hobo", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
389*cdf0e10cSrcweir 		{ "Spain4", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
390*cdf0e10cSrcweir 		{ "Spain6", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
391*cdf0e10cSrcweir 		{ "Spain_x86", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
392*cdf0e10cSrcweir 		{ "Sweden5", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
393*cdf0e10cSrcweir 		{ "Sweden5-Hobo", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
394*cdf0e10cSrcweir 		{ "Sweden4", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
395*cdf0e10cSrcweir 		{ "Sweden6", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
396*cdf0e10cSrcweir 		{ "Sweden_x86", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
397*cdf0e10cSrcweir #endif
398*cdf0e10cSrcweir 		{ "U.S. English", aImplReplacements_English, sizeof(aImplReplacements_English)/sizeof(aImplReplacements_English[0]) },
399*cdf0e10cSrcweir 		{ "United Kingdom", aImplReplacements_English, sizeof(aImplReplacements_English)/sizeof(aImplReplacements_English[0]) },
400*cdf0e10cSrcweir         // Germany, German
401*cdf0e10cSrcweir 		{ "German", aImplReplacements_German, sizeof(aImplReplacements_German)/sizeof(aImplReplacements_German[0]) },
402*cdf0e10cSrcweir 		{ "France", aImplReplacements_French, sizeof(aImplReplacements_French)/sizeof(aImplReplacements_French[0]) },
403*cdf0e10cSrcweir 		{ "French", aImplReplacements_French, sizeof(aImplReplacements_French)/sizeof(aImplReplacements_French[0]) },
404*cdf0e10cSrcweir         // Italy, Italian
405*cdf0e10cSrcweir 		{ "Ital", aImplReplacements_Italian, sizeof(aImplReplacements_Italian)/sizeof(aImplReplacements_Italian[0]) },
406*cdf0e10cSrcweir         // Norway, Norwegian
407*cdf0e10cSrcweir 		{ "Norw", aImplReplacements_Norwegian, sizeof(aImplReplacements_Norwegian)/sizeof(aImplReplacements_Norwegian[0]) },
408*cdf0e10cSrcweir         // Portugal, Portuguese
409*cdf0e10cSrcweir 		{ "Portu", aImplReplacements_Portuguese, sizeof(aImplReplacements_Portuguese)/sizeof(aImplReplacements_Portuguese[0]) },
410*cdf0e10cSrcweir 		{ "Spain", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
411*cdf0e10cSrcweir 		{ "Spanish", aImplReplacements_Spanish, sizeof(aImplReplacements_Spanish)/sizeof(aImplReplacements_Spanish[0]) },
412*cdf0e10cSrcweir         // Sweden, Swedish
413*cdf0e10cSrcweir 		{ "Swed", aImplReplacements_Swedish, sizeof(aImplReplacements_Swedish)/sizeof(aImplReplacements_Swedish[0]) },
414*cdf0e10cSrcweir 		{ "Netherland", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
415*cdf0e10cSrcweir 		{ "Dutch", aImplReplacements_Dutch, sizeof(aImplReplacements_Dutch)/sizeof(aImplReplacements_Dutch[0]) },
416*cdf0e10cSrcweir 		// Turkish, Turkey
417*cdf0e10cSrcweir 		{ "Turk", aImplReplacements_Turkish, sizeof(aImplReplacements_Turkish)/sizeof(aImplReplacements_Turkish[0]) },
418*cdf0e10cSrcweir 		// Russian, Russia
419*cdf0e10cSrcweir 		{ "Russia", aImplReplacements_Russian, sizeof(aImplReplacements_Russian)/sizeof(aImplReplacements_Russian[0]) },
420*cdf0e10cSrcweir 		{ "English", aImplReplacements_English, sizeof(aImplReplacements_English)/sizeof(aImplReplacements_English[0]) }
421*cdf0e10cSrcweir 	};
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir 	String getKeysymReplacementName( const char* pKeyboard, KeySym nSymbol )
424*cdf0e10cSrcweir 	{
425*cdf0e10cSrcweir 		for( unsigned int n = 0; n < sizeof(aKeyboards)/sizeof(aKeyboards[0]); n++ )
426*cdf0e10cSrcweir 		{
427*cdf0e10cSrcweir 			if( ! strncasecmp( pKeyboard, aKeyboards[n].pKeyboardName, strlen( aKeyboards[n].pKeyboardName ) ) )
428*cdf0e10cSrcweir 			{
429*cdf0e10cSrcweir 				const struct KeysymNameReplacement* pRepl = aKeyboards[n].pReplacements;
430*cdf0e10cSrcweir 				for( int m = aKeyboards[n].nReplacements ; m ; )
431*cdf0e10cSrcweir 				{
432*cdf0e10cSrcweir 					if( nSymbol == pRepl[--m].aSymbol )
433*cdf0e10cSrcweir 						return String( pRepl[m].pName, RTL_TEXTENCODING_UTF8 );
434*cdf0e10cSrcweir 				}
435*cdf0e10cSrcweir 			}
436*cdf0e10cSrcweir 		}
437*cdf0e10cSrcweir         // try english fallbacks
438*cdf0e10cSrcweir         const struct KeysymNameReplacement* pRepl = aImplReplacements_English;
439*cdf0e10cSrcweir         for( int m = sizeof(aImplReplacements_English)/sizeof(aImplReplacements_English[0]) ; m ; )
440*cdf0e10cSrcweir         {
441*cdf0e10cSrcweir             if( nSymbol == pRepl[--m].aSymbol )
442*cdf0e10cSrcweir                 return String( pRepl[m].pName, RTL_TEXTENCODING_UTF8 );
443*cdf0e10cSrcweir         }
444*cdf0e10cSrcweir 		return String();
445*cdf0e10cSrcweir 	}
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir }
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir #ifdef SOLARIS
450*cdf0e10cSrcweir typedef struct {
451*cdf0e10cSrcweir 	int 		n_layout;
452*cdf0e10cSrcweir 	const char* p_description;
453*cdf0e10cSrcweir } keyboard_layout;
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir static const keyboard_layout type0_layout[] =
456*cdf0e10cSrcweir {
457*cdf0e10cSrcweir 	{ 0, "US4" },
458*cdf0e10cSrcweir 	{ -1, NULL }
459*cdf0e10cSrcweir };
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir static const keyboard_layout type3_layout[] =
462*cdf0e10cSrcweir {
463*cdf0e10cSrcweir 	{ 0, "US3" },
464*cdf0e10cSrcweir 	{ -1, NULL }
465*cdf0e10cSrcweir };
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir static const keyboard_layout type4_layout[] =
468*cdf0e10cSrcweir {
469*cdf0e10cSrcweir 	{ 0,  "US4" },
470*cdf0e10cSrcweir 	{ 1,  "US4" },
471*cdf0e10cSrcweir 	{ 2,  "FranceBelg4" },
472*cdf0e10cSrcweir 	{ 3,  "Canada4" },
473*cdf0e10cSrcweir 	{ 4,  "Denmark4" },
474*cdf0e10cSrcweir 	{ 5,  "Germany4" },
475*cdf0e10cSrcweir 	{ 6,  "Italy4" },
476*cdf0e10cSrcweir 	{ 7,  "Netherland4" },
477*cdf0e10cSrcweir 	{ 8,  "Norway4" },
478*cdf0e10cSrcweir 	{ 9,  "Portugal4" },
479*cdf0e10cSrcweir 	{ 10, "SpainLatAm4" },
480*cdf0e10cSrcweir 	{ 11, "SwedenFin4" },
481*cdf0e10cSrcweir 	{ 12, "Switzer_Fr4" },
482*cdf0e10cSrcweir 	{ 13, "Switzer_Ge4" },
483*cdf0e10cSrcweir 	{ 14, "UK4" },
484*cdf0e10cSrcweir 	{ 16, "Korea4" },
485*cdf0e10cSrcweir 	{ 17, "Taiwan4" },
486*cdf0e10cSrcweir 	{ 19, "US101A_PC" },
487*cdf0e10cSrcweir 	{ 19, "US101A_Sun" },
488*cdf0e10cSrcweir 	{ 32, "Japan4" },
489*cdf0e10cSrcweir 	{ 33, "US5" },
490*cdf0e10cSrcweir 	{ 34, "US_UNIX5" },
491*cdf0e10cSrcweir 	{ 35, "France5" },
492*cdf0e10cSrcweir 	{ 36, "Denmark5" },
493*cdf0e10cSrcweir 	{ 37, "Germany5" },
494*cdf0e10cSrcweir 	{ 38, "Italy5" },
495*cdf0e10cSrcweir 	{ 39, "Netherland5" },
496*cdf0e10cSrcweir 	{ 40, "Norway5" },
497*cdf0e10cSrcweir 	{ 41, "Portugal5" },
498*cdf0e10cSrcweir 	{ 42, "Spain5" },
499*cdf0e10cSrcweir 	{ 43, "Sweden5" },
500*cdf0e10cSrcweir 	{ 44, "Switzer_Fr5" },
501*cdf0e10cSrcweir 	{ 45, "Switzer_Ge5" },
502*cdf0e10cSrcweir 	{ 46, "UK5" },
503*cdf0e10cSrcweir 	{ 47, "Korea5" },
504*cdf0e10cSrcweir 	{ 48, "Taiwan5" },
505*cdf0e10cSrcweir 	{ 49, "Japan5" },
506*cdf0e10cSrcweir 	{ 50, "Canada_Fr5" },
507*cdf0e10cSrcweir 	{ 51, "Hungary5" },
508*cdf0e10cSrcweir 	{ 52, "Poland5" },
509*cdf0e10cSrcweir 	{ 53, "Czech5" },
510*cdf0e10cSrcweir 	{ 54, "Russia5" },
511*cdf0e10cSrcweir 	{ 55, "Latvia5" },
512*cdf0e10cSrcweir 	{ 56, "Turkey5" },
513*cdf0e10cSrcweir 	{ 57, "Greece5" },
514*cdf0e10cSrcweir 	{ 58, "Estonia5" },
515*cdf0e10cSrcweir 	{ 59, "Lithuania5" },
516*cdf0e10cSrcweir 	{ 63, "Canada_Fr5_TBITS5" },
517*cdf0e10cSrcweir 	{ 80, "US5_Hobo" },
518*cdf0e10cSrcweir 	{ 81, "US_UNIX5_Hobo" },
519*cdf0e10cSrcweir 	{ 82, "France5_Hobo" },
520*cdf0e10cSrcweir 	{ 83, "Denmark5_Hobo" },
521*cdf0e10cSrcweir 	{ 84, "Germany5_Hobo" },
522*cdf0e10cSrcweir 	{ 85, "Italy5_Hobo" },
523*cdf0e10cSrcweir 	{ 86, "Netherland5_Hobo" },
524*cdf0e10cSrcweir 	{ 87, "Norway5_Hobo" },
525*cdf0e10cSrcweir 	{ 88, "Portugal5_Hobo" },
526*cdf0e10cSrcweir 	{ 89, "Spain5_Hobo" },
527*cdf0e10cSrcweir 	{ 90, "Sweden5_Hobo" },
528*cdf0e10cSrcweir 	{ 91, "Switzer_Fr5_Hobo" },
529*cdf0e10cSrcweir 	{ 92, "Switzer_Ge5_Hobo" },
530*cdf0e10cSrcweir 	{ 93, "UK5_Hobo" },
531*cdf0e10cSrcweir 	{ 94, "Korea5_Hobo" },
532*cdf0e10cSrcweir 	{ 95, "Taiwan5_Hobo" },
533*cdf0e10cSrcweir 	{ 96, "Japan5_Hobo" },
534*cdf0e10cSrcweir 	{ 97, "Canada_Fr5_Hobo" },
535*cdf0e10cSrcweir 	{ -1, NULL }
536*cdf0e10cSrcweir };
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir static const keyboard_layout type101_layout[] =
539*cdf0e10cSrcweir {
540*cdf0e10cSrcweir 	{  0, "US101A_x86" },
541*cdf0e10cSrcweir 	{  1, "US101A_x86" },
542*cdf0e10cSrcweir 	{ 34, "J3100_x86" },
543*cdf0e10cSrcweir 	{ 35, "France_x86" },
544*cdf0e10cSrcweir 	{ 36, "Denmark_x86" },
545*cdf0e10cSrcweir 	{ 37, "Germany_x86" },
546*cdf0e10cSrcweir 	{ 38, "Italy_x86" },
547*cdf0e10cSrcweir 	{ 39, "Netherland_x86" },
548*cdf0e10cSrcweir 	{ 40, "Norway_x86" },
549*cdf0e10cSrcweir 	{ 41, "Portugal_x86" },
550*cdf0e10cSrcweir 	{ 42, "Spain_x86" },
551*cdf0e10cSrcweir 	{ 43, "Sweden_x86" },
552*cdf0e10cSrcweir 	{ 44, "Switzer_Fr_x86" },
553*cdf0e10cSrcweir 	{ 45, "Switzer_Ge_x86" },
554*cdf0e10cSrcweir 	{ 46, "UK_x86" },
555*cdf0e10cSrcweir 	{ 47, "Korea_x86" },
556*cdf0e10cSrcweir 	{ 48, "Taiwan_x86" },
557*cdf0e10cSrcweir 	{ 49, "Japan_x86" },
558*cdf0e10cSrcweir 	{ 50, "Canada_Fr2_x86" },
559*cdf0e10cSrcweir 	{ 51, "Hungary_x86" },
560*cdf0e10cSrcweir 	{ 52, "Poland_x86" },
561*cdf0e10cSrcweir 	{ 53, "Czech_x86" },
562*cdf0e10cSrcweir 	{ 54, "Russia_x86" },
563*cdf0e10cSrcweir 	{ 55, "Latvia_x86" },
564*cdf0e10cSrcweir 	{ 56, "Turkey_x86" },
565*cdf0e10cSrcweir 	{ 57, "Greece_x86" },
566*cdf0e10cSrcweir 	{ 59, "Lithuania_x86" },
567*cdf0e10cSrcweir 	{ 1001, "MS_US101A_x86" },
568*cdf0e10cSrcweir 	{ -1, NULL }
569*cdf0e10cSrcweir };
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir static const keyboard_layout type6_layout[] =
572*cdf0e10cSrcweir {
573*cdf0e10cSrcweir 	{ 0,  "US6" },
574*cdf0e10cSrcweir 	{ 6,  "Denmark6" },
575*cdf0e10cSrcweir 	{ 7,  "Finnish6" },
576*cdf0e10cSrcweir 	{ 8,  "France6" },
577*cdf0e10cSrcweir 	{ 9,  "Germany6" },
578*cdf0e10cSrcweir 	{ 14, "Italy6" },
579*cdf0e10cSrcweir 	{ 15, "Japan6" },
580*cdf0e10cSrcweir 	{ 16, "Korea6" },
581*cdf0e10cSrcweir 	{ 18, "Netherland6" },
582*cdf0e10cSrcweir 	{ 19, "Norway6" },
583*cdf0e10cSrcweir 	{ 22, "Portugal6" },
584*cdf0e10cSrcweir 	{ 25, "Spain6" },
585*cdf0e10cSrcweir 	{ 26, "Sweden6" },
586*cdf0e10cSrcweir 	{ 27, "Switzer_Fr6" },
587*cdf0e10cSrcweir 	{ 28, "Switzer_Ge6" },
588*cdf0e10cSrcweir 	{ 30, "Taiwan6" },
589*cdf0e10cSrcweir 	{ 32, "UK6" },
590*cdf0e10cSrcweir 	{ 33, "US6" },
591*cdf0e10cSrcweir 	{ -1, NULL }
592*cdf0e10cSrcweir };
593*cdf0e10cSrcweir #endif
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
597*cdf0e10cSrcweir #include <stdio.h>
598*cdf0e10cSrcweir #endif
599*cdf0e10cSrcweir 
600*cdf0e10cSrcweir const char* SalDisplay::GetKeyboardName( sal_Bool bRefresh )
601*cdf0e10cSrcweir {
602*cdf0e10cSrcweir 	if( bRefresh || ! m_aKeyboardName.Len() )
603*cdf0e10cSrcweir 	{
604*cdf0e10cSrcweir #ifdef SOLARIS
605*cdf0e10cSrcweir 		if( IsLocal() )
606*cdf0e10cSrcweir 		{
607*cdf0e10cSrcweir 			int kbd = open( "/dev/kbd", O_RDONLY );
608*cdf0e10cSrcweir 			if( kbd >= 0 )
609*cdf0e10cSrcweir 			{
610*cdf0e10cSrcweir 				int kbd_type = 0;
611*cdf0e10cSrcweir 				if( ! ioctl( kbd, KIOCTYPE, &kbd_type ) )
612*cdf0e10cSrcweir 				{
613*cdf0e10cSrcweir 					int kbd_layout = 0;
614*cdf0e10cSrcweir 					if( ! ioctl( kbd, KIOCLAYOUT, &kbd_layout ) )
615*cdf0e10cSrcweir 					{
616*cdf0e10cSrcweir 						const keyboard_layout *p_layout = NULL;
617*cdf0e10cSrcweir 						switch( kbd_type )
618*cdf0e10cSrcweir 						{
619*cdf0e10cSrcweir 							case KB_KLUNK: p_layout = type0_layout;   break;
620*cdf0e10cSrcweir 							case KB_SUN3:  p_layout = type3_layout;   break;
621*cdf0e10cSrcweir 							case KB_SUN4:  p_layout = type4_layout;   break;
622*cdf0e10cSrcweir 							case KB_USB:   p_layout = type6_layout;   break;
623*cdf0e10cSrcweir 							case KB_PC:    p_layout = type101_layout; break;
624*cdf0e10cSrcweir 						}
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir 						if( p_layout )
627*cdf0e10cSrcweir 						{
628*cdf0e10cSrcweir 							while( p_layout->n_layout != -1 )
629*cdf0e10cSrcweir 							{
630*cdf0e10cSrcweir 								if ( p_layout->n_layout == kbd_layout )
631*cdf0e10cSrcweir 								{
632*cdf0e10cSrcweir 									m_aKeyboardName = p_layout->p_description;
633*cdf0e10cSrcweir 									break;
634*cdf0e10cSrcweir 								}
635*cdf0e10cSrcweir 								p_layout++;
636*cdf0e10cSrcweir 							}
637*cdf0e10cSrcweir 						}
638*cdf0e10cSrcweir 					}
639*cdf0e10cSrcweir 				}
640*cdf0e10cSrcweir 				close(kbd);
641*cdf0e10cSrcweir 			}
642*cdf0e10cSrcweir 		}
643*cdf0e10cSrcweir #else
644*cdf0e10cSrcweir 		int opcode, event, error;
645*cdf0e10cSrcweir 		int major = XkbMajorVersion, minor = XkbMinorVersion;
646*cdf0e10cSrcweir 		if( XkbQueryExtension( GetDisplay(), &opcode, &event,&error, &major, &minor ) )
647*cdf0e10cSrcweir 		{
648*cdf0e10cSrcweir 			XkbDescPtr pXkbDesc = NULL;
649*cdf0e10cSrcweir 			// try X keyboard extension
650*cdf0e10cSrcweir 			if( (pXkbDesc = XkbGetKeyboard( GetDisplay(), XkbAllComponentsMask, XkbUseCoreKbd )) )
651*cdf0e10cSrcweir 			{
652*cdf0e10cSrcweir                 const char* pAtom = NULL;
653*cdf0e10cSrcweir                 if( pXkbDesc->names->groups[0] )
654*cdf0e10cSrcweir                 {
655*cdf0e10cSrcweir                     pAtom = XGetAtomName( GetDisplay(), pXkbDesc->names->groups[0] );
656*cdf0e10cSrcweir                     m_aKeyboardName = pAtom;
657*cdf0e10cSrcweir                     XFree( (void*)pAtom );
658*cdf0e10cSrcweir                 }
659*cdf0e10cSrcweir                 else
660*cdf0e10cSrcweir                     m_aKeyboardName = "<unknown keyboard>";
661*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
662*cdf0e10cSrcweir #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 ); }
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir 				PRINT_ATOM( keycodes );
665*cdf0e10cSrcweir 				PRINT_ATOM( geometry );
666*cdf0e10cSrcweir 				PRINT_ATOM( symbols );
667*cdf0e10cSrcweir 				PRINT_ATOM( types );
668*cdf0e10cSrcweir 				PRINT_ATOM( compat );
669*cdf0e10cSrcweir 				PRINT_ATOM( phys_symbols );
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir #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 ); }
672*cdf0e10cSrcweir 				int i;
673*cdf0e10cSrcweir 				for( i = 0; i < XkbNumVirtualMods; i++ )
674*cdf0e10cSrcweir 					PRINT_ATOM_2( vmods );
675*cdf0e10cSrcweir 				for( i = 0; i < XkbNumIndicators; i++ )
676*cdf0e10cSrcweir 					PRINT_ATOM_2( indicators );
677*cdf0e10cSrcweir 				for( i = 0; i < XkbNumKbdGroups; i++ )
678*cdf0e10cSrcweir 					PRINT_ATOM_2( groups );
679*cdf0e10cSrcweir #endif
680*cdf0e10cSrcweir 				XkbFreeKeyboard( pXkbDesc, XkbAllComponentsMask, True );
681*cdf0e10cSrcweir 			}
682*cdf0e10cSrcweir 		}
683*cdf0e10cSrcweir #endif
684*cdf0e10cSrcweir 		if( ! m_aKeyboardName.Len() )
685*cdf0e10cSrcweir             m_aKeyboardName = "<unknown keyboard>";
686*cdf0e10cSrcweir 	}
687*cdf0e10cSrcweir 	return m_aKeyboardName.GetBuffer();
688*cdf0e10cSrcweir }
689