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