1 /// Translated from C to D
2 module glfw3.xkb_unicode;
3 
4 extern(C): @nogc: nothrow: __gshared:
5 //========================================================================
6 // GLFW 3.3 X11 - www.glfw.org
7 //------------------------------------------------------------------------
8 // Copyright (c) 2002-2006 Marcus Geelnard
9 // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
10 //
11 // This software is provided 'as-is', without any express or implied
12 // warranty. In no event will the authors be held liable for any damages
13 // arising from the use of this software.
14 //
15 // Permission is granted to anyone to use this software for any purpose,
16 // including commercial applications, and to alter it and redistribute it
17 // freely, subject to the following restrictions:
18 //
19 // 1. The origin of this software must not be misrepresented; you must not
20 //    claim that you wrote the original software. If you use this software
21 //    in a product, an acknowledgment in the product documentation would
22 //    be appreciated but is not required.
23 //
24 // 2. Altered source versions must be plainly marked as such, and must not
25 //    be misrepresented as being the original software.
26 //
27 // 3. This notice may not be removed or altered from any source
28 //    distribution.
29 //
30 //========================================================================
31 // It is fine to use C99 in this file because it will not be built with VS
32 //========================================================================
33 
34 import glfw3.internal;
35 
36 /*
37  * Marcus: This code was originally written by Markus G. Kuhn.
38  * I have made some slight changes (trimmed it down a bit from >60 KB to
39  * 20 KB), but the functionality is the same.
40  */
41 
42 /*
43  * This module converts keysym values into the corresponding ISO 10646
44  * (UCS, Unicode) values.
45  *
46  * The array keysymtab[] contains pairs of X11 keysym values for graphical
47  * characters and the corresponding Unicode value. The function
48  * _glfwKeySym2Unicode() maps a keysym onto a Unicode value using a binary
49  * search, therefore keysymtab[] must remain SORTED by keysym value.
50  *
51  * We allow to represent any UCS character in the range U-00000000 to
52  * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
53  * This admittedly does not cover the entire 31-bit space of UCS, but
54  * it does cover all of the characters up to U-10FFFF, which can be
55  * represented by UTF-16, and more, and it is very unlikely that higher
56  * UCS codes will ever be assigned by ISO. So to get Unicode character
57  * U+ABCD you can directly use keysym 0x0100abcd.
58  *
59  * Original author: Markus G. Kuhn <mkuhn@acm.org>, University of
60  *                  Cambridge, April 2001
61  *
62  * Special thanks to Richard Verhoeven <river@win.tue.nl> for preparing
63  * an initial draft of the mapping table.
64  *
65  */
66 
67 
68 //************************************************************************
69 //****                KeySym to Unicode mapping table                 ****
70 //************************************************************************
71 
72 struct codepair {
73   ushort keysym;
74   ushort ucs;
75 }
76 private alias P = codepair;
77 
78 private immutable codepair[828] keysymtab = [
79   P( 0x01a1, 0x0104 ),
80   P( 0x01a2, 0x02d8 ),
81   P( 0x01a3, 0x0141 ),
82   P( 0x01a5, 0x013d ),
83   P( 0x01a6, 0x015a ),
84   P( 0x01a9, 0x0160 ),
85   P( 0x01aa, 0x015e ),
86   P( 0x01ab, 0x0164 ),
87   P( 0x01ac, 0x0179 ),
88   P( 0x01ae, 0x017d ),
89   P( 0x01af, 0x017b ),
90   P( 0x01b1, 0x0105 ),
91   P( 0x01b2, 0x02db ),
92   P( 0x01b3, 0x0142 ),
93   P( 0x01b5, 0x013e ),
94   P( 0x01b6, 0x015b ),
95   P( 0x01b7, 0x02c7 ),
96   P( 0x01b9, 0x0161 ),
97   P( 0x01ba, 0x015f ),
98   P( 0x01bb, 0x0165 ),
99   P( 0x01bc, 0x017a ),
100   P( 0x01bd, 0x02dd ),
101   P( 0x01be, 0x017e ),
102   P( 0x01bf, 0x017c ),
103   P( 0x01c0, 0x0154 ),
104   P( 0x01c3, 0x0102 ),
105   P( 0x01c5, 0x0139 ),
106   P( 0x01c6, 0x0106 ),
107   P( 0x01c8, 0x010c ),
108   P( 0x01ca, 0x0118 ),
109   P( 0x01cc, 0x011a ),
110   P( 0x01cf, 0x010e ),
111   P( 0x01d0, 0x0110 ),
112   P( 0x01d1, 0x0143 ),
113   P( 0x01d2, 0x0147 ),
114   P( 0x01d5, 0x0150 ),
115   P( 0x01d8, 0x0158 ),
116   P( 0x01d9, 0x016e ),
117   P( 0x01db, 0x0170 ),
118   P( 0x01de, 0x0162 ),
119   P( 0x01e0, 0x0155 ),
120   P( 0x01e3, 0x0103 ),
121   P( 0x01e5, 0x013a ),
122   P( 0x01e6, 0x0107 ),
123   P( 0x01e8, 0x010d ),
124   P( 0x01ea, 0x0119 ),
125   P( 0x01ec, 0x011b ),
126   P( 0x01ef, 0x010f ),
127   P( 0x01f0, 0x0111 ),
128   P( 0x01f1, 0x0144 ),
129   P( 0x01f2, 0x0148 ),
130   P( 0x01f5, 0x0151 ),
131   P( 0x01f8, 0x0159 ),
132   P( 0x01f9, 0x016f ),
133   P( 0x01fb, 0x0171 ),
134   P( 0x01fe, 0x0163 ),
135   P( 0x01ff, 0x02d9 ),
136   P( 0x02a1, 0x0126 ),
137   P( 0x02a6, 0x0124 ),
138   P( 0x02a9, 0x0130 ),
139   P( 0x02ab, 0x011e ),
140   P( 0x02ac, 0x0134 ),
141   P( 0x02b1, 0x0127 ),
142   P( 0x02b6, 0x0125 ),
143   P( 0x02b9, 0x0131 ),
144   P( 0x02bb, 0x011f ),
145   P( 0x02bc, 0x0135 ),
146   P( 0x02c5, 0x010a ),
147   P( 0x02c6, 0x0108 ),
148   P( 0x02d5, 0x0120 ),
149   P( 0x02d8, 0x011c ),
150   P( 0x02dd, 0x016c ),
151   P( 0x02de, 0x015c ),
152   P( 0x02e5, 0x010b ),
153   P( 0x02e6, 0x0109 ),
154   P( 0x02f5, 0x0121 ),
155   P( 0x02f8, 0x011d ),
156   P( 0x02fd, 0x016d ),
157   P( 0x02fe, 0x015d ),
158   P( 0x03a2, 0x0138 ),
159   P( 0x03a3, 0x0156 ),
160   P( 0x03a5, 0x0128 ),
161   P( 0x03a6, 0x013b ),
162   P( 0x03aa, 0x0112 ),
163   P( 0x03ab, 0x0122 ),
164   P( 0x03ac, 0x0166 ),
165   P( 0x03b3, 0x0157 ),
166   P( 0x03b5, 0x0129 ),
167   P( 0x03b6, 0x013c ),
168   P( 0x03ba, 0x0113 ),
169   P( 0x03bb, 0x0123 ),
170   P( 0x03bc, 0x0167 ),
171   P( 0x03bd, 0x014a ),
172   P( 0x03bf, 0x014b ),
173   P( 0x03c0, 0x0100 ),
174   P( 0x03c7, 0x012e ),
175   P( 0x03cc, 0x0116 ),
176   P( 0x03cf, 0x012a ),
177   P( 0x03d1, 0x0145 ),
178   P( 0x03d2, 0x014c ),
179   P( 0x03d3, 0x0136 ),
180   P( 0x03d9, 0x0172 ),
181   P( 0x03dd, 0x0168 ),
182   P( 0x03de, 0x016a ),
183   P( 0x03e0, 0x0101 ),
184   P( 0x03e7, 0x012f ),
185   P( 0x03ec, 0x0117 ),
186   P( 0x03ef, 0x012b ),
187   P( 0x03f1, 0x0146 ),
188   P( 0x03f2, 0x014d ),
189   P( 0x03f3, 0x0137 ),
190   P( 0x03f9, 0x0173 ),
191   P( 0x03fd, 0x0169 ),
192   P( 0x03fe, 0x016b ),
193   P( 0x047e, 0x203e ),
194   P( 0x04a1, 0x3002 ),
195   P( 0x04a2, 0x300c ),
196   P( 0x04a3, 0x300d ),
197   P( 0x04a4, 0x3001 ),
198   P( 0x04a5, 0x30fb ),
199   P( 0x04a6, 0x30f2 ),
200   P( 0x04a7, 0x30a1 ),
201   P( 0x04a8, 0x30a3 ),
202   P( 0x04a9, 0x30a5 ),
203   P( 0x04aa, 0x30a7 ),
204   P( 0x04ab, 0x30a9 ),
205   P( 0x04ac, 0x30e3 ),
206   P( 0x04ad, 0x30e5 ),
207   P( 0x04ae, 0x30e7 ),
208   P( 0x04af, 0x30c3 ),
209   P( 0x04b0, 0x30fc ),
210   P( 0x04b1, 0x30a2 ),
211   P( 0x04b2, 0x30a4 ),
212   P( 0x04b3, 0x30a6 ),
213   P( 0x04b4, 0x30a8 ),
214   P( 0x04b5, 0x30aa ),
215   P( 0x04b6, 0x30ab ),
216   P( 0x04b7, 0x30ad ),
217   P( 0x04b8, 0x30af ),
218   P( 0x04b9, 0x30b1 ),
219   P( 0x04ba, 0x30b3 ),
220   P( 0x04bb, 0x30b5 ),
221   P( 0x04bc, 0x30b7 ),
222   P( 0x04bd, 0x30b9 ),
223   P( 0x04be, 0x30bb ),
224   P( 0x04bf, 0x30bd ),
225   P( 0x04c0, 0x30bf ),
226   P( 0x04c1, 0x30c1 ),
227   P( 0x04c2, 0x30c4 ),
228   P( 0x04c3, 0x30c6 ),
229   P( 0x04c4, 0x30c8 ),
230   P( 0x04c5, 0x30ca ),
231   P( 0x04c6, 0x30cb ),
232   P( 0x04c7, 0x30cc ),
233   P( 0x04c8, 0x30cd ),
234   P( 0x04c9, 0x30ce ),
235   P( 0x04ca, 0x30cf ),
236   P( 0x04cb, 0x30d2 ),
237   P( 0x04cc, 0x30d5 ),
238   P( 0x04cd, 0x30d8 ),
239   P( 0x04ce, 0x30db ),
240   P( 0x04cf, 0x30de ),
241   P( 0x04d0, 0x30df ),
242   P( 0x04d1, 0x30e0 ),
243   P( 0x04d2, 0x30e1 ),
244   P( 0x04d3, 0x30e2 ),
245   P( 0x04d4, 0x30e4 ),
246   P( 0x04d5, 0x30e6 ),
247   P( 0x04d6, 0x30e8 ),
248   P( 0x04d7, 0x30e9 ),
249   P( 0x04d8, 0x30ea ),
250   P( 0x04d9, 0x30eb ),
251   P( 0x04da, 0x30ec ),
252   P( 0x04db, 0x30ed ),
253   P( 0x04dc, 0x30ef ),
254   P( 0x04dd, 0x30f3 ),
255   P( 0x04de, 0x309b ),
256   P( 0x04df, 0x309c ),
257   P( 0x05ac, 0x060c ),
258   P( 0x05bb, 0x061b ),
259   P( 0x05bf, 0x061f ),
260   P( 0x05c1, 0x0621 ),
261   P( 0x05c2, 0x0622 ),
262   P( 0x05c3, 0x0623 ),
263   P( 0x05c4, 0x0624 ),
264   P( 0x05c5, 0x0625 ),
265   P( 0x05c6, 0x0626 ),
266   P( 0x05c7, 0x0627 ),
267   P( 0x05c8, 0x0628 ),
268   P( 0x05c9, 0x0629 ),
269   P( 0x05ca, 0x062a ),
270   P( 0x05cb, 0x062b ),
271   P( 0x05cc, 0x062c ),
272   P( 0x05cd, 0x062d ),
273   P( 0x05ce, 0x062e ),
274   P( 0x05cf, 0x062f ),
275   P( 0x05d0, 0x0630 ),
276   P( 0x05d1, 0x0631 ),
277   P( 0x05d2, 0x0632 ),
278   P( 0x05d3, 0x0633 ),
279   P( 0x05d4, 0x0634 ),
280   P( 0x05d5, 0x0635 ),
281   P( 0x05d6, 0x0636 ),
282   P( 0x05d7, 0x0637 ),
283   P( 0x05d8, 0x0638 ),
284   P( 0x05d9, 0x0639 ),
285   P( 0x05da, 0x063a ),
286   P( 0x05e0, 0x0640 ),
287   P( 0x05e1, 0x0641 ),
288   P( 0x05e2, 0x0642 ),
289   P( 0x05e3, 0x0643 ),
290   P( 0x05e4, 0x0644 ),
291   P( 0x05e5, 0x0645 ),
292   P( 0x05e6, 0x0646 ),
293   P( 0x05e7, 0x0647 ),
294   P( 0x05e8, 0x0648 ),
295   P( 0x05e9, 0x0649 ),
296   P( 0x05ea, 0x064a ),
297   P( 0x05eb, 0x064b ),
298   P( 0x05ec, 0x064c ),
299   P( 0x05ed, 0x064d ),
300   P( 0x05ee, 0x064e ),
301   P( 0x05ef, 0x064f ),
302   P( 0x05f0, 0x0650 ),
303   P( 0x05f1, 0x0651 ),
304   P( 0x05f2, 0x0652 ),
305   P( 0x06a1, 0x0452 ),
306   P( 0x06a2, 0x0453 ),
307   P( 0x06a3, 0x0451 ),
308   P( 0x06a4, 0x0454 ),
309   P( 0x06a5, 0x0455 ),
310   P( 0x06a6, 0x0456 ),
311   P( 0x06a7, 0x0457 ),
312   P( 0x06a8, 0x0458 ),
313   P( 0x06a9, 0x0459 ),
314   P( 0x06aa, 0x045a ),
315   P( 0x06ab, 0x045b ),
316   P( 0x06ac, 0x045c ),
317   P( 0x06ae, 0x045e ),
318   P( 0x06af, 0x045f ),
319   P( 0x06b0, 0x2116 ),
320   P( 0x06b1, 0x0402 ),
321   P( 0x06b2, 0x0403 ),
322   P( 0x06b3, 0x0401 ),
323   P( 0x06b4, 0x0404 ),
324   P( 0x06b5, 0x0405 ),
325   P( 0x06b6, 0x0406 ),
326   P( 0x06b7, 0x0407 ),
327   P( 0x06b8, 0x0408 ),
328   P( 0x06b9, 0x0409 ),
329   P( 0x06ba, 0x040a ),
330   P( 0x06bb, 0x040b ),
331   P( 0x06bc, 0x040c ),
332   P( 0x06be, 0x040e ),
333   P( 0x06bf, 0x040f ),
334   P( 0x06c0, 0x044e ),
335   P( 0x06c1, 0x0430 ),
336   P( 0x06c2, 0x0431 ),
337   P( 0x06c3, 0x0446 ),
338   P( 0x06c4, 0x0434 ),
339   P( 0x06c5, 0x0435 ),
340   P( 0x06c6, 0x0444 ),
341   P( 0x06c7, 0x0433 ),
342   P( 0x06c8, 0x0445 ),
343   P( 0x06c9, 0x0438 ),
344   P( 0x06ca, 0x0439 ),
345   P( 0x06cb, 0x043a ),
346   P( 0x06cc, 0x043b ),
347   P( 0x06cd, 0x043c ),
348   P( 0x06ce, 0x043d ),
349   P( 0x06cf, 0x043e ),
350   P( 0x06d0, 0x043f ),
351   P( 0x06d1, 0x044f ),
352   P( 0x06d2, 0x0440 ),
353   P( 0x06d3, 0x0441 ),
354   P( 0x06d4, 0x0442 ),
355   P( 0x06d5, 0x0443 ),
356   P( 0x06d6, 0x0436 ),
357   P( 0x06d7, 0x0432 ),
358   P( 0x06d8, 0x044c ),
359   P( 0x06d9, 0x044b ),
360   P( 0x06da, 0x0437 ),
361   P( 0x06db, 0x0448 ),
362   P( 0x06dc, 0x044d ),
363   P( 0x06dd, 0x0449 ),
364   P( 0x06de, 0x0447 ),
365   P( 0x06df, 0x044a ),
366   P( 0x06e0, 0x042e ),
367   P( 0x06e1, 0x0410 ),
368   P( 0x06e2, 0x0411 ),
369   P( 0x06e3, 0x0426 ),
370   P( 0x06e4, 0x0414 ),
371   P( 0x06e5, 0x0415 ),
372   P( 0x06e6, 0x0424 ),
373   P( 0x06e7, 0x0413 ),
374   P( 0x06e8, 0x0425 ),
375   P( 0x06e9, 0x0418 ),
376   P( 0x06ea, 0x0419 ),
377   P( 0x06eb, 0x041a ),
378   P( 0x06ec, 0x041b ),
379   P( 0x06ed, 0x041c ),
380   P( 0x06ee, 0x041d ),
381   P( 0x06ef, 0x041e ),
382   P( 0x06f0, 0x041f ),
383   P( 0x06f1, 0x042f ),
384   P( 0x06f2, 0x0420 ),
385   P( 0x06f3, 0x0421 ),
386   P( 0x06f4, 0x0422 ),
387   P( 0x06f5, 0x0423 ),
388   P( 0x06f6, 0x0416 ),
389   P( 0x06f7, 0x0412 ),
390   P( 0x06f8, 0x042c ),
391   P( 0x06f9, 0x042b ),
392   P( 0x06fa, 0x0417 ),
393   P( 0x06fb, 0x0428 ),
394   P( 0x06fc, 0x042d ),
395   P( 0x06fd, 0x0429 ),
396   P( 0x06fe, 0x0427 ),
397   P( 0x06ff, 0x042a ),
398   P( 0x07a1, 0x0386 ),
399   P( 0x07a2, 0x0388 ),
400   P( 0x07a3, 0x0389 ),
401   P( 0x07a4, 0x038a ),
402   P( 0x07a5, 0x03aa ),
403   P( 0x07a7, 0x038c ),
404   P( 0x07a8, 0x038e ),
405   P( 0x07a9, 0x03ab ),
406   P( 0x07ab, 0x038f ),
407   P( 0x07ae, 0x0385 ),
408   P( 0x07af, 0x2015 ),
409   P( 0x07b1, 0x03ac ),
410   P( 0x07b2, 0x03ad ),
411   P( 0x07b3, 0x03ae ),
412   P( 0x07b4, 0x03af ),
413   P( 0x07b5, 0x03ca ),
414   P( 0x07b6, 0x0390 ),
415   P( 0x07b7, 0x03cc ),
416   P( 0x07b8, 0x03cd ),
417   P( 0x07b9, 0x03cb ),
418   P( 0x07ba, 0x03b0 ),
419   P( 0x07bb, 0x03ce ),
420   P( 0x07c1, 0x0391 ),
421   P( 0x07c2, 0x0392 ),
422   P( 0x07c3, 0x0393 ),
423   P( 0x07c4, 0x0394 ),
424   P( 0x07c5, 0x0395 ),
425   P( 0x07c6, 0x0396 ),
426   P( 0x07c7, 0x0397 ),
427   P( 0x07c8, 0x0398 ),
428   P( 0x07c9, 0x0399 ),
429   P( 0x07ca, 0x039a ),
430   P( 0x07cb, 0x039b ),
431   P( 0x07cc, 0x039c ),
432   P( 0x07cd, 0x039d ),
433   P( 0x07ce, 0x039e ),
434   P( 0x07cf, 0x039f ),
435   P( 0x07d0, 0x03a0 ),
436   P( 0x07d1, 0x03a1 ),
437   P( 0x07d2, 0x03a3 ),
438   P( 0x07d4, 0x03a4 ),
439   P( 0x07d5, 0x03a5 ),
440   P( 0x07d6, 0x03a6 ),
441   P( 0x07d7, 0x03a7 ),
442   P( 0x07d8, 0x03a8 ),
443   P( 0x07d9, 0x03a9 ),
444   P( 0x07e1, 0x03b1 ),
445   P( 0x07e2, 0x03b2 ),
446   P( 0x07e3, 0x03b3 ),
447   P( 0x07e4, 0x03b4 ),
448   P( 0x07e5, 0x03b5 ),
449   P( 0x07e6, 0x03b6 ),
450   P( 0x07e7, 0x03b7 ),
451   P( 0x07e8, 0x03b8 ),
452   P( 0x07e9, 0x03b9 ),
453   P( 0x07ea, 0x03ba ),
454   P( 0x07eb, 0x03bb ),
455   P( 0x07ec, 0x03bc ),
456   P( 0x07ed, 0x03bd ),
457   P( 0x07ee, 0x03be ),
458   P( 0x07ef, 0x03bf ),
459   P( 0x07f0, 0x03c0 ),
460   P( 0x07f1, 0x03c1 ),
461   P( 0x07f2, 0x03c3 ),
462   P( 0x07f3, 0x03c2 ),
463   P( 0x07f4, 0x03c4 ),
464   P( 0x07f5, 0x03c5 ),
465   P( 0x07f6, 0x03c6 ),
466   P( 0x07f7, 0x03c7 ),
467   P( 0x07f8, 0x03c8 ),
468   P( 0x07f9, 0x03c9 ),
469   P( 0x08a1, 0x23b7 ),
470   P( 0x08a2, 0x250c ),
471   P( 0x08a3, 0x2500 ),
472   P( 0x08a4, 0x2320 ),
473   P( 0x08a5, 0x2321 ),
474   P( 0x08a6, 0x2502 ),
475   P( 0x08a7, 0x23a1 ),
476   P( 0x08a8, 0x23a3 ),
477   P( 0x08a9, 0x23a4 ),
478   P( 0x08aa, 0x23a6 ),
479   P( 0x08ab, 0x239b ),
480   P( 0x08ac, 0x239d ),
481   P( 0x08ad, 0x239e ),
482   P( 0x08ae, 0x23a0 ),
483   P( 0x08af, 0x23a8 ),
484   P( 0x08b0, 0x23ac ),
485   P( 0x08bc, 0x2264 ),
486   P( 0x08bd, 0x2260 ),
487   P( 0x08be, 0x2265 ),
488   P( 0x08bf, 0x222b ),
489   P( 0x08c0, 0x2234 ),
490   P( 0x08c1, 0x221d ),
491   P( 0x08c2, 0x221e ),
492   P( 0x08c5, 0x2207 ),
493   P( 0x08c8, 0x223c ),
494   P( 0x08c9, 0x2243 ),
495   P( 0x08cd, 0x21d4 ),
496   P( 0x08ce, 0x21d2 ),
497   P( 0x08cf, 0x2261 ),
498   P( 0x08d6, 0x221a ),
499   P( 0x08da, 0x2282 ),
500   P( 0x08db, 0x2283 ),
501   P( 0x08dc, 0x2229 ),
502   P( 0x08dd, 0x222a ),
503   P( 0x08de, 0x2227 ),
504   P( 0x08df, 0x2228 ),
505   P( 0x08ef, 0x2202 ),
506   P( 0x08f6, 0x0192 ),
507   P( 0x08fb, 0x2190 ),
508   P( 0x08fc, 0x2191 ),
509   P( 0x08fd, 0x2192 ),
510   P( 0x08fe, 0x2193 ),
511   P( 0x09e0, 0x25c6 ),
512   P( 0x09e1, 0x2592 ),
513   P( 0x09e2, 0x2409 ),
514   P( 0x09e3, 0x240c ),
515   P( 0x09e4, 0x240d ),
516   P( 0x09e5, 0x240a ),
517   P( 0x09e8, 0x2424 ),
518   P( 0x09e9, 0x240b ),
519   P( 0x09ea, 0x2518 ),
520   P( 0x09eb, 0x2510 ),
521   P( 0x09ec, 0x250c ),
522   P( 0x09ed, 0x2514 ),
523   P( 0x09ee, 0x253c ),
524   P( 0x09ef, 0x23ba ),
525   P( 0x09f0, 0x23bb ),
526   P( 0x09f1, 0x2500 ),
527   P( 0x09f2, 0x23bc ),
528   P( 0x09f3, 0x23bd ),
529   P( 0x09f4, 0x251c ),
530   P( 0x09f5, 0x2524 ),
531   P( 0x09f6, 0x2534 ),
532   P( 0x09f7, 0x252c ),
533   P( 0x09f8, 0x2502 ),
534   P( 0x0aa1, 0x2003 ),
535   P( 0x0aa2, 0x2002 ),
536   P( 0x0aa3, 0x2004 ),
537   P( 0x0aa4, 0x2005 ),
538   P( 0x0aa5, 0x2007 ),
539   P( 0x0aa6, 0x2008 ),
540   P( 0x0aa7, 0x2009 ),
541   P( 0x0aa8, 0x200a ),
542   P( 0x0aa9, 0x2014 ),
543   P( 0x0aaa, 0x2013 ),
544   P( 0x0aae, 0x2026 ),
545   P( 0x0aaf, 0x2025 ),
546   P( 0x0ab0, 0x2153 ),
547   P( 0x0ab1, 0x2154 ),
548   P( 0x0ab2, 0x2155 ),
549   P( 0x0ab3, 0x2156 ),
550   P( 0x0ab4, 0x2157 ),
551   P( 0x0ab5, 0x2158 ),
552   P( 0x0ab6, 0x2159 ),
553   P( 0x0ab7, 0x215a ),
554   P( 0x0ab8, 0x2105 ),
555   P( 0x0abb, 0x2012 ),
556   P( 0x0abc, 0x2329 ),
557   P( 0x0abe, 0x232a ),
558   P( 0x0ac3, 0x215b ),
559   P( 0x0ac4, 0x215c ),
560   P( 0x0ac5, 0x215d ),
561   P( 0x0ac6, 0x215e ),
562   P( 0x0ac9, 0x2122 ),
563   P( 0x0aca, 0x2613 ),
564   P( 0x0acc, 0x25c1 ),
565   P( 0x0acd, 0x25b7 ),
566   P( 0x0ace, 0x25cb ),
567   P( 0x0acf, 0x25af ),
568   P( 0x0ad0, 0x2018 ),
569   P( 0x0ad1, 0x2019 ),
570   P( 0x0ad2, 0x201c ),
571   P( 0x0ad3, 0x201d ),
572   P( 0x0ad4, 0x211e ),
573   P( 0x0ad6, 0x2032 ),
574   P( 0x0ad7, 0x2033 ),
575   P( 0x0ad9, 0x271d ),
576   P( 0x0adb, 0x25ac ),
577   P( 0x0adc, 0x25c0 ),
578   P( 0x0add, 0x25b6 ),
579   P( 0x0ade, 0x25cf ),
580   P( 0x0adf, 0x25ae ),
581   P( 0x0ae0, 0x25e6 ),
582   P( 0x0ae1, 0x25ab ),
583   P( 0x0ae2, 0x25ad ),
584   P( 0x0ae3, 0x25b3 ),
585   P( 0x0ae4, 0x25bd ),
586   P( 0x0ae5, 0x2606 ),
587   P( 0x0ae6, 0x2022 ),
588   P( 0x0ae7, 0x25aa ),
589   P( 0x0ae8, 0x25b2 ),
590   P( 0x0ae9, 0x25bc ),
591   P( 0x0aea, 0x261c ),
592   P( 0x0aeb, 0x261e ),
593   P( 0x0aec, 0x2663 ),
594   P( 0x0aed, 0x2666 ),
595   P( 0x0aee, 0x2665 ),
596   P( 0x0af0, 0x2720 ),
597   P( 0x0af1, 0x2020 ),
598   P( 0x0af2, 0x2021 ),
599   P( 0x0af3, 0x2713 ),
600   P( 0x0af4, 0x2717 ),
601   P( 0x0af5, 0x266f ),
602   P( 0x0af6, 0x266d ),
603   P( 0x0af7, 0x2642 ),
604   P( 0x0af8, 0x2640 ),
605   P( 0x0af9, 0x260e ),
606   P( 0x0afa, 0x2315 ),
607   P( 0x0afb, 0x2117 ),
608   P( 0x0afc, 0x2038 ),
609   P( 0x0afd, 0x201a ),
610   P( 0x0afe, 0x201e ),
611   P( 0x0ba3, 0x003c ),
612   P( 0x0ba6, 0x003e ),
613   P( 0x0ba8, 0x2228 ),
614   P( 0x0ba9, 0x2227 ),
615   P( 0x0bc0, 0x00af ),
616   P( 0x0bc2, 0x22a5 ),
617   P( 0x0bc3, 0x2229 ),
618   P( 0x0bc4, 0x230a ),
619   P( 0x0bc6, 0x005f ),
620   P( 0x0bca, 0x2218 ),
621   P( 0x0bcc, 0x2395 ),
622   P( 0x0bce, 0x22a4 ),
623   P( 0x0bcf, 0x25cb ),
624   P( 0x0bd3, 0x2308 ),
625   P( 0x0bd6, 0x222a ),
626   P( 0x0bd8, 0x2283 ),
627   P( 0x0bda, 0x2282 ),
628   P( 0x0bdc, 0x22a2 ),
629   P( 0x0bfc, 0x22a3 ),
630   P( 0x0cdf, 0x2017 ),
631   P( 0x0ce0, 0x05d0 ),
632   P( 0x0ce1, 0x05d1 ),
633   P( 0x0ce2, 0x05d2 ),
634   P( 0x0ce3, 0x05d3 ),
635   P( 0x0ce4, 0x05d4 ),
636   P( 0x0ce5, 0x05d5 ),
637   P( 0x0ce6, 0x05d6 ),
638   P( 0x0ce7, 0x05d7 ),
639   P( 0x0ce8, 0x05d8 ),
640   P( 0x0ce9, 0x05d9 ),
641   P( 0x0cea, 0x05da ),
642   P( 0x0ceb, 0x05db ),
643   P( 0x0cec, 0x05dc ),
644   P( 0x0ced, 0x05dd ),
645   P( 0x0cee, 0x05de ),
646   P( 0x0cef, 0x05df ),
647   P( 0x0cf0, 0x05e0 ),
648   P( 0x0cf1, 0x05e1 ),
649   P( 0x0cf2, 0x05e2 ),
650   P( 0x0cf3, 0x05e3 ),
651   P( 0x0cf4, 0x05e4 ),
652   P( 0x0cf5, 0x05e5 ),
653   P( 0x0cf6, 0x05e6 ),
654   P( 0x0cf7, 0x05e7 ),
655   P( 0x0cf8, 0x05e8 ),
656   P( 0x0cf9, 0x05e9 ),
657   P( 0x0cfa, 0x05ea ),
658   P( 0x0da1, 0x0e01 ),
659   P( 0x0da2, 0x0e02 ),
660   P( 0x0da3, 0x0e03 ),
661   P( 0x0da4, 0x0e04 ),
662   P( 0x0da5, 0x0e05 ),
663   P( 0x0da6, 0x0e06 ),
664   P( 0x0da7, 0x0e07 ),
665   P( 0x0da8, 0x0e08 ),
666   P( 0x0da9, 0x0e09 ),
667   P( 0x0daa, 0x0e0a ),
668   P( 0x0dab, 0x0e0b ),
669   P( 0x0dac, 0x0e0c ),
670   P( 0x0dad, 0x0e0d ),
671   P( 0x0dae, 0x0e0e ),
672   P( 0x0daf, 0x0e0f ),
673   P( 0x0db0, 0x0e10 ),
674   P( 0x0db1, 0x0e11 ),
675   P( 0x0db2, 0x0e12 ),
676   P( 0x0db3, 0x0e13 ),
677   P( 0x0db4, 0x0e14 ),
678   P( 0x0db5, 0x0e15 ),
679   P( 0x0db6, 0x0e16 ),
680   P( 0x0db7, 0x0e17 ),
681   P( 0x0db8, 0x0e18 ),
682   P( 0x0db9, 0x0e19 ),
683   P( 0x0dba, 0x0e1a ),
684   P( 0x0dbb, 0x0e1b ),
685   P( 0x0dbc, 0x0e1c ),
686   P( 0x0dbd, 0x0e1d ),
687   P( 0x0dbe, 0x0e1e ),
688   P( 0x0dbf, 0x0e1f ),
689   P( 0x0dc0, 0x0e20 ),
690   P( 0x0dc1, 0x0e21 ),
691   P( 0x0dc2, 0x0e22 ),
692   P( 0x0dc3, 0x0e23 ),
693   P( 0x0dc4, 0x0e24 ),
694   P( 0x0dc5, 0x0e25 ),
695   P( 0x0dc6, 0x0e26 ),
696   P( 0x0dc7, 0x0e27 ),
697   P( 0x0dc8, 0x0e28 ),
698   P( 0x0dc9, 0x0e29 ),
699   P( 0x0dca, 0x0e2a ),
700   P( 0x0dcb, 0x0e2b ),
701   P( 0x0dcc, 0x0e2c ),
702   P( 0x0dcd, 0x0e2d ),
703   P( 0x0dce, 0x0e2e ),
704   P( 0x0dcf, 0x0e2f ),
705   P( 0x0dd0, 0x0e30 ),
706   P( 0x0dd1, 0x0e31 ),
707   P( 0x0dd2, 0x0e32 ),
708   P( 0x0dd3, 0x0e33 ),
709   P( 0x0dd4, 0x0e34 ),
710   P( 0x0dd5, 0x0e35 ),
711   P( 0x0dd6, 0x0e36 ),
712   P( 0x0dd7, 0x0e37 ),
713   P( 0x0dd8, 0x0e38 ),
714   P( 0x0dd9, 0x0e39 ),
715   P( 0x0dda, 0x0e3a ),
716   P( 0x0ddf, 0x0e3f ),
717   P( 0x0de0, 0x0e40 ),
718   P( 0x0de1, 0x0e41 ),
719   P( 0x0de2, 0x0e42 ),
720   P( 0x0de3, 0x0e43 ),
721   P( 0x0de4, 0x0e44 ),
722   P( 0x0de5, 0x0e45 ),
723   P( 0x0de6, 0x0e46 ),
724   P( 0x0de7, 0x0e47 ),
725   P( 0x0de8, 0x0e48 ),
726   P( 0x0de9, 0x0e49 ),
727   P( 0x0dea, 0x0e4a ),
728   P( 0x0deb, 0x0e4b ),
729   P( 0x0dec, 0x0e4c ),
730   P( 0x0ded, 0x0e4d ),
731   P( 0x0df0, 0x0e50 ),
732   P( 0x0df1, 0x0e51 ),
733   P( 0x0df2, 0x0e52 ),
734   P( 0x0df3, 0x0e53 ),
735   P( 0x0df4, 0x0e54 ),
736   P( 0x0df5, 0x0e55 ),
737   P( 0x0df6, 0x0e56 ),
738   P( 0x0df7, 0x0e57 ),
739   P( 0x0df8, 0x0e58 ),
740   P( 0x0df9, 0x0e59 ),
741   P( 0x0ea1, 0x3131 ),
742   P( 0x0ea2, 0x3132 ),
743   P( 0x0ea3, 0x3133 ),
744   P( 0x0ea4, 0x3134 ),
745   P( 0x0ea5, 0x3135 ),
746   P( 0x0ea6, 0x3136 ),
747   P( 0x0ea7, 0x3137 ),
748   P( 0x0ea8, 0x3138 ),
749   P( 0x0ea9, 0x3139 ),
750   P( 0x0eaa, 0x313a ),
751   P( 0x0eab, 0x313b ),
752   P( 0x0eac, 0x313c ),
753   P( 0x0ead, 0x313d ),
754   P( 0x0eae, 0x313e ),
755   P( 0x0eaf, 0x313f ),
756   P( 0x0eb0, 0x3140 ),
757   P( 0x0eb1, 0x3141 ),
758   P( 0x0eb2, 0x3142 ),
759   P( 0x0eb3, 0x3143 ),
760   P( 0x0eb4, 0x3144 ),
761   P( 0x0eb5, 0x3145 ),
762   P( 0x0eb6, 0x3146 ),
763   P( 0x0eb7, 0x3147 ),
764   P( 0x0eb8, 0x3148 ),
765   P( 0x0eb9, 0x3149 ),
766   P( 0x0eba, 0x314a ),
767   P( 0x0ebb, 0x314b ),
768   P( 0x0ebc, 0x314c ),
769   P( 0x0ebd, 0x314d ),
770   P( 0x0ebe, 0x314e ),
771   P( 0x0ebf, 0x314f ),
772   P( 0x0ec0, 0x3150 ),
773   P( 0x0ec1, 0x3151 ),
774   P( 0x0ec2, 0x3152 ),
775   P( 0x0ec3, 0x3153 ),
776   P( 0x0ec4, 0x3154 ),
777   P( 0x0ec5, 0x3155 ),
778   P( 0x0ec6, 0x3156 ),
779   P( 0x0ec7, 0x3157 ),
780   P( 0x0ec8, 0x3158 ),
781   P( 0x0ec9, 0x3159 ),
782   P( 0x0eca, 0x315a ),
783   P( 0x0ecb, 0x315b ),
784   P( 0x0ecc, 0x315c ),
785   P( 0x0ecd, 0x315d ),
786   P( 0x0ece, 0x315e ),
787   P( 0x0ecf, 0x315f ),
788   P( 0x0ed0, 0x3160 ),
789   P( 0x0ed1, 0x3161 ),
790   P( 0x0ed2, 0x3162 ),
791   P( 0x0ed3, 0x3163 ),
792   P( 0x0ed4, 0x11a8 ),
793   P( 0x0ed5, 0x11a9 ),
794   P( 0x0ed6, 0x11aa ),
795   P( 0x0ed7, 0x11ab ),
796   P( 0x0ed8, 0x11ac ),
797   P( 0x0ed9, 0x11ad ),
798   P( 0x0eda, 0x11ae ),
799   P( 0x0edb, 0x11af ),
800   P( 0x0edc, 0x11b0 ),
801   P( 0x0edd, 0x11b1 ),
802   P( 0x0ede, 0x11b2 ),
803   P( 0x0edf, 0x11b3 ),
804   P( 0x0ee0, 0x11b4 ),
805   P( 0x0ee1, 0x11b5 ),
806   P( 0x0ee2, 0x11b6 ),
807   P( 0x0ee3, 0x11b7 ),
808   P( 0x0ee4, 0x11b8 ),
809   P( 0x0ee5, 0x11b9 ),
810   P( 0x0ee6, 0x11ba ),
811   P( 0x0ee7, 0x11bb ),
812   P( 0x0ee8, 0x11bc ),
813   P( 0x0ee9, 0x11bd ),
814   P( 0x0eea, 0x11be ),
815   P( 0x0eeb, 0x11bf ),
816   P( 0x0eec, 0x11c0 ),
817   P( 0x0eed, 0x11c1 ),
818   P( 0x0eee, 0x11c2 ),
819   P( 0x0eef, 0x316d ),
820   P( 0x0ef0, 0x3171 ),
821   P( 0x0ef1, 0x3178 ),
822   P( 0x0ef2, 0x317f ),
823   P( 0x0ef3, 0x3181 ),
824   P( 0x0ef4, 0x3184 ),
825   P( 0x0ef5, 0x3186 ),
826   P( 0x0ef6, 0x318d ),
827   P( 0x0ef7, 0x318e ),
828   P( 0x0ef8, 0x11eb ),
829   P( 0x0ef9, 0x11f0 ),
830   P( 0x0efa, 0x11f9 ),
831   P( 0x0eff, 0x20a9 ),
832   P( 0x13a4, 0x20ac ),
833   P( 0x13bc, 0x0152 ),
834   P( 0x13bd, 0x0153 ),
835   P( 0x13be, 0x0178 ),
836   P( 0x20ac, 0x20ac ),
837   P( 0xfe50,    '`' ),
838   P( 0xfe51, 0x00b4 ),
839   P( 0xfe52,    '^' ),
840   P( 0xfe53,    '~' ),
841   P( 0xfe54, 0x00af ),
842   P( 0xfe55, 0x02d8 ),
843   P( 0xfe56, 0x02d9 ),
844   P( 0xfe57, 0x00a8 ),
845   P( 0xfe58, 0x02da ),
846   P( 0xfe59, 0x02dd ),
847   P( 0xfe5a, 0x02c7 ),
848   P( 0xfe5b, 0x00b8 ),
849   P( 0xfe5c, 0x02db ),
850   P( 0xfe5d, 0x037a ),
851   P( 0xfe5e, 0x309b ),
852   P( 0xfe5f, 0x309c ),
853   P( 0xfe63,    '/' ),
854   P( 0xfe64, 0x02bc ),
855   P( 0xfe65, 0x02bd ),
856   P( 0xfe66, 0x02f5 ),
857   P( 0xfe67, 0x02f3 ),
858   P( 0xfe68, 0x02cd ),
859   P( 0xfe69, 0xa788 ),
860   P( 0xfe6a, 0x02f7 ),
861   P( 0xfe6e,    ',' ),
862   P( 0xfe6f, 0x00a4 ),
863   P( 0xfe80,    'a' ), // XK_dead_a
864   P( 0xfe81,    'A' ), // XK_dead_A
865   P( 0xfe82,    'e' ), // XK_dead_e
866   P( 0xfe83,    'E' ), // XK_dead_E
867   P( 0xfe84,    'i' ), // XK_dead_i
868   P( 0xfe85,    'I' ), // XK_dead_I
869   P( 0xfe86,    'o' ), // XK_dead_o
870   P( 0xfe87,    'O' ), // XK_dead_O
871   P( 0xfe88,    'u' ), // XK_dead_u
872   P( 0xfe89,    'U' ), // XK_dead_U
873   P( 0xfe8a, 0x0259 ),
874   P( 0xfe8b, 0x018f ),
875   P( 0xfe8c, 0x00b5 ),
876   P( 0xfe90,    '_' ),
877   P( 0xfe91, 0x02c8 ),
878   P( 0xfe92, 0x02cc ),
879   P( 0xff80 /*XKB_KEY_KP_Space*/,     ' ' ),
880   P( 0xff95 /*XKB_KEY_KP_7*/, 0x0037 ),
881   P( 0xff96 /*XKB_KEY_KP_4*/, 0x0034 ),
882   P( 0xff97 /*XKB_KEY_KP_8*/, 0x0038 ),
883   P( 0xff98 /*XKB_KEY_KP_6*/, 0x0036 ),
884   P( 0xff99 /*XKB_KEY_KP_2*/, 0x0032 ),
885   P( 0xff9a /*XKB_KEY_KP_9*/, 0x0039 ),
886   P( 0xff9b /*XKB_KEY_KP_3*/, 0x0033 ),
887   P( 0xff9c /*XKB_KEY_KP_1*/, 0x0031 ),
888   P( 0xff9d /*XKB_KEY_KP_5*/, 0x0035 ),
889   P( 0xff9e /*XKB_KEY_KP_0*/, 0x0030 ),
890   P( 0xffaa /*XKB_KEY_KP_Multiply*/,  '*' ),
891   P( 0xffab /*XKB_KEY_KP_Add*/,       '+' ),
892   P( 0xffac /*XKB_KEY_KP_Separator*/, ',' ),
893   P( 0xffad /*XKB_KEY_KP_Subtract*/,  '-' ),
894   P( 0xffae /*XKB_KEY_KP_Decimal*/,   '.' ),
895   P( 0xffaf /*XKB_KEY_KP_Divide*/,    '/' ),
896   P( 0xffb0 /*XKB_KEY_KP_0*/, 0x0030 ),
897   P( 0xffb1 /*XKB_KEY_KP_1*/, 0x0031 ),
898   P( 0xffb2 /*XKB_KEY_KP_2*/, 0x0032 ),
899   P( 0xffb3 /*XKB_KEY_KP_3*/, 0x0033 ),
900   P( 0xffb4 /*XKB_KEY_KP_4*/, 0x0034 ),
901   P( 0xffb5 /*XKB_KEY_KP_5*/, 0x0035 ),
902   P( 0xffb6 /*XKB_KEY_KP_6*/, 0x0036 ),
903   P( 0xffb7 /*XKB_KEY_KP_7*/, 0x0037 ),
904   P( 0xffb8 /*XKB_KEY_KP_8*/, 0x0038 ),
905   P( 0xffb9 /*XKB_KEY_KP_9*/, 0x0039 ),
906   P( 0xffbd /*XKB_KEY_KP_Equal*/,     '=' )
907 ];
908 
909 
910 //////////////////////////////////////////////////////////////////////////
911 //////                       GLFW internal API                      //////
912 //////////////////////////////////////////////////////////////////////////
913 
914 // Convert XKB KeySym to Unicode
915 int _glfwKeySym2Unicode(uint keysym) {
916     int min = 0;
917     int max = keysymtab.length;
918     int mid;
919 
920     // First check for Latin-1 characters (1:1 mapping)
921     if ((keysym >= 0x0020 && keysym <= 0x007e) ||
922         (keysym >= 0x00a0 && keysym <= 0x00ff))
923     {
924         return keysym;
925     }
926 
927     // Also check for directly encoded 24-bit UCS characters
928     if ((keysym & 0xff000000) == 0x01000000)
929         return keysym & 0x00ffffff;
930 
931     // Binary search in table
932     while (max >= min)
933     {
934         mid = (min + max) / 2;
935         if (keysymtab[mid].keysym < keysym)
936             min = mid + 1;
937         else if (keysymtab[mid].keysym > keysym)
938             max = mid - 1;
939         else
940             return keysymtab[mid].ucs;
941     }
942 
943     // No matching Unicode value found
944     return -1;
945 }