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