2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
9 #include <devices/keymap.h>
30 #define EUR 0xA4 /* ISO 8859-15: Euro = 164 = 0xA4) */
32 static CONST UBYTE lokeymaptypes
[] =
101 static CONST UBYTE hikeymaptypes
[] =
104 N
, /* 41 BACKSPACE */
110 ST
|S
, /* 47 INSERT ?? */
111 ST
|S
, /* 48 PAGE UP ?? */
112 ST
|S
, /* 49 PAGE DOWN ?? */
113 N
, /* 4A NUMERIC PAD - */
114 ST
|S
, /* 4B F11 ?? */
115 ST
|S
, /* 4C CURSORUP*/
116 ST
|S
, /* 4D CURSORDOWN */
117 ST
|S
, /* 4E CURSORRIGHT */
118 ST
|S
, /* 4F CURSORLEFT */
135 NOP
, /* 60 LEFT SHIFT*/
136 NOP
, /* 61 RIGHT SHIFT */
137 NOP
, /* 62 CAPS LOCK */
138 NOP
, /* 63 CONTROL */
141 NOP
, /* 66 LCOMMAND */
142 NOP
, /* 67 RCOMMAND */
143 NOP
, /* 68 LEFT MOUSE BUTTON*/
144 NOP
, /* 69 RIGHT MOUSE BUTTON */
145 NOP
, /* 6A MIDDLE MOUSE BUTTON */
149 ST
|A
, /* 6E PAUSE/BREAK ??*/
150 ST
|S
, /* 6F F12 ?? */
151 ST
|C
, /* 70 HOME ?? */
152 ST
|C
, /* 71 END ?? */
183 #define STRING(x) (IPTR)x
184 #define DEAD(x) (IPTR)x
186 #define BYTES(b0, b1, b2, b3) \
187 (((UBYTE)b0)<<24) | (((UBYTE)b1)<<16) | (((UBYTE)b2)<<8) | (((UBYTE)b3)<<0)
201 STATIC CONST UBYTE a_descr
[] =
212 'a', 'á' /*0xE1*/, 'à' /*0xE0*/, 'â' /*0xE2*/, 'ã' /*0xE3*/, 'ä' /*0xE4*/, 'å' /*0xE5*/,
214 'A', 'Á' /*0xC1*/, 'À' /*0xC0*/, 'Â' /*0xC2*/, 'Ã' /*0xC3*/, 'Ä' /*0xC4*/, 'Å' /*0xC5*/
217 STATIC CONST UBYTE e_descr
[] =
228 'e', 'é' /*0xE9*/, 'è' /*0xE8*/, 'ê' /*0xEA*/, 'e', 'ë' /*0xEB*/, 'e',
230 'E', 'É' /*0xC9*/, 'È' /*0xC8*/, 'Ê' /*0xCA*/, 'E', 'Ë' /*0xCB*/, 'E'
233 STATIC CONST UBYTE u_descr
[] =
244 'u', 'ú' /*0xFA*/, 'ù' /*0xF9*/, 'û' /*0xFB*/, 'u', 'ü' /*0xFC*/, 'u',
246 'U', 'Ú' /*0xDA*/, 'Ù' /*0xD9*/, 'Û' /*0xDB*/, 'U', 'Ü' /*0xDC*/, 'U'
249 STATIC CONST UBYTE i_descr
[] =
260 'i', 'í' /*0xED*/, 'ì' /*0xEC*/, 'î' /*0xEE*/, 'i', 'ï' /*0xEF*/, 'i',
262 'I', 'Í' /*0xCD*/, 'Ì' /*0xCC*/, 'Î' /*0xCE*/, 'I', 'Ï' /*0xCF*/, 'I'
265 STATIC CONST UBYTE o_descr
[] =
276 'o', 'ó' /*0xF3*/, 'ò' /*0xF2*/, 'ô' /*0xF4*/, 'õ' /*0xF5*/, 'ö' /*0xF6*/, 'o',
278 'O', 'Ó' /*0xD3*/, 'Ò' /*0xD2*/, 'Ô' /*0xD4*/, 'Õ' /*0xD5*/, 'Ö' /*0xD6*/, 'O'
281 STATIC CONST UBYTE y_descr
[] =
292 'y', 'ý', 'y', 'y', 'y', 'ÿ', 'y',
294 'Y', 'Ý', 'Y', 'Y', 'Y', 'Y', 'Y'
297 STATIC CONST UBYTE n_descr
[] =
308 'n', 'n', 'n', 'n', 'ñ', 'n', 'n',
310 'N', 'N', 'N', 'N', 'Ñ', 'N', 'N'
313 STATIC CONST UBYTE f_descr
[] =
325 STATIC CONST UBYTE g_descr
[] =
337 STATIC CONST UBYTE h_descr
[] =
349 STATIC CONST UBYTE j_descr
[] =
361 STATIC CONST UBYTE k_descr
[] =
374 static CONST IPTR lokeymap
[] =
376 BYTES('~', '`', '~', '`'), /* 00 Left of 1 Key */
377 BYTES('!', '¹', '!', '1'), /* 01 1 */
378 BYTES('@', '²', '@', '2'), /* 02 2 */
379 BYTES('#', '³', '#', '3'), /* 03 3 */
380 BYTES('$', '¢', '$', '4'), /* 04 4 */
381 BYTES('%', '¼', '%', '5'), /* 05 5 */
382 BYTES('^', '½', '^', '6'), /* 06 6 */
383 BYTES('&', '¾', '&', '7'), /* 07 7 */
384 BYTES('*', '·', '*', '8'), /* 08 8 */
385 BYTES('(', '«', '(', '9'), /* 09 9 */
386 BYTES(')', '»', ')', '0'), /* 0A 0 */
387 BYTES('_', '-', '_', '-'), /* 0B Right of 0 */
388 BYTES('+', '=', '+', '='), /* 0C 2nd right of 0 */
389 BYTES('|', '\\', '|', '\\'), /* 0D 3rd right of 0 */
390 BYTES(0, 0, 0, 0), /* 0E undefined */
391 BYTES('0', '0', '0', '0'), /* 0F NUM 0 */
392 BYTES('Å', 'å', 'Q', 'q'), /* 10 */
393 BYTES('°', '°', 'W', 'w'), /* 11 */
394 DEAD(e_descr
), /* 12 */
395 BYTES('®', '®', 'R', 'r'), /* 13 */
396 BYTES('Þ', 'þ', 'T', 't'), /* 14 */
397 DEAD(y_descr
), /* 15 */
398 DEAD(u_descr
), /* 16 */
399 DEAD(i_descr
), /* 17 */
400 DEAD(o_descr
), /* 18 */
401 BYTES('¶', '¶', 'P', 'p'), /* 19 */
403 BYTES('{', '[', '{', '['), /* 1A */
404 BYTES('}', ']', '}', ']'), /* 1B */
405 BYTES(0, 0, 0, 0), /* 1C undefined */
406 BYTES('0', '0', '0', '1'), /* 1D NUM 1*/
407 BYTES('0', '0', '0', '2'), /* 1E NUM 2*/
408 BYTES('0', '0', '0', '3'), /* 1F NUM 3*/
410 DEAD(a_descr
), /* 20 */
411 BYTES('§', 'ß', 'S', 's'), /* 21 */
412 BYTES('Ð', 'ð', 'D', 'd'), /* 22 */
413 DEAD(f_descr
), /* 23 */
414 DEAD(g_descr
), /* 24 */
415 DEAD(h_descr
), /* 25 */
416 DEAD(j_descr
), /* 26 */
417 DEAD(k_descr
), /* 27 */
418 BYTES('£', '£', 'L', 'l'), /* 28 */
420 BYTES(':', ';', ':', ';'), /* 29 */
421 BYTES('"', '\'', '"', '\''), /* 2A */
422 BYTES(0, 0, 0, 0), /* 2B undefined */
423 BYTES(0, 0, 0, 0), /* 2C undefined */
424 BYTES('0', '0', '0', '4'), /* 2D NUM 4 */
425 BYTES('0', '0', '0', '5'), /* 2E NUM 5 */
426 BYTES('0', '0', '0', '6'), /* 2F NUM 6 */
427 BYTES('»', '«', '>', '<'), /* 30 */
429 BYTES('¬', '±', 'Z', 'z'), /* 31 */
430 BYTES('÷', '×', 'X', 'x'), /* 32 */
431 BYTES('Ç', 'ç', 'C', 'c'), /* 33 */
432 BYTES('ª', 'ª', 'V', 'v'), /* 34 */
433 BYTES('º', 'º', 'B', 'b'), /* 35 */
434 DEAD(n_descr
), /* 36 */
435 BYTES('¿', '¸', 'M', 'm'), /* 37 */
437 BYTES('<', ',', '<', ','), /* 38 */
438 BYTES('>', '.', '>', '.'), /* 39 */
439 BYTES('?', '/', '?', '/'), /* 3A */
440 BYTES(0, 0, 0, 0), /* 3B */
441 BYTES('0', '0', '0', '.'), /* 3C NUM . */
442 BYTES('0', '0', '0', '7'), /* 3D NUM 7 */
443 BYTES('0', '0', '0', '8'), /* 3E NUM 8 */
444 BYTES('0', '0', '0', '9'), /* 3F NUM 9 */
447 /* Strings for the F1 key. In a real AmigaOS keymap, these would have come after
448 ** the HiKeyMap, but we do it this way to avoid prototyping
450 ** String descriptors are byte arrays and work like this:
452 ** sizeofstring,offset_from_start_array_to_start_of_string
453 ** sizeofstring,offset_from_start_array_to_start_of_string
461 ** The number of strings depends on the qualifier flags
462 ** set in the keymap type.
465 CONST UBYTE f1_descr
[] =
474 CONST UBYTE f2_descr
[] =
483 CONST UBYTE f3_descr
[] =
492 CONST UBYTE f4_descr
[] =
501 CONST UBYTE f5_descr
[] =
510 CONST UBYTE f6_descr
[] =
519 CONST UBYTE f7_descr
[] =
528 CONST UBYTE f8_descr
[] =
537 CONST UBYTE f9_descr
[] =
546 CONST UBYTE f10_descr
[] =
555 CONST UBYTE f11_descr
[] =
564 CONST UBYTE f12_descr
[] =
573 CONST UBYTE insert_descr
[] =
582 CONST UBYTE pageup_descr
[] =
591 CONST UBYTE pagedown_descr
[] =
600 CONST UBYTE pausebreak_descr
[] =
609 CONST UBYTE home_descr
[] =
618 CONST UBYTE end_descr
[] =
627 CONST UBYTE up_descr
[] =
636 CONST UBYTE down_descr
[] =
645 CONST UBYTE left_descr
[] =
654 CONST UBYTE right_descr
[] =
663 CONST UBYTE tab_descr
[] =
672 CONST UBYTE help_descr
[] =
679 STATIC CONST UBYTE space_descr
[] =
684 ' ', '´' /*0xB4*/, '`','^','~', '¨' /*0xA8*/, '°' /*0xB0*/
687 static CONST IPTR hikeymap
[] =
689 DEAD(space_descr
), /* 40 SPACE */
690 BYTES(8, 8, 8, 8), /* 41 BACKSPACE*/
691 STRING(tab_descr
), /* 42 TAB */
692 BYTES(13, 13, 13, 13), /* 43 ENTER */
693 BYTES(0, 0, 10, 13), /* 44 RETURN */
694 BYTES(0, 0, 0x9B, 27), /* 45 ESCAPE */
695 BYTES(127, 127, 127, 127), /* 46 DEL */
696 STRING(insert_descr
), /* 47 INSERT ?? */
697 STRING(pageup_descr
), /* 48 PAGEUP ?? */
698 STRING(pagedown_descr
), /* 49 PAGEDOWN ?? */
699 BYTES('-', '-', '-', '-'), /* 4A NUMPAD - */
700 STRING(f11_descr
), /* 4B F11 ?? */
701 STRING(up_descr
), /* 4C CURSOR UP*/
702 STRING(down_descr
), /* 4D CURSOR DOWN*/
703 STRING(right_descr
), /* 4E CURSOR RIGHT */
704 STRING(left_descr
), /* 4F CURSOR LEFT */
705 STRING(f1_descr
), /* 50 F1 */
706 STRING(f2_descr
), /* 51 */
707 STRING(f3_descr
), /* 52 */
708 STRING(f4_descr
), /* 53 */
709 STRING(f5_descr
), /* 54 */
710 STRING(f6_descr
), /* 55 */
711 STRING(f7_descr
), /* 56 */
712 STRING(f8_descr
), /* 57 */
713 STRING(f9_descr
), /* 58 */
714 STRING(f10_descr
), /* 59 */
715 BYTES('[', '(', '[', '('), /* 5A */
716 BYTES(']', ')', ']', ')'), /* 5B */
717 BYTES('/', '/', '/', '/'), /* 5C */
718 BYTES('*', '*', '*', '*'), /* 5D */
719 BYTES('+', '+', '+', '+'), /* 5E */
720 STRING(help_descr
), /* 5F HELP */
721 BYTES(0, 0, 0, 0), /* 60 */
722 BYTES(0, 0, 0, 0), /* 61 */
723 BYTES(0, 0, 0, 0), /* 62 */
724 BYTES(0, 0, 0, 0), /* 63 */
725 BYTES(0, 0, 0, 0), /* 64 */
726 BYTES(0, 0, 0, 0), /* 65 */
727 BYTES(0, 0, 0, 0), /* 66 */
728 BYTES(0, 0, 0, 0), /* 67 */
729 BYTES(0, 0, 0, 0), /* 68 */
730 BYTES(0, 0, 0, 0), /* 69 */
731 BYTES(0, 0, 0, 0), /* 6A */
732 BYTES(0, 0, 0, 0), /* 6B */
733 BYTES(0, 0, 0, 0), /* 6C */
734 BYTES(0, 0, 0, 0), /* 6D */
735 STRING(pausebreak_descr
), /* 6E PAUSE/BREAK ?? */
736 STRING(f12_descr
), /* 6F F12 ?? */
737 STRING(home_descr
), /* 70 HOME ?? */
738 STRING(end_descr
), /* 71 END ?? */
739 BYTES(0, 0, 0, 0), /* 72 */
740 BYTES(0, 0, 0, 0), /* 73 */
741 BYTES(0, 0, 0, 0), /* 74 */
742 BYTES(0, 0, 0, 0), /* 75 */
743 BYTES(0, 0, 0, 0), /* 76 */
744 BYTES(0, 0, 0, 0), /* 77 */
745 BYTES(0, 0, 0, 0), /* 78 */
746 BYTES(0, 0, 0, 0), /* 79 */
747 BYTES(0, 0, 0, 0), /* 7A */
748 BYTES(0, 0, 0, 0), /* 7B */
749 BYTES(0, 0, 0, 0), /* 7C */
750 BYTES(0, 0, 0, 0), /* 7D */
751 BYTES(0, 0, 0, 0), /* 7E */
752 BYTES(0, 0, 0, 0), /* 7F */
757 #define SETBITS(b0, b1, b2, b3, b4, b5, b6, b7) \
758 (b0<<0)|(b1<<1)|(b2<<2)|(b3<<3)|(b4<<4)|(b5<<5)|(b6<<6)|(b7<<7)
760 static CONST UBYTE locapsable
[] =
762 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 00 - 07 */
763 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 08 - 0F */
765 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 10 - 17 */
766 SETBITS(1, 1, 0, 0, 0, 0, 0, 0), /* 18 - 1F */
768 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 20 - 27 */
769 SETBITS(1, 0, 0, 0, 0, 0, 0, 0), /* 28 - 2F */
771 SETBITS(0, 1, 1, 1, 1, 1, 1, 1), /* 30 - 37 */
772 SETBITS(0, 0, 0, 0, 0, 0, 0, 0) /* 38 - 3F */
775 static CONST UBYTE hicapsable
[] =
777 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 40 - 47 */
778 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 48 - 4F */
780 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 50 - 57 */
781 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 58 - 5F */
783 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 60 - 67 */
784 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 68 - 6F */
786 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 70 - 77 */
787 SETBITS(0, 0, 0, 0, 0, 0, 0, 0) /* 78 - 7F */
790 static CONST UBYTE lorepeatable
[] =
792 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 00 - 07 */
793 SETBITS(1, 1, 1, 1, 1, 1, 0, 1), /* 08 - 0F */
795 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 10 - 17 */
796 SETBITS(1, 1, 1, 1, 0, 1, 1, 1), /* 18 - 1F */
798 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 20 - 27 */
799 SETBITS(1, 1, 1, 1, 0, 1, 1, 1), /* 28 - 2F */
801 SETBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 30 - 37 */
802 SETBITS(1, 1, 1, 0, 1, 1, 1, 1) /* 38 - 3F */
805 static CONST UBYTE hirepeatable
[] =
807 SETBITS(1, 1, 1, 0, 0, 0, 1, 0), /* 40 - 47 */
808 SETBITS(1, 1, 0, 0, 1, 1, 1, 1), /* 48 - 4F */
810 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 50 - 57 */
811 SETBITS(0, 0, 1, 1, 1, 1, 1, 0), /* 58 - 5F */
813 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 60 - 67 */
814 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 68 - 6F */
816 SETBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 70 - 77 */
817 SETBITS(0, 0, 0, 0, 0, 0, 0, 0) /* 78 - 7F */
820 CONST
struct KeyMap def_km
=
833 /* index vertically: (keytype & KC_VANILLA)
834 ** index horizontally: KCF_xxx qualifier combination for keypress.
835 ** Which is used to get the index of the byte describing the keypress.
836 ** X means invalid key.
837 ** S means Ctrl-c alike combination (clear bits 5 and 6)
839 #undef X /* undefined */
840 #undef S /* Ctrl-c like combo */
846 /* stegerg: on the Amiga you get a key event if you
847 press for example CONTROL + A, even if
848 the keymaptype for that key has not set
849 KCF_CONTROL. So it looks like if for a
850 certain keypress some qualifiers are set
851 which are not set in the keymap-type then
852 this qualifiers are simply to be ignored
855 const BYTE keymaptype_table
[8][8] =
857 {3, 3, 3, 3, 3, 3, 3, 3}, /* KCF_NOQUAL == 0 */
858 {3, 2, 3, 2, 3, 2, 3, 2}, /* KCF_SHIFT == 1 */
859 {3, 3, 2, 2, 3, 3, 2, 2}, /* KCF_ALT == 2 */
860 {3, 2, 1, 0, 3, 2, 1, 0}, /* KCF_SHIFT|KCF_ALT == 3 */
861 {3, 3, 3, 3, 2, 2, 2, 2}, /* KCF_CONTROL == 4 */
862 {3, 2, 3, 2, 1, 0, 1, 0}, /* KCF_SHIFT|KCF_CONTROL == 5 */
863 {3, 3, 2, 2, 1, 1, 0, 0}, /* KCF_ALT|KCF_CONTROL == 6 */
864 {3, 2, 1, 0, S
, X
, X
, X
} /* KCF_SHIFT|KCF_ALT|KCF_CONTROL == KC__VANILLA == 7 */
870 const BYTE keymaptype_table
[8][8] =
872 {3, X
, X
, X
, X
, X
, X
, X
}, /* KCF_NOQUAL == 0 */
873 {3, 2, X
, X
, X
, X
, X
, X
}, /* KCF_SHIFT == 1 */
874 {3, X
, 2, X
, X
, X
, X
, X
}, /* KCF_ALT == 2 */
875 {3, 2, 1, 0, X
, X
, X
, X
}, /* KCF_SHIFT|KCF_ALT == 3 */
876 {3, X
, X
, X
, 2, X
, X
, X
}, /* KCF_CONTROL == 4 */
877 {3, 2, X
, X
, 1, 0, X
, X
}, /* KCF_SHIFT|KCF_CONTROL == 5 */
878 {3, X
, 2, X
, 1, X
, 0, X
}, /* KCF_ALT|KCF_CONTROL == 6 */
879 {3, 2, 1, 0, S
, X
, X
, X
} /* KCF_SHIFT|KCF_ALT|KCF_CONTROL == KC__VANILLA == 7 */
886 /* index vertically: (keytype & KC_VANILLA)
887 ** index horizontally: KCF_xxx qualifier combination for keypress.
888 ** Used to get the number of the string descriptor,
889 ** depending on the KCF_SHIFT, KCF_ALT and KCF_CONTROL qualifiers
890 ** of the key pressed
895 /* stegerg: see comment before keymaptype_table */
897 const BYTE keymapstr_table
[8][8] =
899 {0, 0, 0, 0, 0, 0, 0, 0}, /* KCF_NOQUAL == 0 */
900 {0, 1, 0, 1, 0, 1, 0, 1}, /* KCF_SHIFT == 1 */
901 {0, 0, 1, 1, 0, 0, 1, 1}, /* KCF_ALT == 2 */
902 {0, 1, 2, 3, 0, 1, 2, 3}, /* KCF_SHIFT|KCF_ALT == 3 */
903 {0, 0, 0, 0, 1, 1, 1, 1}, /* KCF_CONTROL == 4 */
904 {0, 1, 0, 1, 2, 3, 2, 3}, /* KCF_SHIFT|KCF_CONTROL == 5 */
905 {0, 0, 1, 1, 2, 2, 3, 3}, /* KCF_ALT|KCF_CONTROL == 6 */
906 {0, 1, 2, 3, 4, 5, 6, 7} /* KCF_SHIFT|KCF_ALT|KCF_CONTROL == KC__VANILLA == 7 */
910 const BYTE keymapstr_table
[8][8] =
912 {0, X
, X
, X
, X
, X
, X
, X
}, /* KCF_NOQUAL == 0 */
913 {0, 1, X
, X
, X
, X
, X
, X
}, /* KCF_SHIFT == 1 */
914 {0, X
, 1, X
, X
, X
, X
, X
}, /* KCF_ALT == 2 */
915 {0, 1, 2, 3, X
, X
, X
, X
}, /* KCF_SHIFT|KCF_ALT == 3 */
916 {0, X
, X
, X
, 1, X
, X
, X
}, /* KCF_CONTROL == 4 */
917 {0, 1, X
, X
, 2, 3, X
, X
}, /* KCF_SHIFT|KCF_CONTROL == 5 */
918 {0, X
, 1, X
, 2, X
, 3, X
}, /* KCF_ALT|KCF_CONTROL == 6 */
919 {0, 1, 2, 3, 4, 5, 6, 7} /* KCF_SHIFT|KCF_ALT|KCF_CONTROL == KC__VANILLA == 7 */