20 #include <freerdp/config.h>
27 #include <winpr/crt.h>
29 #include "liblocale.h"
31 #include <freerdp/locale/keyboard.h>
33 #include "keyboard_x11.h"
35 #include "keyboard_sun.h"
61 UINT32 keyboardLayoutId;
64 static const SOLARIS_KEYBOARD SOLARIS_KEYBOARD_TABLE[] = {
65 { 4, 0,
"sun(type4)", KBD_US },
66 { 4, 1,
"sun(type4)", KBD_US },
67 { 4, 2,
"sun(type4tuv)", KBD_FRENCH },
68 { 4, 3,
"sun(type4_ca)", KBD_US },
69 { 4, 4,
"sun(type4tuv)", KBD_DANISH },
70 { 4, 5,
"sun(type4tuv)", KBD_GERMAN },
71 { 4, 6,
"sun(type4tuv)", KBD_ITALIAN },
72 { 4, 7,
"sun(type4tuv)", KBD_DUTCH },
73 { 4, 8,
"sun(type4tuv)", KBD_NORWEGIAN },
74 { 4, 9,
"sun(type4tuv)", KBD_PORTUGUESE },
75 { 4, 10,
"sun(type4tuv)", KBD_SPANISH },
76 { 4, 11,
"sun(type4tuv)", KBD_SWEDISH },
77 { 4, 12,
"sun(type4tuv)", KBD_SWISS_FRENCH },
78 { 4, 13,
"sun(type4tuv)", KBD_SWISS_GERMAN },
79 { 4, 14,
"sun(type4tuv)", KBD_UNITED_KINGDOM },
80 { 4, 16,
"sun(type4)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 },
81 { 4, 17,
"sun(type4)", KBD_CHINESE_TRADITIONAL_PHONETIC },
82 { 4, 32,
"sun(type4jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 },
83 { 4, 19,
"sun(type5)", KBD_US },
84 { 4, 33,
"sun(type5)", KBD_US },
85 { 4, 34,
"sun(type5unix)", KBD_US },
86 { 4, 35,
"sun(type5tuv)", KBD_FRENCH },
87 { 4, 36,
"sun(type5tuv)", KBD_DANISH },
88 { 4, 37,
"sun(type5tuv)", KBD_GERMAN },
89 { 4, 38,
"sun(type5tuv)", KBD_ITALIAN },
90 { 4, 39,
"sun(type5tuv)", KBD_DUTCH },
91 { 4, 40,
"sun(type5tuv)", KBD_NORWEGIAN },
92 { 4, 41,
"sun(type5tuv)", KBD_PORTUGUESE },
93 { 4, 42,
"sun(type5tuv)", KBD_SPANISH },
94 { 4, 43,
"sun(type5tuv)", KBD_SWEDISH },
95 { 4, 44,
"sun(type5tuv)", KBD_SWISS_FRENCH },
96 { 4, 45,
"sun(type5tuv)", KBD_SWISS_GERMAN },
97 { 4, 46,
"sun(type5tuv)", KBD_UNITED_KINGDOM },
98 { 4, 47,
"sun(type5)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 },
99 { 4, 48,
"sun(type5)", KBD_CHINESE_TRADITIONAL_PHONETIC },
100 { 4, 49,
"sun(type5jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 },
101 { 4, 50,
"sun(type5tuv)", KBD_CANADIAN_FRENCH },
102 { 4, 51,
"sun(type5tuv)", KBD_HUNGARIAN },
103 { 4, 52,
"sun(type5tuv)", KBD_POLISH_214 },
104 { 4, 53,
"sun(type5tuv)", KBD_CZECH },
105 { 4, 54,
"sun(type5tuv)", KBD_RUSSIAN },
106 { 4, 55,
"sun(type5tuv)", KBD_LATVIAN },
107 { 4, 57,
"sun(type5tuv)", KBD_GREEK },
108 { 4, 59,
"sun(type5tuv)", KBD_LITHUANIAN },
109 { 4, 63,
"sun(type5tuv)", KBD_CANADIAN_FRENCH },
110 { 4, 56,
"sun(type5tuv)", KBD_TURKISH_Q },
111 { 4, 58,
"sun(type5tuv)", KBD_ARABIC_101 },
112 { 4, 60,
"sun(type5tuv)", KBD_BELGIAN_FRENCH },
113 { 4, 62,
"sun(type5tuv)", KBD_TURKISH_F },
114 { 4, 80,
"sun(type5hobo)", KBD_US },
115 { 4, 81,
"sun(type5hobo)", KBD_US },
116 { 4, 82,
"sun(type5tuvhobo)", KBD_FRENCH },
117 { 4, 83,
"sun(type5tuvhobo)", KBD_DANISH },
118 { 4, 84,
"sun(type5tuvhobo)", KBD_GERMAN },
119 { 4, 85,
"sun(type5tuvhobo)", KBD_ITALIAN },
120 { 4, 86,
"sun(type5tuvhobo)", KBD_DUTCH },
121 { 4, 87,
"sun(type5tuvhobo)", KBD_NORWEGIAN },
122 { 4, 88,
"sun(type5tuvhobo)", KBD_PORTUGUESE },
123 { 4, 89,
"sun(type5tuvhobo)", KBD_SPANISH },
124 { 4, 90,
"sun(type5tuvhobo)", KBD_SWEDISH },
125 { 4, 91,
"sun(type5tuvhobo)", KBD_SWISS_FRENCH },
126 { 4, 92,
"sun(type5tuvhobo)", KBD_SWISS_GERMAN },
127 { 4, 93,
"sun(type5tuvhobo)", KBD_UNITED_KINGDOM },
128 { 4, 94,
"sun(type5hobo)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 },
129 { 4, 95,
"sun(type5hobo)", KBD_CHINESE_TRADITIONAL_PHONETIC },
130 { 4, 96,
"sun(type5jphobo)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 },
131 { 4, 97,
"sun(type5tuvhobo)", KBD_CANADIAN_FRENCH },
132 { 101, 1,
"digital_vndr/pc(pc104)", KBD_US },
133 { 101, 34,
"digital_vndr/pc(pc104)", KBD_US },
134 { 101, 35,
"digital_vndr/pc(pc104)", KBD_FRENCH },
135 { 101, 36,
"digital_vndr/pc(pc104)", KBD_DANISH },
136 { 101, 37,
"digital_vndr/pc(pc104)", KBD_GERMAN },
137 { 101, 38,
"digital_vndr/pc(pc104)", KBD_ITALIAN },
138 { 101, 39,
"digital_vndr/pc(pc104)", KBD_DUTCH },
139 { 101, 40,
"digital_vndr/pc(pc104)", KBD_NORWEGIAN },
140 { 101, 41,
"digital_vndr/pc(pc104)", KBD_PORTUGUESE },
141 { 101, 42,
"digital_vndr/pc(pc104)", KBD_SPANISH },
142 { 101, 43,
"digital_vndr/pc(pc104)", KBD_SWEDISH },
143 { 101, 44,
"digital_vndr/pc(pc104)", KBD_SWISS_FRENCH },
144 { 101, 45,
"digital_vndr/pc(pc104)", KBD_SWISS_GERMAN },
145 { 101, 46,
"digital_vndr/pc(pc104)", KBD_UNITED_KINGDOM },
146 { 101, 47,
"digital_vndr/pc(pc104)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 },
147 { 101, 48,
"digital_vndr/pc(pc104)", KBD_CHINESE_TRADITIONAL_PHONETIC },
148 { 101, 49,
"digital_vndr/pc(lk411jj)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 },
149 { 101, 50,
"digital_vndr/pc(pc104)", KBD_CANADIAN_FRENCH },
150 { 101, 51,
"digital_vndr/pc(pc104)", KBD_HUNGARIAN },
151 { 101, 52,
"digital_vndr/pc(pc104)", KBD_POLISH_214 },
152 { 101, 53,
"digital_vndr/pc(pc104)", KBD_CZECH },
153 { 101, 54,
"digital_vndr/pc(pc104)", KBD_RUSSIAN },
154 { 101, 55,
"digital_vndr/pc(pc104)", KBD_LATVIAN },
155 { 101, 56,
"digital_vndr/pc(pc104)", KBD_TURKISH_Q },
156 { 101, 57,
"digital_vndr/pc(pc104)", KBD_GREEK },
157 { 101, 59,
"digital_vndr/pc(pc104)", KBD_LITHUANIAN },
158 { 101, 1001,
"digital_vndr/pc(pc104)", KBD_US },
159 { 6, 6,
"sun(type6tuv)", KBD_DANISH },
160 { 6, 7,
"sun(type6tuv)", KBD_FINNISH },
161 { 6, 8,
"sun(type6tuv)", KBD_FRENCH },
162 { 6, 9,
"sun(type6tuv)", KBD_GERMAN },
163 { 6, 14,
"sun(type6tuv)", KBD_ITALIAN },
164 { 6, 15,
"sun(type6jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 },
165 { 6, 16,
"sun(type6)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 },
166 { 6, 18,
"sun(type6tuv)", KBD_DUTCH },
167 { 6, 19,
"sun(type6tuv)", KBD_NORWEGIAN },
168 { 6, 22,
"sun(type6tuv)", KBD_PORTUGUESE },
169 { 6, 23,
"sun(type6tuv)", KBD_RUSSIAN },
170 { 6, 25,
"sun(type6tuv)", KBD_SPANISH },
171 { 6, 26,
"sun(type6tuv)", KBD_SWEDISH },
172 { 6, 27,
"sun(type6tuv)", KBD_SWISS_FRENCH },
173 { 6, 28,
"sun(type6tuv)", KBD_SWISS_GERMAN },
174 { 6, 30,
"sun(type6)", KBD_CHINESE_TRADITIONAL_PHONETIC },
175 { 6, 32,
"sun(type6tuv)", KBD_UNITED_KINGDOM },
176 { 6, 33,
"sun(type6)", KBD_US },
177 { 6, 1,
"sun(type6tuv)", KBD_ARABIC_101 },
178 { 6, 2,
"sun(type6tuv)", KBD_BELGIAN_FRENCH },
179 { 6, 31,
"sun(type6tuv)", KBD_TURKISH_Q },
180 { 6, 35,
"sun(type6tuv)", KBD_TURKISH_F },
181 { 6, 271,
"sun(type6jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 },
182 { 6, 264,
"sun(type6tuv)", KBD_ALBANIAN },
183 { 6, 261,
"sun(type6tuv)", KBD_BELARUSIAN },
184 { 6, 260,
"sun(type6tuv)", KBD_BULGARIAN },
185 { 6, 259,
"sun(type6tuv)", KBD_CROATIAN },
186 { 6, 5,
"sun(type6tuv)", KBD_CZECH },
187 { 6, 4,
"sun(type6tuv)", KBD_CANADIAN_FRENCH },
188 { 6, 12,
"sun(type6tuv)", KBD_HUNGARIAN },
189 { 6, 10,
"sun(type6tuv)", KBD_GREEK },
190 { 6, 17,
"sun(type6)", KBD_LATIN_AMERICAN },
191 { 6, 265,
"sun(type6tuv)", KBD_LITHUANIAN },
192 { 6, 266,
"sun(type6tuv)", KBD_LATVIAN },
193 { 6, 267,
"sun(type6tuv)", KBD_FYRO_MACEDONIAN },
194 { 6, 263,
"sun(type6tuv)", KBD_MALTESE_47_KEY },
195 { 6, 262,
"sun(type6tuv)", KBD_MALTESE_48_KEY },
196 { 6, 21,
"sun(type6tuv)", KBD_POLISH_214 },
197 { 6, 257,
"sun(type6tuv)", KBD_SERBIAN_LATIN },
198 { 6, 256,
"sun(type6tuv)", KBD_SLOVENIAN },
199 { 6, 24,
"sun(type6tuv)", KBD_SLOVAK },
200 { 6, 3,
"sun(type6)", KBD_CANADIAN_MULTILINGUAL_STANDARD },
201 { 6, 272,
"sun(type6)", KBD_PORTUGUESE_BRAZILIAN_ABNT }
204 int freerdp_get_solaris_keyboard_layout_and_type(
int* type,
int* layout)
223 kbd = popen(
"kbd -t -l",
"r");
228 while (fgets(buffer,
sizeof(buffer), kbd) != NULL)
232 if ((pch = strstr(buffer,
"type=")) != NULL)
234 beg = pch +
sizeof(
"type=") - 1;
235 end = strchr(beg,
'\n');
238 val = strtol(beg, NULL, 0);
240 if ((errno != 0) || (val < INT32_MIN) || (val > INT32_MAX))
245 else if ((pch = strstr(buffer,
"layout=")) != NULL)
247 beg = pch +
sizeof(
"layout=") - 1;
248 end = strchr(beg,
' ');
251 val = strtol(beg, NULL, 0);
253 if ((errno != 0) || (val < INT32_MIN) || (val > INT32_MAX))
266 DWORD freerdp_detect_solaris_keyboard_layout()
271 if (freerdp_get_solaris_keyboard_layout_and_type(&type, &layout) < 0)
274 for (
size_t i = 0; i < ARRAYSIZE(SOLARIS_KEYBOARD_TABLE); i++)
276 if (SOLARIS_KEYBOARD_TABLE[i].type == type)
278 if (SOLARIS_KEYBOARD_TABLE[i].layout == layout)
279 return SOLARIS_KEYBOARD_TABLE[i].keyboardLayoutId;