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