This source file includes following definitions.
- kb_wait
- keyboard_interrupt
- put_queue
- puts_queue
- ctrl
- alt
- unctrl
- unalt
- lshift
- unlshift
- rshift
- unrshift
- caps
- uncaps
- show_ptregs
- scroll
- num
- applkey
- do_self
- handle_diacr
- cursor
- cur
- func
- slash
- star
- enter
- minus
- plus
- none
- send_data
- kbd_bh
- hard_reset_now
- kbd_init
1
2
3
4
5
6
7
8
9
10 #define KEYBOARD_IRQ 1
11
12 #include <linux/sched.h>
13 #include <linux/ctype.h>
14 #include <linux/tty.h>
15 #include <linux/mm.h>
16 #include <linux/ptrace.h>
17 #include <linux/keyboard.h>
18 #include <linux/interrupt.h>
19 #include <linux/config.h>
20
21 #ifndef KBD_DEFFLAGS
22 #ifdef CONFIG_KBD_META
23 #define KBD_DEFFLAGS ((1 << VC_NUMLOCK) | (1 << VC_REPEAT) | (1 << VC_META))
24 #else
25 #define KBD_DEFFLAGS ((1 << VC_NUMLOCK) | (1 << VC_REPEAT))
26 #endif
27 #endif
28
29
30
31
32
33
34
35 #define REALLY_SLOW_IO
36 #define SLOW_IO_BY_JUMPING
37 #include <asm/io.h>
38 #include <asm/system.h>
39
40 extern void do_keyboard_interrupt(void);
41 extern void ctrl_alt_del(void);
42 extern void change_console(unsigned int new_console);
43 extern void fake_keyboard_interrupt(void);
44
45 unsigned long kbd_flags = 0;
46 unsigned long kbd_dead_keys = 0;
47 unsigned long kbd_prev_dead_keys = 0;
48
49 static int want_console = -1;
50 struct kbd_struct kbd_table[NR_CONSOLES];
51 static struct kbd_struct * kbd = kbd_table;
52 static struct tty_struct * tty = NULL;
53
54 static volatile unsigned char acknowledge = 0;
55 static volatile unsigned char resend = 0;
56
57 typedef void (*fptr)(int);
58
59 static int diacr = -1;
60 static int npadch = 0;
61 fptr key_table[];
62
63 static void put_queue(int);
64 static void applkey(int);
65 static void cur(int);
66 static unsigned int handle_diacr(unsigned int);
67
68 static struct pt_regs * pt_regs;
69
70 static inline void kb_wait(void)
71 {
72 int i;
73
74 for (i=0; i<0x10000; i++)
75 if ((inb_p(0x64) & 0x02) == 0)
76 break;
77 }
78
79 static void keyboard_interrupt(int int_pt_regs)
80 {
81 static unsigned char rep = 0xff;
82 unsigned char scancode;
83
84 pt_regs = (struct pt_regs *) int_pt_regs;
85 kbd_prev_dead_keys |= kbd_dead_keys;
86 if (!kbd_dead_keys)
87 kbd_prev_dead_keys = 0;
88 kbd_dead_keys = 0;
89 kb_wait();
90 if (!(inb_p(0x64) & 0x01))
91 goto end_kbd_intr;
92 scancode = inb(0x60);
93 mark_bh(KEYBOARD_BH);
94 if (scancode == 0xfa) {
95 acknowledge = 1;
96 goto end_kbd_intr;
97 } else if (scancode == 0xfe) {
98 resend = 1;
99 goto end_kbd_intr;
100 }
101 tty = TTY_TABLE(0);
102 kbd = kbd_table + fg_console;
103 if (vc_kbd_flag(kbd,VC_RAW)) {
104 kbd_flags = 0;
105 put_queue(scancode);
106 goto end_kbd_intr;
107 }
108 if (scancode == 0xe0) {
109 set_kbd_dead(KGD_E0);
110 goto end_kbd_intr;
111 } else if (scancode == 0xe1) {
112 set_kbd_dead(KGD_E1);
113 goto end_kbd_intr;
114 }
115
116
117
118
119
120
121
122 if (kbd_dead(KGD_E0) && (scancode == 0x2a || scancode == 0xaa))
123 goto end_kbd_intr;
124
125
126
127
128
129 if ((scancode != rep) ||
130 (vc_kbd_flag(kbd,VC_REPEAT) && tty &&
131 (L_ECHO(tty) || (EMPTY(&tty->secondary) && EMPTY(&tty->read_q)))))
132 key_table[scancode](scancode);
133 rep = scancode;
134 end_kbd_intr:
135 }
136
137 static void put_queue(int ch)
138 {
139 struct tty_queue *qp;
140 unsigned long new_head;
141
142 wake_up(&keypress_wait);
143 if (!tty)
144 return;
145 qp = &tty->read_q;
146
147 qp->buf[qp->head]=ch;
148 if ((new_head=(qp->head+1)&(TTY_BUF_SIZE-1)) != qp->tail)
149 qp->head=new_head;
150 wake_up_interruptible(&qp->proc_list);
151 }
152
153 static void puts_queue(char *cp)
154 {
155 struct tty_queue *qp;
156 unsigned long new_head;
157 char ch;
158
159 wake_up_interruptible(&keypress_wait);
160 if (!tty)
161 return;
162 qp = &tty->read_q;
163
164 while ((ch = *(cp++)) != 0) {
165 qp->buf[qp->head]=ch;
166 if ((new_head=(qp->head+1)&(TTY_BUF_SIZE-1))
167 != qp->tail)
168 qp->head=new_head;
169 }
170 wake_up_interruptible(&qp->proc_list);
171 }
172
173 static void ctrl(int sc)
174 {
175 if (kbd_dead(KGD_E0))
176 set_kbd_flag(KG_RCTRL);
177 else
178 set_kbd_flag(KG_LCTRL);
179 }
180
181 static void alt(int sc)
182 {
183 if (kbd_dead(KGD_E0))
184 set_kbd_flag(KG_ALTGR);
185 else
186 set_kbd_flag(KG_ALT);
187 }
188
189 static void unctrl(int sc)
190 {
191 if (kbd_dead(KGD_E0))
192 clr_kbd_flag(KG_RCTRL);
193 else
194 clr_kbd_flag(KG_LCTRL);
195 }
196
197 static void unalt(int sc)
198 {
199 if (kbd_dead(KGD_E0))
200 clr_kbd_flag(KG_ALTGR);
201 else {
202 clr_kbd_flag(KG_ALT);
203 if (npadch != 0) {
204 put_queue(npadch);
205 npadch=0;
206 }
207 }
208 }
209
210 static void lshift(int sc)
211 {
212 set_kbd_flag(KG_LSHIFT);
213 }
214
215 static void unlshift(int sc)
216 {
217 clr_kbd_flag(KG_LSHIFT);
218 }
219
220 static void rshift(int sc)
221 {
222 set_kbd_flag(KG_RSHIFT);
223 }
224
225 static void unrshift(int sc)
226 {
227 clr_kbd_flag(KG_RSHIFT);
228 }
229
230 static void caps(int sc)
231 {
232 if (kbd_flag(KG_CAPSLOCK))
233 return;
234 set_kbd_flag(KG_CAPSLOCK);
235 chg_vc_kbd_flag(kbd,VC_CAPSLOCK);
236 }
237
238 static void uncaps(int sc)
239 {
240 clr_kbd_flag(KG_CAPSLOCK);
241 }
242
243 static void show_ptregs(void)
244 {
245 if (!pt_regs)
246 return;
247 printk("\nEIP: %04x:%08x",0xffff & pt_regs->cs,pt_regs->eip);
248 if (pt_regs->cs & 3)
249 printk(" ESP: %04x:%08x",0xffff & pt_regs->cs,pt_regs->eip);
250 printk(" EFLAGS: %08x",pt_regs->eflags);
251 printk("\nEAX: %08x EBX: %08x ECX: %08x EDX: %08x",
252 pt_regs->orig_eax,pt_regs->ebx,pt_regs->ecx,pt_regs->edx);
253 printk("\nESI: %08x EDI: %08x EBP: %08x",
254 pt_regs->esi, pt_regs->edi, pt_regs->ebp);
255 printk(" DS: %04x ES: %04x FS: %04x GS: %04x\n",
256 0xffff & pt_regs->ds,0xffff & pt_regs->es,
257 0xffff & pt_regs->fs,0xffff & pt_regs->gs);
258 }
259
260 static void scroll(int sc)
261 {
262 if (kbd_flag(KG_LSHIFT) || kbd_flag(KG_RSHIFT))
263 show_mem();
264 else if (kbd_flag(KG_ALT) || kbd_flag(KG_ALTGR))
265 show_ptregs();
266 else if (kbd_flag(KG_LCTRL) || kbd_flag(KG_RCTRL))
267 show_state();
268 else
269 chg_vc_kbd_flag(kbd,VC_SCROLLOCK);
270 }
271
272 static void num(int sc)
273 {
274 if (vc_kbd_flag(kbd,VC_APPLIC))
275 applkey(0x50);
276 else
277 chg_vc_kbd_flag(kbd,VC_NUMLOCK);
278 }
279
280 static void applkey(int key)
281 {
282 char buf[] = { 0x1b, 0x4f, 0x00, 0x00 };
283
284 buf[2] = key;
285 puts_queue(buf);
286 }
287
288 #if defined KBD_FINNISH
289
290 static unsigned char key_map[] = {
291 0, 27, '1', '2', '3', '4', '5', '6',
292 '7', '8', '9', '0', '+', '\'', 127, 9,
293 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
294 'o', 'p', '}', 0, 13, 0, 'a', 's',
295 'd', 'f', 'g', 'h', 'j', 'k', 'l', '|',
296 '{', 0, 0, '\'', 'z', 'x', 'c', 'v',
297 'b', 'n', 'm', ',', '.', '-', 0, '*',
298 0, 32, 0, 0, 0, 0, 0, 0,
299 0, 0, 0, 0, 0, 0, 0, 0,
300 0, 0, '-', 0, 0, 0, '+', 0,
301 0, 0, 0, 0, 0, 0, '<', 0,
302 0, 0, 0, 0, 0, 0, 0, 0,
303 0 };
304
305 static unsigned char shift_map[] = {
306 0, 27, '!', '\"', '#', '$', '%', '&',
307 '/', '(', ')', '=', '?', '`', 127, 9,
308 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
309 'O', 'P', ']', '^', 13, 0, 'A', 'S',
310 'D', 'F', 'G', 'H', 'J', 'K', 'L', '\\',
311 '[', 0, 0, '*', 'Z', 'X', 'C', 'V',
312 'B', 'N', 'M', ';', ':', '_', 0, '*',
313 0, 32, 0, 0, 0, 0, 0, 0,
314 0, 0, 0, 0, 0, 0, 0, 0,
315 0, 0, '-', 0, 0, 0, '+', 0,
316 0, 0, 0, 0, 0, 0, '>', 0,
317 0, 0, 0, 0, 0, 0, 0, 0,
318 0 };
319
320 static unsigned char alt_map[] = {
321 0, 0, 0, '@', 163, '$', 0, 0,
322 '{', '[', ']', '}', '\\', 0, 0, 0,
323 0, 0, 0, 0, 0, 0, 0, 0,
324 0, 0, 0, '~', 13, 0, 0, 0,
325 0, 0, 0, 0, 0, 0, 0, 0,
326 0, 0, 0, 0, 0, 0, 0, 0,
327 0, 0, 0, 0, 0, 0, 0, 0,
328 0, 0, 0, 0, 0, 0, 0, 0,
329 0, 0, 0, 0, 0, 0, 0, 0,
330 0, 0, 0, 0, 0, 0, 0, 0,
331 0, 0, 0, 0, 0, 0, '|', 0,
332 0, 0, 0, 0, 0, 0, 0, 0,
333 0 };
334
335 #elif defined KBD_FINNISH_LATIN1
336
337 static unsigned char key_map[] = {
338 0, 27, '1', '2', '3', '4', '5', '6',
339 '7', '8', '9', '0', '+', 180, 127, 9,
340 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
341 'o', 'p', 229, 168, 13, 0, 'a', 's',
342 'd', 'f', 'g', 'h', 'j', 'k', 'l', 246,
343 228, 167, 0, '\'', 'z', 'x', 'c', 'v',
344 'b', 'n', 'm', ',', '.', '-', 0, '*',
345 0, 32, 0, 0, 0, 0, 0, 0,
346 0, 0, 0, 0, 0, 0, 0, 0,
347 0, 0, '-', 0, 0, 0, '+', 0,
348 0, 0, 0, 0, 0, 0, '<', 0,
349 0, 0, 0, 0, 0, 0, 0, 0,
350 0 };
351
352 static unsigned char shift_map[] = {
353 0, 27, '!', '"', '#', '$', '%', '&',
354 '/', '(', ')', '=', '?', '`', 127, 9,
355 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
356 'O', 'P', 197, '^', 13, 0, 'A', 'S',
357 'D', 'F', 'G', 'H', 'J', 'K', 'L', 214,
358 196, 189, 0, '*', 'Z', 'X', 'C', 'V',
359 'B', 'N', 'M', ';', ':', '_', 0, '*',
360 0, 32, 0, 0, 0, 0, 0, 0,
361 0, 0, 0, 0, 0, 0, 0, 0,
362 0, 0, '-', 0, 0, 0, '+', 0,
363 0, 0, 0, 0, 0, 0, '>', 0,
364 0, 0, 0, 0, 0, 0, 0, 0,
365 0 };
366
367 static unsigned char alt_map[] = {
368 0, 0, 0, '@', 163, '$', 0, 0,
369 '{', '[', ']', '}', '\\', 0, 0, 0,
370 0, 0, 0, 0, 0, 0, 0, 0,
371 0, 0, 0, '~', 13, 0, 0, 0,
372 0, 0, 0, 0, 0, 0, 0, 0,
373 0, 0, 0, 0, 0, 0, 0, 0,
374 0, 0, 0, 0, 0, 0, 0, 0,
375 0, 0, 0, 0, 0, 0, 0, 0,
376 0, 0, 0, 0, 0, 0, 0, 0,
377 0, 0, 0, 0, 0, 0, 0, 0,
378 0, 0, 0, 0, 0, 0, '|', 0,
379 0, 0, 0, 0, 0, 0, 0, 0,
380 0 };
381
382 #elif defined KBD_US
383
384 static unsigned char key_map[] = {
385 0, 27, '1', '2', '3', '4', '5', '6',
386 '7', '8', '9', '0', '-', '=', 127, 9,
387 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
388 'o', 'p', '[', ']', 13, 0, 'a', 's',
389 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
390 '\'', '`', 0, '\\', 'z', 'x', 'c', 'v',
391 'b', 'n', 'm', ',', '.', '/', 0, '*',
392 0, 32, 0, 0, 0, 0, 0, 0,
393 0, 0, 0, 0, 0, 0, 0, 0,
394 0, 0, '-', 0, 0, 0, '+', 0,
395 0, 0, 0, 0, 0, 0, '<', 0,
396 0, 0, 0, 0, 0, 0, 0, 0,
397 0 };
398
399 static unsigned char shift_map[] = {
400 0, 27, '!', '@', '#', '$', '%', '^',
401 '&', '*', '(', ')', '_', '+', 127, 9,
402 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
403 'O', 'P', '{', '}', 13, 0, 'A', 'S',
404 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':',
405 '"', '~', '0', '|', 'Z', 'X', 'C', 'V',
406 'B', 'N', 'M', '<', '>', '?', 0, '*',
407 0, 32, 0, 0, 0, 0, 0, 0,
408 0, 0, 0, 0, 0, 0, 0, 0,
409 0, 0, '-', 0, 0, 0, '+', 0,
410 0, 0, 0, 0, 0, 0, '>', 0,
411 0, 0, 0, 0, 0, 0, 0, 0,
412 0 };
413
414 static unsigned char alt_map[] = {
415 0, 0, 0, '@', 0, '$', 0, 0,
416 '{', '[', ']', '}', '\\', 0, 0, 0,
417 0, 0, 0, 0, 0, 0, 0, 0,
418 0, 0, 0, '~', 13, 0, 0, 0,
419 0, 0, 0, 0, 0, 0, 0, 0,
420 0, 0, 0, 0, 0, 0, 0, 0,
421 0, 0, 0, 0, 0, 0, 0, 0,
422 0, 0, 0, 0, 0, 0, 0, 0,
423 0, 0, 0, 0, 0, 0, 0, 0,
424 0, 0, 0, 0, 0, 0, 0, 0,
425 0, 0, 0, 0, 0, 0, '|', 0,
426 0, 0, 0, 0, 0, 0, 0, 0,
427 0 };
428
429 #elif defined KBD_UK
430
431 static unsigned char key_map[] = {
432 0, 27, '1', '2', '3', '4', '5', '6',
433 '7', '8', '9', '0', '-', '=', 127, 9,
434 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
435 'o', 'p', '[', ']', 13, 0, 'a', 's',
436 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
437 '\'', '`', 0, '#', 'z', 'x', 'c', 'v',
438 'b', 'n', 'm', ',', '.', '/', 0, '*',
439 0, 32, 0, 0, 0, 0, 0, 0,
440 0, 0, 0, 0, 0, 0, 0, 0,
441 0, 0, '-', 0, 0, 0, '+', 0,
442 0, 0, 0, 0, 0, 0, '\\', 0,
443 0, 0, 0, 0, 0, 0, 0, 0,
444 0 };
445
446 static unsigned char shift_map[] = {
447 0, 27, '!', '"', 163, '$', '%', '^',
448 '&', '*', '(', ')', '_', '+', 127, 9,
449 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
450 'O', 'P', '{', '}', 13, 0, 'A', 'S',
451 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':',
452 '@', '~', '0', '~', 'Z', 'X', 'C', 'V',
453 'B', 'N', 'M', '<', '>', '?', 0, '*',
454 0, 32, 0, 0, 0, 0, 0, 0,
455 0, 0, 0, 0, 0, 0, 0, 0,
456 0, 0, '-', 0, 0, 0, '+', 0,
457 0, 0, 0, 0, 0, 0, '|', 0,
458 0, 0, 0, 0, 0, 0, 0, 0,
459 0 };
460
461 static unsigned char alt_map[] = {
462 0, 0, 0, '@', 0, '$', 0, 0,
463 '{', '[', ']', '}', '\\', 0, 0, 0,
464 0, 0, 0, 0, 0, 0, 0, 0,
465 0, 0, 0, '~', 13, 0, 0, 0,
466 0, 0, 0, 0, 0, 0, 0, 0,
467 0, 0, 0, 0, 0, 0, 0, 0,
468 0, 0, 0, 0, 0, 0, 0, 0,
469 0, 0, 0, 0, 0, 0, 0, 0,
470 0, 0, 0, 0, 0, 0, 0, 0,
471 0, 0, 0, 0, 0, 0, 0, 0,
472 0, 0, 0, 0, 0, 0, '|', 0,
473 0, 0, 0, 0, 0, 0, 0, 0,
474 0 };
475
476 #elif defined KBD_GR
477
478 static unsigned char key_map[] = {
479 0, 27, '1', '2', '3', '4', '5', '6',
480 '7', '8', '9', '0', '\\', '\'', 127, 9,
481 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i',
482 'o', 'p', '@', '+', 13, 0, 'a', 's',
483 'd', 'f', 'g', 'h', 'j', 'k', 'l', '[',
484 ']', '^', 0, '#', 'y', 'x', 'c', 'v',
485 'b', 'n', 'm', ',', '.', '-', 0, '*',
486 0, 32, 0, 0, 0, 0, 0, 0,
487 0, 0, 0, 0, 0, 0, 0, 0,
488 0, 0, '-', 0, 0, 0, '+', 0,
489 0, 0, 0, 0, 0, 0, '<', 0,
490 0, 0, 0, 0, 0, 0, 0, 0,
491 0 };
492
493 static unsigned char shift_map[] = {
494 0, 27, '!', '"', '#', '$', '%', '&',
495 '/', '(', ')', '=', '?', '`', 127, 9,
496 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I',
497 'O', 'P', '\\', '*', 13, 0, 'A', 'S',
498 'D', 'F', 'G', 'H', 'J', 'K', 'L', '{',
499 '}', '~', 0, '\'', 'Y', 'X', 'C', 'V',
500 'B', 'N', 'M', ';', ':', '_', 0, '*',
501 0, 32, 0, 0, 0, 0, 0, 0,
502 0, 0, 0, 0, 0, 0, 0, 0,
503 0, 0, '-', 0, 0, 0, '+', 0,
504 0, 0, 0, 0, 0, 0, '>', 0,
505 0, 0, 0, 0, 0, 0, 0, 0,
506 0 };
507
508 static unsigned char alt_map[] = {
509 0, 0, 0, '@', 0, '$', 0, 0,
510 '{', '[', ']', '}', '\\', 0, 0, 0,
511 '@', 0, 0, 0, 0, 0, 0, 0,
512 0, 0, 0, '~', 13, 0, 0, 0,
513 0, 0, 0, 0, 0, 0, 0, 0,
514 0, 0, 0, 0, 0, 0, 0, 0,
515 0, 0, 0, 0, 0, 0, 0, 0,
516 0, 0, 0, 0, 0, 0, 0, 0,
517 0, 0, 0, 0, 0, 0, 0, 0,
518 0, 0, 0, 0, 0, 0, 0, 0,
519 0, 0, 0, 0, 0, 0, '|', 0,
520 0, 0, 0, 0, 0, 0, 0, 0,
521 0 };
522
523 #elif defined KBD_GR_LATIN1
524
525 static unsigned char key_map[] = {
526 0, 27, '1', '2', '3', '4', '5', '6',
527 '7', '8', '9', '0', 223, 180, 127, 9,
528 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i',
529 'o', 'p', 252, '+', 13, 0, 'a', 's',
530 'd', 'f', 'g', 'h', 'j', 'k', 'l', 246,
531 228, 94, 0, '#', 'y', 'x', 'c', 'v',
532 'b', 'n', 'm', ',', '.', '-', 0, '*',
533 0, 32, 0, 0, 0, 0, 0, 0,
534 0, 0, 0, 0, 0, 0, 0, 0,
535 0, 0, '-', 0, 0, 0, '+', 0,
536 0, 0, 0, 0, 0, 0, '<', 0,
537 0, 0, 0, 0, 0, 0, 0, 0,
538 0 };
539
540 static unsigned char shift_map[] = {
541 0, 27, '!', '"', 167, '$', '%', '&',
542 '/', '(', ')', '=', '?', '`', 127, 9,
543 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I',
544 'O', 'P', 220, '*', 13, 0, 'A', 'S',
545 'D', 'F', 'G', 'H', 'J', 'K', 'L', 214,
546 196, 176, 0, '\'', 'Y', 'X', 'C', 'V',
547 'B', 'N', 'M', ';', ':', '_', 0, '*',
548 0, 32, 0, 0, 0, 0, 0, 0,
549 0, 0, 0, 0, 0, 0, 0, 0,
550 0, 0, '-', 0, 0, 0, '+', 0,
551 0, 0, 0, 0, 0, 0, '>', 0,
552 0, 0, 0, 0, 0, 0, 0, 0,
553 0 };
554
555 static unsigned char alt_map[] = {
556 0, 0, 0, 178, 179, '$', 0, 0,
557 '{', '[', ']', '}', '\\', 0, 0, 0,
558 '@', 0, 0, 0, 0, 0, 0, 0,
559 0, 0, 0, '~', 13, 0, 0, 0,
560 0, 0, 0, 0, 0, 0, 0, 0,
561 0, 0, 0, 0, 0, 0, 0, 0,
562 0, 0, 181, 0, 0, 0, 0, 0,
563 0, 0, 0, 0, 0, 0, 0, 0,
564 0, 0, 0, 0, 0, 0, 0, 0,
565 0, 0, 0, 0, 0, 0, 0, 0,
566 0, 0, 0, 0, 0, 0, '|', 0,
567 0, 0, 0, 0, 0, 0, 0, 0,
568 0 };
569
570 #elif defined KBD_FR
571
572 static unsigned char key_map[] = {
573 0, 27, '&', '{', '"', '\'', '(', '-',
574 '}', '_', '/', '@', ')', '=', 127, 9,
575 'a', 'z', 'e', 'r', 't', 'y', 'u', 'i',
576 'o', 'p', '^', '$', 13, 0, 'q', 's',
577 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm',
578 '|', '`', 0, 42, 'w', 'x', 'c', 'v',
579 'b', 'n', ',', ';', ':', '!', 0, '*',
580 0, 32, 0, 0, 0, 0, 0, 0,
581 0, 0, 0, 0, 0, 0, 0, 0,
582 0, 0, '-', 0, 0, 0, '+', 0,
583 0, 0, 0, 0, 0, 0, '<', 0,
584 0, 0, 0, 0, 0, 0, 0, 0,
585 0 };
586
587 static unsigned char shift_map[] = {
588 0, 27, '1', '2', '3', '4', '5', '6',
589 '7', '8', '9', '0', ']', '+', 127, 9,
590 'A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I',
591 'O', 'P', '<', '>', 13, 0, 'Q', 'S',
592 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M',
593 '%', '~', 0, '#', 'W', 'X', 'C', 'V',
594 'B', 'N', '?', '.', '/', '\\', 0, '*',
595 0, 32, 0, 0, 0, 0, 0, 0,
596 0, 0, 0, 0, 0, 0, 0, 0,
597 0, 0, '-', 0, 0, 0, '+', 0,
598 0, 0, 0, 0, 0, 0, '>', 0,
599 0, 0, 0, 0, 0, 0, 0, 0,
600 0 };
601
602 static unsigned char alt_map[] = {
603 0, 0, 0, '~', '#', '{', '[', '|',
604 '`', '\\', '^', '@', ']', '}', 0, 0,
605 '@', 0, 0, 0, 0, 0, 0, 0,
606 0, 0, 0, '~', 13, 0, 0, 0,
607 0, 0, 0, 0, 0, 0, 0, 0,
608 0, 0, 0, 0, 0, 0, 0, 0,
609 0, 0, 0, 0, 0, 0, 0, 0,
610 0, 0, 0, 0, 0, 0, 0, 0,
611 0, 0, 0, 0, 0, 0, 0, 0,
612 0, 0, 0, 0, 0, 0, 0, 0,
613 0, 0, 0, 0, 0, 0, '|', 0,
614 0, 0, 0, 0, 0, 0, 0, 0,
615 0 };
616
617 #elif defined KBD_FR_LATIN1
618
619 static unsigned char key_map[] = {
620 0, 27, '&', 233, '"', '\'', '(', '-',
621 232, '_', 231, 224, ')', '=', 127, 9,
622 'a', 'z', 'e', 'r', 't', 'y', 'u', 'i',
623 'o', 'p', '^', '$', 13, 0, 'q', 's',
624 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm',
625 249, 178, 0, 42, 'w', 'x', 'c', 'v',
626 'b', 'n', ',', ';', ':', '!', 0, '*',
627 0, 32, 0, 0, 0, 0, 0, 0,
628 0, 0, 0, 0, 0, 0, 0, 0,
629 0, 0, '-', 0, 0, 0, '+', 0,
630 0, 0, 0, 0, 0, 0, '<', 0,
631 0, 0, 0, 0, 0, 0, 0, 0,
632 0 };
633
634 static unsigned char shift_map[] = {
635 0, 27, '1', '2', '3', '4', '5', '6',
636 '7', '8', '9', '0', 176, '+', 127, 9,
637 'A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I',
638 'O', 'P', 168, 163, 13, 0, 'Q', 'S',
639 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M',
640 '%', 0, 0, 181, 'W', 'X', 'C', 'V',
641 'B', 'N', '?', '.', '/', 167, 0, '*',
642 0, 32, 0, 0, 0, 0, 0, 0,
643 0, 0, 0, 0, 0, 0, 0, 0,
644 0, 0, '-', 0, 0, 0, '+', 0,
645 0, 0, 0, 0, 0, 0, '>', 0,
646 0, 0, 0, 0, 0, 0, 0, 0,
647 0 };
648
649 static unsigned char alt_map[] = {
650 0, 0, 0, '~', '#', '{', '[', '|',
651 '`', '\\', '^', '@', ']', '}', 0, 0,
652 '@', 0, 0, 0, 0, 0, 0, 0,
653 0, 0, 0, 164, 13, 0, 0, 0,
654 0, 0, 0, 0, 0, 0, 0, 0,
655 0, 0, 0, 0, 0, 0, 0, 0,
656 0, 0, 0, 0, 0, 0, 0, 0,
657 0, 0, 0, 0, 0, 0, 0, 0,
658 0, 0, 0, 0, 0, 0, 0, 0,
659 0, 0, 0, 0, 0, 0, 0, 0,
660 0, 0, 0, 0, 0, 0, '|', 0,
661 0, 0, 0, 0, 0, 0, 0, 0,
662 0 };
663
664 #elif defined KBD_DK
665
666 static unsigned char key_map[] = {
667 0, 27, '1', '2', '3', '4', '5', '6',
668 '7', '8', '9', '0', '+', '\'', 127, 9,
669 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
670 'o', 'p', 229, 0, 13, 0, 'a', 's',
671 'd', 'f', 'g', 'h', 'j', 'k', 'l', 230,
672 162, 0, 0, '\'', 'z', 'x', 'c', 'v',
673 'b', 'n', 'm', ',', '.', '-', 0, '*',
674 0, 32, 0, 0, 0, 0, 0, 0,
675 0, 0, 0, 0, 0, 0, 0, 0,
676 0, 0, '-', 0, 0, 0, '+', 0,
677 0, 0, 0, 0, 0, 0, '<', 0,
678 0, 0, 0, 0, 0, 0, 0, 0,
679 0 };
680
681 static unsigned char shift_map[] = {
682 0, 27, '!', '\"', '#', '$', '%', '&',
683 '/', '(', ')', '=', '?', '`', 127, 9,
684 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
685 'O', 'P', 197, '^', 13, 0, 'A', 'S',
686 'D', 'F', 'G', 'H', 'J', 'K', 'L', 198,
687 165, 0, 0, '*', 'Z', 'X', 'C', 'V',
688 'B', 'N', 'M', ';', ':', '_', 0, '*',
689 0, 32, 0, 0, 0, 0, 0, 0,
690 0, 0, 0, 0, 0, 0, 0, 0,
691 0, 0, '-', 0, 0, 0, '+', 0,
692 0, 0, 0, 0, 0, 0, '>', 0,
693 0, 0, 0, 0, 0, 0, 0, 0,
694 0 };
695
696 static unsigned char alt_map[] = {
697 0, 0, 0, '@', 163, '$', 0, 0,
698 '{', '[', ']', '}', 0, '|', 0, 0,
699 0, 0, 0, 0, 0, 0, 0, 0,
700 0, 0, 0, '~', 13, 0, 0, 0,
701 0, 0, 0, 0, 0, 0, 0, 0,
702 0, 0, 0, 0, 0, 0, 0, 0,
703 0, 0, 0, 0, 0, 0, 0, 0,
704 0, 0, 0, 0, 0, 0, 0, 0,
705 0, 0, 0, 0, 0, 0, 0, 0,
706 0, 0, 0, 0, 0, 0, 0, 0,
707 0, 0, 0, 0, 0, 0, '\\', 0,
708 0, 0, 0, 0, 0, 0, 0, 0,
709 0 };
710
711 #elif defined KBD_DK_LATIN1
712
713 static unsigned char key_map[] = {
714 0, 27, '1', '2', '3', '4', '5', '6',
715 '7', '8', '9', '0', '+', 180, 127, 9,
716 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
717 'o', 'p', 229, 168, 13, 0, 'a', 's',
718 'd', 'f', 'g', 'h', 'j', 'k', 'l', 230,
719 162, 189, 0, '\'', 'z', 'x', 'c', 'v',
720 'b', 'n', 'm', ',', '.', '-', 0, '*',
721 0, 32, 0, 0, 0, 0, 0, 0,
722 0, 0, 0, 0, 0, 0, 0, 0,
723 0, 0, '-', 0, 0, 0, '+', 0,
724 0, 0, 0, 0, 0, 0, '<', 0,
725 0, 0, 0, 0, 0, 0, 0, 0,
726 0 };
727
728 static unsigned char shift_map[] = {
729 0, 27, '!', '\"', '#', '$', '%', '&',
730 '/', '(', ')', '=', '?', '`', 127, 9,
731 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
732 'O', 'P', 197, '^', 13, 0, 'A', 'S',
733 'D', 'F', 'G', 'H', 'J', 'K', 'L', 198,
734 165, 167, 0, '*', 'Z', 'X', 'C', 'V',
735 'B', 'N', 'M', ';', ':', '_', 0, '*',
736 0, 32, 0, 0, 0, 0, 0, 0,
737 0, 0, 0, 0, 0, 0, 0, 0,
738 0, 0, '-', 0, 0, 0, '+', 0,
739 0, 0, 0, 0, 0, 0, '>', 0,
740 0, 0, 0, 0, 0, 0, 0, 0,
741 0 };
742
743 static unsigned char alt_map[] = {
744 0, 0, 0, '@', 163, '$', 0, 0,
745 '{', '[', ']', '}', 0, '|', 0, 0,
746 0, 0, 0, 0, 0, 0, 0, 0,
747 0, 0, 0, '~', 13, 0, 0, 0,
748 0, 0, 0, 0, 0, 0, 0, 0,
749 0, 0, 0, 0, 0, 0, 0, 0,
750 0, 0, 0, 0, 0, 0, 0, 0,
751 0, 0, 0, 0, 0, 0, 0, 0,
752 0, 0, 0, 0, 0, 0, 0, 0,
753 0, 0, 0, 0, 0, 0, 0, 0,
754 0, 0, 0, 0, 0, 0, '\\', 0,
755 0, 0, 0, 0, 0, 0, 0, 0,
756 0 };
757
758 #elif defined KBD_DVORAK
759
760 static unsigned char key_map[] = {
761 0, 27, '1', '2', '3', '4', '5', '6',
762 '7', '8', '9', '0', '\\', '=', 127, 9,
763 '\'', ',', '.', 'p', 'y', 'f', 'g', 'c',
764 'r', 'l', '/', ']', 13, 0, 'a', 'o',
765 'e', 'u', 'i', 'd', 'h', 't', 'n', 's',
766 '-', '`', 0, '[', ';', 'q', 'j', 'k',
767 'x', 'b', 'm', 'w', 'v', 'z', 0, '*',
768 0, 32, 0, 0, 0, 0, 0, 0,
769 0, 0, 0, 0, 0, 0, 0, 0,
770 0, 0, '-', 0, 0, 0, '+', 0,
771 0, 0, 0, 0, 0, 0, '<', 0,
772 0, 0, 0, 0, 0, 0, 0, 0,
773 0 };
774
775 static unsigned char shift_map[] = {
776 0, 27, '!', '@', '#', '$', '%', '^',
777 '&', '*', '(', ')', '|', '+', 127, 9,
778 '"', '<', '>', 'P', 'Y', 'F', 'G', 'C',
779 'R', 'L', '?', '}', 13, 0, 'A', 'O',
780 'E', 'U', 'I', 'D', 'H', 'T', 'N', 'S',
781 '_', '~', 0, '{', ':', 'Q', 'J', 'K',
782 'X', 'B', 'M', 'W', 'V', 'Z', 0, '*',
783 0, 32, 0, 0, 0, 0, 0, 0,
784 0, 0, 0, 0, 0, 0, 0, 0,
785 0, 0, '-', 0, 0, 0, '+', 0,
786 0, 0, 0, 0, 0, 0, '<', 0,
787 0, 0, 0, 0, 0, 0, 0, 0,
788 0 };
789
790 static unsigned char alt_map[] = {
791 0, 0, 0, '@', 0, '$', 0, 0,
792 '{', '[', ']', '}', '\\', 0, 0, 0,
793 0, 0, 0, 0, 0, 0, 0, 0,
794 0, 0, 0, '~', 13, 0, 0, 0,
795 0, 0, 0, 0, 0, 0, 0, 0,
796 0, 0, 0, 0, 0, 0, 0, 0,
797 0, 0, 0, 0, 0, 0, 0, 0,
798 0, 0, 0, 0, 0, 0, 0, 0,
799 0, 0, 0, 0, 0, 0, 0, 0,
800 0, 0, 0, 0, 0, 0, 0, 0,
801 0, 0, 0, 0, 0, 0, '|', 0,
802 0, 0, 0, 0, 0, 0, 0, 0,
803 0 };
804
805 #elif defined KBD_SG
806
807 static unsigned char key_map[] = {
808 0, 27, '1', '2', '3', '4', '5', '6',
809 '7', '8', '9', '0', '\'', '^', 127, 9,
810 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i',
811 'o', 'p', 0, 0, 13, 0, 'a', 's',
812 'd', 'f', 'g', 'h', 'j', 'k', 'l', 0,
813 0, 0, 0, '$', 'y', 'x', 'c', 'v',
814 'b', 'n', 'm', ',', '.', '-', 0, '*',
815 0, 32, 0, 0, 0, 0, 0, 0,
816 0, 0, 0, 0, 0, 0, 0, 0,
817 0, 0, '-', 0, 0, 0, '+', 0,
818 0, 0, 0, 0, 0, 0, '<', 0,
819 0, 0, 0, 0, 0, 0, 0, 0,
820 0 };
821
822 static unsigned char shift_map[] = {
823 0, 27, '+', '"', '*', 0, '%', '&',
824 '/', '(', ')', '=', '?', '`', 127, 9,
825 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I',
826 'O', 'P', 0, '!', 13, 0, 'A', 'S',
827 'D', 'F', 'G', 'H', 'J', 'K', 'L', 0,
828 0, 0, 0, 0, 'Y', 'X', 'C', 'V',
829 'B', 'N', 'M', ';', ':', '_', 0, '*',
830 0, 32, 0, 0, 0, 0, 0, 0,
831 0, 0, 0, 0, 0, 0, 0, 0,
832 0, 0, '-', 0, 0, 0, '+', 0,
833 0, 0, 0, 0, 0, 0, '>', 0,
834 0, 0, 0, 0, 0, 0, 0, 0,
835 0 };
836
837 static unsigned char alt_map[] = {
838 0, 0, 0, '@', '#', 0, 0, 0,
839 '|', 0, 0, 0, '\'', '~', 0, 0,
840 '@', 0, 0, 0, 0, 0, 0, 0,
841 0, 0, '[', ']', 13, 0, 0, 0,
842 0, 0, 0, 0, 0, 0, 0, 0,
843 '{', 0, 0, '}', 0, 0, 0, 0,
844 0, 0, 0, 0, 0, 0, 0, 0,
845 0, 0, 0, 0, 0, 0, 0, 0,
846 0, 0, 0, 0, 0, 0, 0, 0,
847 0, 0, 0, 0, 0, 0, 0, 0,
848 0, 0, 0, 0, 0, 0, '\\', 0,
849 0, 0, 0, 0, 0, 0, 0, 0,
850 0 };
851
852 #elif defined KBD_SG_LATIN1
853
854 static unsigned char key_map[] = {
855 0, 27, '1', '2', '3', '4', '5', '6',
856 '7', '8', '9', '0', '\'', '^', 127, 9,
857 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i',
858 'o', 'p', 252, 0, 13, 0, 'a', 's',
859 'd', 'f', 'g', 'h', 'j', 'k', 'l', 246,
860 228, 167, 0, '$', 'y', 'x', 'c', 'v',
861 'b', 'n', 'm', ',', '.', '-', 0, '*',
862 0, 32, 0, 0, 0, 0, 0, 0,
863 0, 0, 0, 0, 0, 0, 0, 0,
864 0, 0, '-', 0, 0, 0, '+', 0,
865 0, 0, 0, 0, 0, 0, '<', 0,
866 0, 0, 0, 0, 0, 0, 0, 0,
867 0 };
868
869 static unsigned char shift_map[] = {
870 0, 27, '+', '"', '*', 231, '%', '&',
871 '/', '(', ')', '=', '?', '`', 127, 9,
872 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I',
873 'O', 'P', 220, '!', 13, 0, 'A', 'S',
874 'D', 'F', 'G', 'H', 'J', 'K', 'L', 214,
875 196, 176, 0, 163, 'Y', 'X', 'C', 'V',
876 'B', 'N', 'M', ';', ':', '_', 0, '*',
877 0, 32, 0, 0, 0, 0, 0, 0,
878 0, 0, 0, 0, 0, 0, 0, 0,
879 0, 0, '-', 0, 0, 0, '+', 0,
880 0, 0, 0, 0, 0, 0, '>', 0,
881 0, 0, 0, 0, 0, 0, 0, 0,
882 0 };
883
884 static unsigned char alt_map[] = {
885 0, 0, 0, '@', '#', 0, 0, 172,
886 '|', 162, 0, 0, '\'', '~', 0, 0,
887 '@', 0, 0, 0, 0, 0, 0, 0,
888 0, 0, '[', ']', 13, 0, 0, 0,
889 0, 0, 0, 0, 0, 0, 0, 233,
890 '{', 0, 0, '}', 0, 0, 0, 0,
891 0, 0, 0, 0, 0, 0, 0, 0,
892 0, 0, 0, 0, 0, 0, 0, 0,
893 0, 0, 0, 0, 0, 0, 0, 0,
894 0, 0, 0, 0, 0, 0, 0, 0,
895 0, 0, 0, 0, 0, 0, '\\', 0,
896 0, 0, 0, 0, 0, 0, 0, 0,
897 0 };
898
899 #elif defined KBD_NO
900
901 static unsigned char key_map[] = {
902 0, 27, '1', '2', '3', '4', '5', '6',
903 '7', '8', '9', '0', '+', '\\', 127, 9,
904 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
905 'o', 'p', '}', '~', 13, 0, 'a', 's',
906 'd', 'f', 'g', 'h', 'j', 'k', 'l', '|',
907 '{', '|', 0, '\'', 'z', 'x', 'c', 'v',
908 'b', 'n', 'm', ',', '.', '-', 0, '*',
909 0, 32, 0, 0, 0, 0, 0, 0,
910 0, 0, 0, 0, 0, 0, 0, 0,
911 0, 0, '-', 0, 0, 0, '+', 0,
912 0, 0, 0, 0, 0, 0, '<', 0,
913 0, 0, 0, 0, 0, 0, 0, 0,
914 0 };
915
916 static unsigned char shift_map[] = {
917 0, 27, '!', '\"', '#', '$', '%', '&',
918 '/', '(', ')', '=', '?', '`', 127, 9,
919 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
920 'O', 'P', ']', '^', 13, 0, 'A', 'S',
921 'D', 'F', 'G', 'H', 'J', 'K', 'L', '\\',
922 '[', 0, 0, '*', 'Z', 'X', 'C', 'V',
923 'B', 'N', 'M', ';', ':', '_', 0, '*',
924 0, 32, 0, 0, 0, 0, 0, 0,
925 0, 0, 0, 0, 0, 0, 0, 0,
926 0, 0, '-', 0, 0, 0, '+', 0,
927 0, 0, 0, 0, 0, 0, '>', 0,
928 0, 0, 0, 0, 0, 0, 0, 0,
929 0 };
930
931 static unsigned char alt_map[] = {
932 0, 0, 0, '@', 0, '$', 0, 0,
933 '{', '[', ']', '}', 0, '\'', 0, 0,
934 0, 0, 0, 0, 0, 0, 0, 0,
935 0, 0, 0, '~', 13, 0, 0, 0,
936 0, 0, 0, 0, 0, 0, 0, 0,
937 0, 0, 0, 0, 0, 0, 0, 0,
938 0, 0, 0, 0, 0, 0, 0, 0,
939 0, 0, 0, 0, 0, 0, 0, 0,
940 0, 0, 0, 0, 0, 0, 0, 0,
941 0, 0, 0, 0, 0, 0, 0, 0,
942 0, 0, 0, 0, 0, 0, 0, 0,
943 0, 0, 0, 0, 0, 0, 0, 0,
944 0 };
945
946 #elif defined KBD_SF
947
948 static unsigned char key_map[] = {
949 0, 27, '1', '2', '3', '4', '5', '6',
950 '7', '8', '9', '0', '\'', '^', 127, 9,
951 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i',
952 'o', 'p', 0, 0, 13, 0, 'a', 's',
953 'd', 'f', 'g', 'h', 'j', 'k', 'l', 0,
954 0, 0, 0, '$', 'y', 'x', 'c', 'v',
955 'b', 'n', 'm', ',', '.', '-', 0, '*',
956 0, 32, 0, 0, 0, 0, 0, 0,
957 0, 0, 0, 0, 0, 0, 0, 0,
958 0, 0, '-', 0, 0, 0, '+', 0,
959 0, 0, 0, 0, 0, 0, '<', 0,
960 0, 0, 0, 0, 0, 0, 0, 0,
961 0 };
962 static unsigned char shift_map[] = {
963 0, 27, '+', '"', '*', 0, '%', '&',
964 '/', '(', ')', '=', '?', '`', 127, 9,
965 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I',
966 'O', 'P', 0, '!', 13, 0, 'A', 'S',
967 'D', 'F', 'G', 'H', 'J', 'K', 'L', 0,
968 0, 0, 0, 0, 'Y', 'X', 'C', 'V',
969 'B', 'N', 'M', ';', ':', '_', 0, '*',
970 0, 32, 0, 0, 0, 0, 0, 0,
971 0, 0, 0, 0, 0, 0, 0, 0,
972 0, 0, '-', 0, 0, 0, '+', 0,
973 0, 0, 0, 0, 0, 0, '>', 0,
974 0, 0, 0, 0, 0, 0, 0, 0,
975 0 };
976 static unsigned char alt_map[] = {
977 0, 0, 0, '@', '#', 0, 0, 0,
978 '|', 0, 0, 0, '\'', '~', 0, 0,
979 0, 0, 0, 0, 0, 0, 0, 0,
980 0, 0, '[', ']', 13, 0, 0, 0,
981 0, 0, 0, 0, 0, 0, 0, 0,
982 '{', 0, 0, '}', 0, 0, 0, 0,
983 0, 0, 0, 0, 0, 0, 0, 0,
984 0, 0, 0, 0, 0, 0, 0, 0,
985 0, 0, 0, 0, 0, 0, 0, 0,
986 0, 0, 0, 0, 0, 0, 0, 0,
987 0, 0, 0, 0, 0, 0, '\\', 0,
988 0, 0, 0, 0, 0, 0, 0, 0,
989 0 };
990
991 #elif defined KBD_SF_LATIN1
992
993 static unsigned char key_map[] = {
994 0, 27, '1', '2', '3', '4', '5', '6',
995 '7', '8', '9', '0', '\'', '^', 127, 9,
996 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i',
997 'o', 'p', 232, 168, 13, 0, 'a', 's',
998 'd', 'f', 'g', 'h', 'j', 'k', 'l', 233,
999 224, 167, 0, '$', 'y', 'x', 'c', 'v',
1000 'b', 'n', 'm', ',', '.', '-', 0, '*',
1001 0, 32, 0, 0, 0, 0, 0, 0,
1002 0, 0, 0, 0, 0, 0, 0, 0,
1003 0, 0, '-', 0, 0, 0, '+', 0,
1004 0, 0, 0, 0, 0, 0, '<', 0,
1005 0, 0, 0, 0, 0, 0, 0, 0,
1006 0 };
1007 static unsigned char shift_map[] = {
1008 0, 27, '+', '"', '*', 231, '%', '&',
1009 '/', '(', ')', '=', '?', '`', 127, 9,
1010 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I',
1011 'O', 'P', 252, '!', 13, 0, 'A', 'S',
1012 'D', 'F', 'G', 'H', 'J', 'K', 'L', 246,
1013 228, 176, 0, 163, 'Y', 'X', 'C', 'V',
1014 'B', 'N', 'M', ';', ':', '_', 0, '*',
1015 0, 32, 0, 0, 0, 0, 0, 0,
1016 0, 0, 0, 0, 0, 0, 0, 0,
1017 0, 0, '-', 0, 0, 0, '+', 0,
1018 0, 0, 0, 0, 0, 0, '>', 0,
1019 0, 0, 0, 0, 0, 0, 0, 0,
1020 0 };
1021 static unsigned char alt_map[] = {
1022 0, 0, 0, '@', '#', 0, 0, 172,
1023 '|', 162, 0, 0, 180, '~', 0, 0,
1024 0, 0, 0, 0, 0, 0, 0, 0,
1025 0, 0, '[', ']', 13, 0, 0, 0,
1026 0, 0, 0, 0, 0, 0, 0, 0,
1027 '{', 0, 0, '}', 0, 0, 0, 0,
1028 0, 0, 0, 0, 0, 0, 0, 0,
1029 0, 0, 0, 0, 0, 0, 0, 0,
1030 0, 0, 0, 0, 0, 0, 0, 0,
1031 0, 0, 0, 0, 0, 0, 0, 0,
1032 0, 0, 0, 0, 0, 0, '\\', 0,
1033 0, 0, 0, 0, 0, 0, 0, 0,
1034 0 };
1035 #else
1036 #error "KBD-type not defined"
1037 #endif
1038
1039 static void do_self(int sc)
1040 {
1041 unsigned char ch;
1042
1043 if (kbd_flag(KG_ALTGR))
1044 ch = alt_map[sc];
1045 else if (kbd_flag(KG_LSHIFT) || kbd_flag(KG_RSHIFT) ||
1046 kbd_flag(KG_LCTRL) || kbd_flag(KG_RCTRL))
1047 ch = shift_map[sc];
1048 else
1049 ch = key_map[sc];
1050
1051 if (ch == 0)
1052 return;
1053
1054 if ((ch = handle_diacr(ch)) == 0)
1055 return;
1056
1057 if (kbd_flag(KG_LCTRL) || kbd_flag(KG_RCTRL) ||
1058 vc_kbd_flag(kbd,VC_CAPSLOCK))
1059 if ((ch >= 'a' && ch <= 'z') || (ch >= 224 && ch <= 254))
1060 ch -= 32;
1061 if (kbd_flag(KG_LCTRL) || kbd_flag(KG_RCTRL))
1062 ch &= 0x1f;
1063
1064 if (kbd_flag(KG_ALT))
1065 if (vc_kbd_flag(kbd,VC_META)) {
1066 put_queue('\033');
1067 put_queue(ch);
1068 } else
1069 put_queue(ch|0x80);
1070 else
1071 put_queue(ch);
1072 }
1073
1074 unsigned char accent_table[5][64] = {
1075 " \300BCD\310FGH\314JKLMN\322PQRST\331VWXYZ[\\]^_"
1076 "`\340bcd\350fgh\354jklmn\362pqrst\371vwxyz{|}~",
1077
1078 " \301BCD\311FGH\315JKLMN\323PQRST\332VWX\335Z[\\]^_"
1079 "`\341bcd\351fgh\355jklmn\363pqrst\372vwxyz{|}~",
1080
1081 " \302BCD\312FGH\316JKLMN\324PQRST\333VWXYZ[\\]^_"
1082 "`\342bcd\352fgh\356jklmn\364pqrst\373vwxyz{|}~",
1083
1084 " \303BCDEFGHIJKLMN\325PQRSTUVWXYZ[\\]^_"
1085 "`\343bcdefghijklm\361\365pqrstuvwxyz{|}~",
1086
1087 " \304BCD\313FGH\316JKLMN\326PQRST\334VWXYZ[\\]^_"
1088 "`\344bcd\353fgh\357jklmn\366pqrst\374vwx\377z{|}~"
1089 };
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100 unsigned int handle_diacr(unsigned int ch)
1101 {
1102 static unsigned char diacr_table[] =
1103 {'`', 180, '^', '~', 168, 0};
1104 static unsigned char ret_diacr[] =
1105 {'`', '\'', '^', '~', '"' };
1106 int i;
1107
1108 for(i=0; diacr_table[i]; i++)
1109 if (ch==diacr_table[i] && ((1<<i)&kbd->kbd_flags)) {
1110 if (diacr == i) {
1111 diacr=-1;
1112 return ret_diacr[i];
1113 } else {
1114 diacr=i;
1115 return 0;
1116 }
1117 }
1118 if (diacr == -1)
1119 return ch;
1120 else if (ch == ' ') {
1121 ch=ret_diacr[diacr];
1122 diacr=-1;
1123 return ch;
1124 } else if (ch<64 || ch>122) {
1125 diacr=-1;
1126 return ch;
1127 } else {
1128 ch=accent_table[diacr][ch-64];
1129 diacr=-1;
1130 return ch;
1131 }
1132 }
1133
1134 #if defined KBD_FR || defined KBD_US || defined KBD_UK || defined KBD_FR_LATIN1
1135 static unsigned char num_table[] = "789-456+1230.";
1136 #else
1137 static unsigned char num_table[] = "789-456+1230,";
1138 #endif
1139
1140 static unsigned char cur_table[] = "1A5-DGC+4B623";
1141 static unsigned int pad_table[] = { 7,8,9,0,4,5,6,0,1,2,3,0,0 };
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162 static unsigned char appl_table[] = "wxyStuvlqrspn";
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173 static char *func_table[2][12] = { {
1174 "\033[[A", "\033[[B", "\033[[C", "\033[[D",
1175 "\033[[E", "\033[17~", "\033[18~", "\033[19~",
1176 "\033[20~", "\033[21~", "\033[28~", "\033[29~"
1177 }, {
1178 "\033[23~", "\033[24~", "\033[25~", "\033[26~",
1179 "\033[28~", "\033[29~", "\033[31~", "\033[32~",
1180 "\033[33~", "\033[34~", "\033[28~", "\033[29~"
1181 }};
1182
1183 static void cursor(int sc)
1184 {
1185 if (sc < 0x47 || sc > 0x53)
1186 return;
1187 sc -= 0x47;
1188 if (sc == 12 &&
1189 (kbd_flag(KG_LCTRL) || kbd_flag(KG_RCTRL)) &&
1190 (kbd_flag(KG_ALT) || kbd_flag(KG_ALTGR))) {
1191 ctrl_alt_del();
1192 return;
1193 }
1194 if (kbd_dead(KGD_E0)) {
1195 cur(sc);
1196 return;
1197 }
1198
1199 if (kbd_flag(KG_ALT) && sc != 12) {
1200 npadch=npadch*10+pad_table[sc];
1201 return;
1202 }
1203
1204 if (vc_kbd_flag(kbd,VC_APPLIC) &&
1205 !kbd_flag(KG_LSHIFT) &&
1206 !kbd_flag(KG_RSHIFT)) {
1207 applkey(appl_table[sc]);
1208 return;
1209 }
1210
1211 if (vc_kbd_flag(kbd,VC_NUMLOCK)) {
1212 put_queue(num_table[sc]);
1213 } else
1214 cur(sc);
1215 }
1216
1217 static void cur(int sc)
1218 {
1219 char buf[] = { 0x1b, '[', 0, 0, 0 };
1220
1221 buf[2]=cur_table[sc];
1222 if (buf[2] < '9')
1223 buf[3]='~';
1224 else
1225 if ((buf[2] >= 'A' && buf[2] <= 'D') ?
1226 vc_kbd_flag(kbd,VC_CKMODE) :
1227 vc_kbd_flag(kbd,VC_APPLIC))
1228 buf[1]='O';
1229 puts_queue(buf);
1230 }
1231
1232 static void func(int sc)
1233 {
1234 if (sc < 0x3b)
1235 return;
1236 sc-=0x3b;
1237 if (sc > 9) {
1238 sc-=18;
1239 if (sc < 10 || sc > 11)
1240 return;
1241 }
1242 if (kbd_flag(KG_ALT))
1243 want_console = sc;
1244 else
1245 if (kbd_flag(KG_LSHIFT) || kbd_flag(KG_RSHIFT))
1246 puts_queue(func_table[1][sc]);
1247 else
1248 puts_queue(func_table[0][sc]);
1249 }
1250
1251 static void slash(int sc)
1252 {
1253 if (!kbd_dead(KGD_E0))
1254 do_self(sc);
1255 else if (vc_kbd_flag(kbd,VC_APPLIC))
1256 applkey('Q');
1257 else
1258 put_queue('/');
1259 }
1260
1261 static void star(int sc)
1262 {
1263 if (vc_kbd_flag(kbd,VC_APPLIC))
1264 applkey('R');
1265 else
1266 do_self(sc);
1267 }
1268
1269 static void enter(int sc)
1270 {
1271 if (kbd_dead(KGD_E0) && vc_kbd_flag(kbd,VC_APPLIC))
1272 applkey('M');
1273 else {
1274 put_queue(13);
1275 if (vc_kbd_flag(kbd,VC_CRLF))
1276 put_queue(10);
1277 }
1278 }
1279
1280 static void minus(int sc)
1281 {
1282 if (vc_kbd_flag(kbd,VC_APPLIC))
1283 applkey('S');
1284 else
1285 do_self(sc);
1286 }
1287
1288 static void plus(int sc)
1289 {
1290 if (vc_kbd_flag(kbd,VC_APPLIC))
1291 applkey('l');
1292 else
1293 do_self(sc);
1294 }
1295
1296 static void none(int sc)
1297 {
1298 }
1299
1300
1301
1302
1303
1304
1305 static int send_data(unsigned char data)
1306 {
1307 int retries = 3;
1308 int i;
1309
1310 do {
1311 kb_wait();
1312 acknowledge = 0;
1313 resend = 0;
1314 outb_p(data, 0x60);
1315 for(i=0; i<0x20000; i++) {
1316 inb_p(0x64);
1317 if (acknowledge)
1318 return 1;
1319 if (resend)
1320 goto repeat;
1321 }
1322 return 0;
1323 repeat:
1324 } while (retries-- > 0);
1325 return 0;
1326 }
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341 static void kbd_bh(void * unused)
1342 {
1343 static unsigned char old_leds = -1;
1344 unsigned char leds = kbd_table[fg_console].flags & LED_MASK;
1345
1346 if (leds != old_leds) {
1347 old_leds = leds;
1348 if (!send_data(0xed) || !send_data(leds))
1349 send_data(0xf4);
1350 }
1351 if (want_console >= 0) {
1352 change_console(want_console);
1353 want_console = -1;
1354 }
1355 do_keyboard_interrupt();
1356 cli();
1357 if (inb_p(0x64) & 0x01)
1358 fake_keyboard_interrupt();
1359 sti();
1360 }
1361
1362 long no_idt[2] = {0, 0};
1363
1364
1365
1366
1367
1368
1369 void hard_reset_now(void)
1370 {
1371 int i, j;
1372 extern unsigned long pg0[1024];
1373
1374 sti();
1375
1376 pg0[0] = 7;
1377 *((unsigned short *)0x472) = 0x1234;
1378 for (;;) {
1379 for (i=0; i<100; i++) {
1380 kb_wait();
1381 for(j = 0; j < 100000 ; j++)
1382 ;
1383 outb(0xfe,0x64);
1384 }
1385 __asm__("\tlidt _no_idt"::);
1386 }
1387 }
1388
1389 static fptr key_table[] = {
1390 none,do_self,do_self,do_self,
1391 do_self,do_self,do_self,do_self,
1392 do_self,do_self,do_self,do_self,
1393 do_self,do_self,do_self,do_self,
1394 do_self,do_self,do_self,do_self,
1395 do_self,do_self,do_self,do_self,
1396 do_self,do_self,do_self,do_self,
1397 enter,ctrl,do_self,do_self,
1398 do_self,do_self,do_self,do_self,
1399 do_self,do_self,do_self,do_self,
1400 do_self,do_self,lshift,do_self,
1401 do_self,do_self,do_self,do_self,
1402 do_self,do_self,do_self,do_self,
1403 do_self,slash,rshift,star,
1404 alt,do_self,caps,func,
1405 func,func,func,func,
1406 func,func,func,func,
1407 func,num,scroll,cursor,
1408 cursor,cursor,minus,cursor,
1409 cursor,cursor,plus,cursor,
1410 cursor,cursor,cursor,cursor,
1411 none,none,do_self,func,
1412 func,none,none,none,
1413 none,none,none,none,
1414 none,none,none,none,
1415 none,none,none,none,
1416 none,none,none,none,
1417 none,none,none,none,
1418 none,none,none,none,
1419 none,none,none,none,
1420 none,none,none,none,
1421 none,none,none,none,
1422 none,none,none,none,
1423 none,none,none,none,
1424 none,none,none,none,
1425 none,none,none,none,
1426 none,none,none,none,
1427 none,none,none,none,
1428 none,none,none,none,
1429 none,unctrl,none,none,
1430 none,none,none,none,
1431 none,none,none,none,
1432 none,none,unlshift,none,
1433 none,none,none,none,
1434 none,none,none,none,
1435 none,none,unrshift,none,
1436 unalt,none,uncaps,none,
1437 none,none,none,none,
1438 none,none,none,none,
1439 none,none,none,none,
1440 none,none,none,none,
1441 none,none,none,none,
1442 none,none,none,none,
1443 none,none,none,none,
1444 none,none,none,none,
1445 none,none,none,none,
1446 none,none,none,none,
1447 none,none,none,none,
1448 none,none,none,none,
1449 none,none,none,none,
1450 none,none,none,none,
1451 none,none,none,none,
1452 none,none,none,none,
1453 none,none,none,none
1454 };
1455
1456 unsigned long kbd_init(unsigned long kmem_start)
1457 {
1458 int i;
1459 struct kbd_struct * kbd;
1460
1461 kbd = kbd_table + 0;
1462 for (i = 0 ; i < NR_CONSOLES ; i++,kbd++) {
1463 kbd->flags = KBD_DEFFLAGS;
1464 kbd->default_flags = KBD_DEFFLAGS;
1465 kbd->kbd_flags = KBDFLAGS;
1466 }
1467 bh_base[KEYBOARD_BH].routine = kbd_bh;
1468 request_irq(KEYBOARD_IRQ,keyboard_interrupt);
1469 mark_bh(KEYBOARD_BH);
1470 return kmem_start;
1471 }