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