2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 #include <devices/keymap.h>
30 static UBYTE lokeymaptypes
[] =
99 static UBYTE hikeymaptypes
[] =
102 N
, /* 41 BACKSPACE */
108 ST
|S
, /* 47 INSERT ?? */
109 ST
|S
, /* 48 PAGE UP ?? */
110 ST
|S
, /* 49 PAGE DOWN ?? */
111 N
, /* 4A NUMERIC PAD - */
112 ST
|S
, /* 4B F11 ?? */
113 ST
|S
, /* 4C CURSORUP*/
114 ST
|S
, /* 4D CURSORDOWN */
115 ST
|S
, /* 4E CURSORRIGHT */
116 ST
|S
, /* 4F CURSORLEFT */
133 NOP
, /* 60 LEFT SHIFT*/
134 NOP
, /* 61 RIGHT SHIFT */
135 NOP
, /* 62 CAPS LOCK */
136 NOP
, /* 63 CONTROL */
139 NOP
, /* 66 LCOMMAND */
140 NOP
, /* 67 RCOMMAND */
141 NOP
, /* 68 LEFT MOUSE BUTTON*/
142 NOP
, /* 69 RIGHT MOUSE BUTTON */
143 NOP
, /* 6A MIDDLE MOUSE BUTTON */
147 ST
|A
, /* 6E PAUSE/BREAK ??*/
148 ST
|S
, /* 6F F12 ?? */
149 ST
|C
, /* 70 HOME ?? */
150 ST
|C
, /* 71 END ?? */
181 #define STRING(x) (IPTR)x
182 #define DEAD(x) (IPTR)x
184 #define BYTES(b0, b1, b2, b3) \
185 (((UBYTE)b0)<<24) | (((UBYTE)b1)<<16) | (((UBYTE)b2)<<8) | (((UBYTE)b3)<<0)
187 static IPTR lokeymap
[] =
189 BYTES('~', '`', '~', '`'), /* 00 Left of 1 Key */
190 BYTES(0xB9, 0xA1, '!', '1'), /* 01 1 */
191 BYTES(0xB2, '@', '@', '2'), /* 02 2 */
192 BYTES(0xB3, 0xA3, '#', '3'), /* 03 3 */
193 BYTES(0xBC, 0xA4, '$', '4'), /* 04 4 */
194 BYTES(0xBD, 0xBD, '%', '5'), /* 05 5 */
195 BYTES(0xBE, 0xBE, '^', '6'), /* 06 6 */
196 BYTES(0xF7, '{', '&', '7'), /* 07 7 */
197 BYTES('[', '[', '*', '8'), /* 08 8 */
198 BYTES(']', ']', '(', '9'), /* 09 9 */
199 BYTES('}', '}', ')', '0'), /* 0A 0 */
200 BYTES('_', '-', '_', '-'), /* 0B Right of 0 */
201 BYTES('+', '=', '+', '='), /* 0C 2nd right of 0 */
202 BYTES('|', '\\', '|', '\\'), /* 0D 3rd right of 0 */
203 BYTES(0, 0, 0, 0), /* 0E undefined */
204 BYTES('0', '0', '0', '0'), /* 0F NUM 0 */
205 BYTES('Q', 'q', 'Q', 'q'), /* 10 */
206 BYTES('W', 'w', 'W', 'w'), /* 11 */
207 BYTES('E', 'e', 'E', 'e'), /* 12 */
208 BYTES('R', 'r', 'R', 'r'), /* 13 */
209 BYTES('T', 't', 'T', 't'), /* 14 */
210 BYTES('Y', 'y', 'Y', 'y'), /* 15 */
211 BYTES('U', 'u', 'U', 'u'), /* 16 */
212 BYTES('I', 'i', 'I', 'i'), /* 17 */
213 BYTES('O', 'o', 'O', 'o'), /* 18 */
214 BYTES('P', 'p', 'P', 'p'), /* 19 */
216 BYTES('{', '[', '{', '['), /* 1A */
217 BYTES('}', ']', '}', ']'), /* 1B */
218 BYTES(0, 0, 0, 0), /* 1C undefined */
219 BYTES('1', '1', '1', '1'), /* 1D NUM 1*/
220 BYTES('2', '2', '2', '2'), /* 1E NUM 2*/
221 BYTES('3', '3', '3', '3'), /* 1F NUM 3*/
223 BYTES('A', 'a', 'A', 'a'), /* 20 */
224 BYTES('S', 's', 'S', 's'), /* 21 */
225 BYTES('D', 'd', 'D', 'd'), /* 22 */
226 BYTES('F', 'f', 'F', 'f'), /* 23 */
227 BYTES('G', 'g', 'G', 'g'), /* 24 */
228 BYTES('H', 'h', 'H', 'h'), /* 25 */
229 BYTES('J', 'j', 'J', 'j'), /* 26 */
230 BYTES('K', 'k', 'K', 'k'), /* 27 */
231 BYTES('L', 'l', 'L', 'l'), /* 28 */
233 BYTES(':', ';', ':', ';'), /* 29 */
234 BYTES('"', 0x27, '"', 0x27), /* 2A */
235 BYTES('|', '\\', '|', '\\'), /* 2B */
236 BYTES(0, 0, 0, 0), /* 2C undefined */
237 BYTES('4', '4', '4', '4'), /* 2D NUM 4 */
238 BYTES('5', '5', '5', '5'), /* 2E NUM 5 */
239 BYTES('6', '6', '6', '6'), /* 2F NUM 6 */
240 BYTES('>', '<', '>', '<'), /* 30 */
242 BYTES('Z', 'z', 'Z', 'z'), /* 31 */
243 BYTES('X', 'x', 'X', 'x'), /* 32 */
244 BYTES('C', 'c', 'C', 'c'), /* 33 */
245 BYTES('V', 'v', 'V', 'v'), /* 34 */
246 BYTES('B', 'b', 'B', 'b'), /* 35 */
247 BYTES('N', 'n', 'N', 'n'), /* 36 */
248 BYTES('M', 'm', 'M', 'm'), /* 37 */
250 BYTES('<', ',', '<', ','), /* 38 */
251 BYTES('>', '.', '>', '.'), /* 39 */
252 BYTES('?', '/', '?', '/'), /* 3A */
253 BYTES(0, 0, 0, 0), /* 3B */
254 BYTES('.', '.', '.', '.'), /* 3C NUM . */
255 BYTES('7', '7', '7', '7'), /* 3D NUM 7 */
256 BYTES('8', '8', '8', '8'), /* 3E NUM 8 */
257 BYTES('9', '9', '9', '9'), /* 3F NUM 9 */
260 /* Strings for the F1 key. In a real AmigaOS keymap, these would have come after
261 ** the HiKeyMap, but we do it this way to avoid prototyping
263 ** String descriptors are byte arrays and work like this:
265 ** sizeofstring,offset_from_start_array_to_start_of_string
266 ** sizeofstring,offset_from_start_array_to_start_of_string
274 ** The number of strings depends on the qualifier flags
275 ** set in the keymap type.
386 UBYTE insert_descr
[] =
395 UBYTE pageup_descr
[] =
404 UBYTE pagedown_descr
[] =
413 UBYTE pausebreak_descr
[] =
467 UBYTE right_descr
[] =
492 static IPTR hikeymap
[] =
494 BYTES(' ', ' ', ' ', ' '), /* 40 */
495 BYTES(8, 8, 8, 8), /* 41 BACKSPACE*/
496 STRING(tab_descr
), /* 42 TAB */
497 BYTES(13, 13, 13, 13), /* 43 ENTER */
498 BYTES(0, 0, 10, 13), /* 44 RETURN */
499 BYTES(0, 0, 0x9B, 27), /* 45 ESCAPE */
500 BYTES(127, 127, 127, 127), /* 46 DEL */
501 STRING(insert_descr
), /* 47 INSERT ?? */
502 STRING(pageup_descr
), /* 48 PAGEUP ?? */
503 STRING(pagedown_descr
), /* 49 PAGEDOWN ?? */
504 BYTES('-', '-', '-', '-'), /* 4A NUMPAD - */
505 STRING(f11_descr
), /* 4B F11 ?? */
506 STRING(up_descr
), /* 4C CURSOR UP*/
507 STRING(down_descr
), /* 4D CURSOR DOWN*/
508 STRING(right_descr
), /* 4E CURSOR RIGHT */
509 STRING(left_descr
), /* 4F CURSOR LEFT */
510 STRING(f1_descr
), /* 50 F1 */
511 STRING(f2_descr
), /* 51 */
512 STRING(f3_descr
), /* 52 */
513 STRING(f4_descr
), /* 53 */
514 STRING(f5_descr
), /* 54 */
515 STRING(f6_descr
), /* 55 */
516 STRING(f7_descr
), /* 56 */
517 STRING(f8_descr
), /* 57 */
518 STRING(f9_descr
), /* 58 */
519 STRING(f10_descr
), /* 59 */
520 BYTES('[', '(', '[', '('), /* 5A */
521 BYTES(']', ')', ']', ')'), /* 5B */
522 BYTES('/', '/', '/', '/'), /* 5C */
523 BYTES('*', '*', '*', '*'), /* 5D */
524 BYTES('+', '+', '+', '+'), /* 5E */
525 STRING(help_descr
), /* 5F HELP */
526 BYTES(0, 0, 0, 0), /* 60 */
527 BYTES(0, 0, 0, 0), /* 61 */
528 BYTES(0, 0, 0, 0), /* 62 */
529 BYTES(0, 0, 0, 0), /* 63 */
530 BYTES(0, 0, 0, 0), /* 64 */
531 BYTES(0, 0, 0, 0), /* 65 */
532 BYTES(0, 0, 0, 0), /* 66 */
533 BYTES(0, 0, 0, 0), /* 67 */
534 BYTES(0, 0, 0, 0), /* 68 */
535 BYTES(0, 0, 0, 0), /* 69 */
536 BYTES(0, 0, 0, 0), /* 6A */
537 BYTES(0, 0, 0, 0), /* 6B */
538 BYTES(0, 0, 0, 0), /* 6C */
539 BYTES(0, 0, 0, 0), /* 6D */
540 STRING(pausebreak_descr
), /* 6E PAUSE/BREAK ?? */
541 STRING(f12_descr
), /* 6F F12 ?? */
542 STRING(home_descr
), /* 70 HOME ?? */
543 STRING(end_descr
), /* 71 END ?? */
544 BYTES(0, 0, 0, 0), /* 72 */
545 BYTES(0, 0, 0, 0), /* 73 */
546 BYTES(0, 0, 0, 0), /* 74 */
547 BYTES(0, 0, 0, 0), /* 75 */
548 BYTES(0, 0, 0, 0), /* 76 */
549 BYTES(0, 0, 0, 0), /* 77 */
550 BYTES(0, 0, 0, 0), /* 78 */
551 BYTES(0, 0, 0, 0), /* 79 */
552 BYTES(0, 0, 0, 0), /* 7A */
553 BYTES(0, 0, 0, 0), /* 7B */
554 BYTES(0, 0, 0, 0), /* 7C */
555 BYTES(0, 0, 0, 0), /* 7D */
556 BYTES(0, 0, 0, 0), /* 7E */
557 BYTES(0, 0, 0, 0), /* 7F */
562 #define SETBITS(b0, b1, b2, b3, b4, b5, b6, b7) \
563 (b0<<0)|(b1<<1)|(b2<<2)|(b3<<3)|(b4<<4)|(b5<<5)|(b6<<6)|(b7<<7)
565 static UBYTE locapsable
[] =
567 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 00 - 07 */
568 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 08 - 0F */
570 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 10 - 17 */
571 SETBITS(1, 1, 0, 0, 0, 0, 0, 0), /* 18 - 1F */
573 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 20 - 27 */
574 SETBITS(1, 0, 0, 0, 0, 0, 0, 0), /* 28 - 2F */
576 SETBITS(0, 1, 1, 1, 1, 1, 1, 1), /* 30 - 37 */
577 SETBITS(0, 0, 0, 0, 0, 0, 0, 0) /* 38 - 3F */
580 static UBYTE hicapsable
[] =
582 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 40 - 47 */
583 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 48 - 4F */
585 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 50 - 57 */
586 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 58 - 5F */
588 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 60 - 67 */
589 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 68 - 6F */
591 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 70 - 77 */
592 SETBITS(0, 0, 0, 0, 0, 0, 0, 0) /* 78 - 7F */
595 static UBYTE lorepeatable
[] =
597 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 00 - 07 */
598 SETBITS(1, 1, 1, 1, 1, 1, 0, 1), /* 08 - 0F */
600 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 10 - 17 */
601 SETBITS(1, 1, 1, 1, 0, 1, 1, 1), /* 18 - 1F */
603 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 20 - 27 */
604 SETBITS(1, 1, 1, 1, 0, 1, 1, 1), /* 28 - 2F */
606 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 30 - 37 */
607 SETBITS(1, 1, 1, 0, 1, 1, 1, 1) /* 38 - 3F */
610 static UBYTE hirepeatable
[] =
612 SETBITS(1, 1, 1, 0, 0, 0, 1, 0), /* 40 - 47 */
613 SETBITS(1, 1, 0, 0, 1, 1, 1, 1), /* 48 - 4F */
615 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 50 - 57 */
616 SETBITS(0, 0, 1, 1, 1, 1, 1, 0), /* 58 - 5F */
618 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 60 - 67 */
619 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 68 - 6F */
621 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 70 - 77 */
622 SETBITS(0, 0, 0, 0, 0, 0, 0, 0) /* 78 - 7F */
625 struct KeyMap def_km
=
638 /* index vertically: (keytype & KC_VANILLA)
639 ** index horizontally: KCF_xxx qualifier combination for keypress.
640 ** Which is used to get the index of the byte describing the keypress.
641 ** X means invalid key.
642 ** S means Ctrl-c alike combination (clear bits 5 and 6)
644 #undef X /* undefined */
645 #undef S /* Ctrl-c like combo */
651 /* stegerg: on the Amiga you get a key event if you
652 press for example CONTROL + A, even if
653 the keymaptype for that key has not set
654 KCF_CONTROL. So it looks like if for a
655 certain keypress some qualifiers are set
656 which are not set in the keymap-type then
657 this qualifiers are simply to be ignored
660 const BYTE keymaptype_table
[8][8] =
662 {3, 3, 3, 3, 3, 3, 3, 3}, /* KCF_NOQUAL == 0 */
663 {3, 2, 3, 2, 3, 2, 3, 2}, /* KCF_SHIFT == 1 */
664 {3, 3, 2, 2, 3, 3, 2, 2}, /* KCF_ALT == 2 */
665 {3, 2, 1, 0, 3, 2, 1, 0}, /* KCF_SHIFT|KCF_ALT == 3 */
666 {3, 3, 3, 3, 2, 2, 2, 2}, /* KCF_CONTROL == 4 */
667 {3, 2, 3, 2, 1, 0, 1, 0}, /* KCF_SHIFT|KCF_CONTROL == 5 */
668 {3, 3, 2, 2, 1, 1, 0, 0}, /* KCF_ALT|KCF_CONTROL == 6 */
669 {3, 2, 1, 0, S
, X
, X
, X
} /* KCF_SHIFT|KCF_ALT|KCF_CONTROL == KC__VANILLA == 7 */
675 const BYTE keymaptype_table
[8][8] =
677 {3, X
, X
, X
, X
, X
, X
, X
}, /* KCF_NOQUAL == 0 */
678 {3, 2, X
, X
, X
, X
, X
, X
}, /* KCF_SHIFT == 1 */
679 {3, X
, 2, X
, X
, X
, X
, X
}, /* KCF_ALT == 2 */
680 {3, 2, 1, 0, X
, X
, X
, X
}, /* KCF_SHIFT|KCF_ALT == 3 */
681 {3, X
, X
, X
, 2, X
, X
, X
}, /* KCF_CONTROL == 4 */
682 {3, 2, X
, X
, 1, 0, X
, X
}, /* KCF_SHIFT|KCF_CONTROL == 5 */
683 {3, X
, 2, X
, 1, X
, 0, X
}, /* KCF_ALT|KCF_CONTROL == 6 */
684 {3, 2, 1, 0, S
, X
, X
, X
} /* KCF_SHIFT|KCF_ALT|KCF_CONTROL == KC__VANILLA == 7 */
691 /* index vertically: (keytype & KC_VANILLA)
692 ** index horizontally: KCF_xxx qualifier combination for keypress.
693 ** Used to get the number of the string descriptor,
694 ** depending on the KCF_SHIFT, KCF_ALT and KCF_CONTROL qualifiers
695 ** of the key pressed
700 /* stegerg: see comment before keymaptype_table */
702 const BYTE keymapstr_table
[8][8] =
704 {0, 0, 0, 0, 0, 0, 0, 0}, /* KCF_NOQUAL == 0 */
705 {0, 1, 0, 1, 0, 1, 0, 1}, /* KCF_SHIFT == 1 */
706 {0, 0, 1, 1, 0, 0, 1, 1}, /* KCF_ALT == 2 */
707 {0, 1, 2, 3, 0, 1, 2, 3}, /* KCF_SHIFT|KCF_ALT == 3 */
708 {0, 0, 0, 0, 1, 1, 1, 1}, /* KCF_CONTROL == 4 */
709 {0, 1, 0, 1, 2, 3, 2, 3}, /* KCF_SHIFT|KCF_CONTROL == 5 */
710 {0, 0, 1, 1, 2, 2, 3, 3}, /* KCF_ALT|KCF_CONTROL == 6 */
711 {0, 1, 2, 3, 4, 5, 6, 7} /* KCF_SHIFT|KCF_ALT|KCF_CONTROL == KC__VANILLA == 7 */
715 const BYTE keymapstr_table
[8][8] =
717 {0, X
, X
, X
, X
, X
, X
, X
}, /* KCF_NOQUAL == 0 */
718 {0, 1, X
, X
, X
, X
, X
, X
}, /* KCF_SHIFT == 1 */
719 {0, X
, 1, X
, X
, X
, X
, X
}, /* KCF_ALT == 2 */
720 {0, 1, 2, 3, X
, X
, X
, X
}, /* KCF_SHIFT|KCF_ALT == 3 */
721 {0, X
, X
, X
, 1, X
, X
, X
}, /* KCF_CONTROL == 4 */
722 {0, 1, X
, X
, 2, 3, X
, X
}, /* KCF_SHIFT|KCF_CONTROL == 5 */
723 {0, X
, 1, X
, 2, X
, 3, X
}, /* KCF_ALT|KCF_CONTROL == 6 */
724 {0, 1, 2, 3, 4, 5, 6, 7} /* KCF_SHIFT|KCF_ALT|KCF_CONTROL == KC__VANILLA == 7 */