xref: /netbsd/sys/arch/atari/dev/kbdmap.c (revision bf9ec67e)
1 /*	$NetBSD: kbdmap.c,v 1.3 1996/05/15 07:29:07 leo Exp $	*/
2 
3 /*
4  * Copyright (c) 1995 Leo Weppelman.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by Leo Weppelman.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #include <atari/dev/kbdmap.h>
34 
35 /* define a default keymap. This can be changed by keyboard ioctl's
36    (later at least..) */
37 
38 /* mode shortcuts: */
39 #define	S KBD_MODE_STRING
40 #define C KBD_MODE_CAPS
41 #define K KBD_MODE_KPAD
42 
43 struct kbdmap ascii_kbdmap = {
44 	/* normal map */
45 	{
46 /* 0x00 */	{ 0, 0    },	{ 0, ESC  },	{ 0, '1'  },	{ 0, '2'  },
47 /* 0x04 */	{ 0, '3'  },	{ 0, '4'  },	{ 0, '5'  },	{ 0, '6'  },
48 /* 0x08 */	{ 0, '7'  },	{ 0, '8'  },	{ 0, '9'  },	{ 0, '0'  },
49 /* 0x0c */	{ 0, '-'  },	{ 0, '='  },	{ 0, '\b' },	{ 0, '\t' },
50 /* 0x10	*/	{ C, 'q'  },	{ C, 'w'  },	{ C, 'e'  },	{ C, 'r'  },
51 /* 0x14 */	{ C, 't'  },	{ C, 'y'  },	{ C, 'u'  },	{ C, 'i'  },
52 /* 0x18 */	{ C, 'o'  },	{ C, 'p'  },	{ 0, '['  },	{ 0, ']'  },
53 /* 0x1c */	{ 0, '\r' },	{ 0, 0    },	{ C, 'a'  },	{ C, 's'  },
54 /* 0x20 */	{ C, 'd'  },	{ C, 'f'  },	{ C, 'g'  },	{ C, 'h'  },
55 /* 0x24 */	{ C, 'j'  },	{ C, 'k'  },	{ C, 'l'  },	{ 0, ';'  },
56 #ifdef US_KBD
57 /* 0x28 */	{ 0, '\'' },	{ 0, '`'  },	{ 0, 0    },	{ 0, '\\' },
58 #else
59 /* 0x28 */	{ 0, '\'' },	{ 0, '`'  },	{ 0, 0    },	{ 0, '#'  },
60 #endif
61 /* 0x2c */	{ C, 'z'  },	{ C, 'x'  },	{ C, 'c'  },	{ C, 'v'  },
62 /* 0x30 */	{ C, 'b'  },	{ C, 'n'  },	{ C, 'm'  },	{ 0, ','  },
63 /* 0x34 */	{ 0, '.'  },	{ 0, '/'  },	{ 0, 0    },	{ 0, 0    },
64 /* 0x38 */	{ 0, 0    },	{ 0, ' '  },	{ 0, 0    },	{ S, 0x10 },
65 /* 0x3c */	{ S, 0x15 },	{ S, 0x1A },	{ S, 0x1F },	{ S, 0x24 },
66 /* 0x40 */	{ S, 0x29 },	{ S, 0x2E },	{ S, 0x33 },	{ S, 0x38 },
67 /* 0x44 */	{ S, 0x3D },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
68 /* 0x48 */	{ S, 0x00 },	{ 0, 0    },	{ 0, '-'  },	{ S, 0x0C },
69 /* 0x4c */	{ 0, 0    },	{ S, 0x08 },	{ 0, '+'  },	{ 0, 0    },
70 /* 0x50 */	{ S, 0x04 },	{ 0, 0    },	{ 0, 0    },	{ 0, DEL  },
71 /* 0x54 */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
72 /* 0x58 */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
73 /* 0x5c */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
74 #ifdef US_KBD
75 /* 0x60 */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, '('  },
76 #else
77 /* 0x60 */	{ 0, '\\' },	{ 0, 0    },	{ 0, 0    },	{ 0, '('  },
78 #endif
79 /* 0x64 */	{ 0, ')'  },	{ 0, '/'  },	{ 0, '*'  },	{ K, '7'  },
80 /* 0x68 */	{ K, '8'  },	{ K, '9'  },	{ K, '4'  },	{ K, '5'  },
81 /* 0x6c */	{ K, '6'  },	{ K, '1'  },	{ K, '2'  },	{ K, '3'  },
82 /* 0x70 */	{ K, '0'  },	{ K, '.'  },	{ K, '\r' },	{ 0, 0    },
83 /* 0x74 */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
84 /* 0x78 */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
85 /* 0x7c */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    }
86 },
87 	/* shifted map */
88 	{
89 #ifdef US_KBD
90 /* 0x00 */	{ 0, 0    },	{ 0, ESC  },	{ 0, '!'  },	{ 0, '@'  },
91 #else
92 /* 0x00 */	{ 0, 0    },	{ 0, ESC  },	{ 0, '!'  },	{ 0, '"'  },
93 #endif
94 /* 0x04 */	{ 0, '#'  },	{ 0, '$'  },	{ 0, '%'  },	{ 0, '^'  },
95 /* 0x08 */	{ 0, '&'  },	{ 0, '*'  },	{ 0, '('  },	{ 0, ')'  },
96 /* 0x0c */	{ 0, '_'  },	{ 0, '+'  },	{ 0, '\b' },	{ 0, '\t' },
97 /* 0x10	*/	{ C, 'Q'  },	{ C, 'W'  },	{ C, 'E'  },	{ C, 'R'  },
98 /* 0x14 */	{ C, 'T'  },	{ C, 'Y'  },	{ C, 'U'  },	{ C, 'I'  },
99 /* 0x18 */	{ C, 'O'  },	{ C, 'P'  },	{ 0, '{'  },	{ 0, '}'  },
100 /* 0x1c */	{ 0, '\r' },	{ 0, 0    },	{ C, 'A'  },	{ C, 'S'  },
101 /* 0x20 */	{ C, 'D'  },	{ C, 'F'  },	{ C, 'G'  },	{ C, 'H'  },
102 /* 0x24 */	{ C, 'J'  },	{ C, 'K'  },	{ C, 'L'  },	{ 0, ':'  },
103 #ifdef US_KBD
104 /* 0x28 */	{ 0, '"'  },	{ 0, '~'  },	{ 0, 0    },	{ 0, '|'  },
105 #else
106 /* 0x28 */	{ 0, '@'  },	{ 0, '_'  },	{ 0, 0    },	{ 0, '~'  },
107 #endif
108 /* 0x2c */	{ C, 'Z'  },	{ C, 'X'  },	{ C, 'C'  },	{ C, 'V'  },
109 /* 0x30 */	{ C, 'B'  },	{ C, 'N'  },	{ C, 'M'  },	{ 0, '<'  },
110 /* 0x34 */	{ 0, '>'  },	{ 0, '?'  },	{ 0, 0    },	{ 0, 0    },
111 /* 0x38 */	{ 0, 0    },	{ 0, ' '  },	{ 0, 0    },	{ S, 0x5d },
112 /* 0x3c */	{ S, 0x63 },	{ S, 0x69 },	{ S, 0x6F },	{ S, 0x75 },
113 /* 0x40 */	{ S, 0x7b },	{ S, 0x81 },	{ S, 0x87 },	{ S, 0x8d },
114 /* 0x44 */	{ S, 0x93 },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
115 /* 0x48 */	{ S, 0x47 },	{ 0, 0    },	{ 0, '-'  },	{ S, 0x57 },
116 /* 0x4c */	{ 0, 0    },	{ S, 0x51 },	{ 0, '+'  },	{ 0, 0    },
117 /* 0x50 */	{ S, 0x4c },	{ 0, 0    },	{ 0, 0    },	{ 0, DEL  },
118 /* 0x54 */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
119 /* 0x58 */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
120 /* 0x5c */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
121 /* 0x60 */
122 #ifdef US_KBD
123 /* 0x60 */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, '('  },
124 #else
125 /* 0x60 */	{ 0, '|'  },	{ 0, 0    },	{ 0, 0    },	{ 0, '('  },
126 #endif
127 /* 0x64 */	{ 0, ')'  },	{ 0, '/'  },	{ 0, '*'  },	{ K, '7'  },
128 /* 0x68 */	{ K, '8'  },	{ K, '9'  },	{ K, '4'  },	{ K, '5'  },
129 /* 0x6c */	{ K, '6'  },	{ K, '1'  },	{ K, '2'  },	{ K, '3'  },
130 /* 0x70 */	{ K, '0'  },	{ K, '.'  },	{ K, '\r' },	{ 0, 0    },
131 /* 0x74 */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
132 /* 0x78 */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },
133 /* 0x7c */	{ 0, 0    },	{ 0, 0    },	{ 0, 0    },	{ 0, 0    }
134 	},
135 
136 	/* alt map FIXME: No altmap yet.. */
137 	{
138 		{ 0, 0    }
139 	},
140 
141 	/* shift alt map FIXME: No shift altmap yet... */
142 	{
143 		{ 0, 0    }
144 	},
145 
146 	{
147 	  /* string table. If there's a better way to get the offsets into the
148 	     above table, please tell me..
149 
150 	     NOTE: save yourself and others a lot of grief by *not* using
151 	           CSI == 0x9b, using the two-character sequence gives
152 	           much less trouble, especially in GNU-Emacs.. */
153 
154 	  3, ESC, '[', 'A',		/* 0x00: CRSR UP */
155 	  3, ESC, '[', 'B',		/* 0x04: CRSR DOWN */
156 	  3, ESC, '[', 'C',		/* 0x08: CRSR RIGHT */
157 	  3, ESC, '[', 'D',		/* 0x0C: CRSR LEFT */
158 	  4, ESC, '[', '0', '~',	/* 0x10: F1 */
159 	  4, ESC, '[', '1', '~',	/* 0x15: F2 */
160 	  4, ESC, '[', '2', '~',	/* 0x1A: F3 */
161 	  4, ESC, '[', '3', '~',	/* 0x1F: F4 */
162 	  4, ESC, '[', '4', '~',	/* 0x24: F5 */
163 	  4, ESC, '[', '5', '~',	/* 0x29: F6 */
164 	  4, ESC, '[', '6', '~',	/* 0x2E: F7 */
165 	  4, ESC, '[', '7', '~',	/* 0x33: F8 */
166 	  4, ESC, '[', '8', '~',	/* 0x38: F9 */
167 	  4, ESC, '[', '9', '~',	/* 0x3D: F10 */
168 	  4, ESC, '[', '?', '~',	/* 0x42: HELP */
169 
170 	  4, ESC, '[', 'T', '~',	/* 0x47: shift CRSR UP */
171 	  4, ESC, '[', 'S', '~',	/* 0x4C: shift CRSR DOWN */
172 	  5, ESC, '[', ' ', '@', '~',	/* 0x51: shift CRSR RIGHT */
173 	  5, ESC, '[', ' ', 'A', '~',	/* 0x57: shift CRSR LEFT */
174 	  5, ESC, '[', '1', '0', '~',	/* 0x5D: shift F1 */
175 	  5, ESC, '[', '1', '1', '~',	/* 0x63: shift F2 */
176 	  5, ESC, '[', '1', '2', '~',	/* 0x69: shift F3 */
177 	  5, ESC, '[', '1', '3', '~',	/* 0x6F: shift F4 */
178 	  5, ESC, '[', '1', '4', '~',	/* 0x75: shift F5 */
179 	  5, ESC, '[', '1', '5', '~',	/* 0x7B: shift F6 */
180 	  5, ESC, '[', '1', '6', '~',	/* 0x81: shift F7 */
181 	  5, ESC, '[', '1', '7', '~',	/* 0x87: shift F8 */
182 	  5, ESC, '[', '1', '8', '~',	/* 0x8D: shift F9 */
183 	  5, ESC, '[', '1', '9', '~',	/* 0x93: shift F10 */
184 	  3, ESC, '[', 'Z',		/* 0x99: shift TAB */
185 	  2, ESC, '[',			/* 0x9d: alt ESC == CSI */
186 	},
187 };
188 
189 unsigned char acctable[KBD_NUM_ACC][64] = {
190   {	"@�BCD�FGH�JKLMN�PQRST�VWXYZ[\\]^_"
191 	"`�bcd�fgh�jklmn�pqrst�vwxyz{|}~\177"},	/* KBD_ACC_GRAVE */
192 
193   {	"@�BCD�FGH�JKLMN�PQRST�VWXYZ[\\]^_"
194 	"`�bcd�fgh�jklmn�pqrst�vwxyz{|}~\177"},	/* KBD_ACC_ACUTE */
195 
196   {	"@�BCD�FGH�JKLMN�PQRST�VWXYZ[\\]^_"
197 	"`�bcd�fgh�jklmn�pqrst�vwxyz{|}~\177"},	/* KBD_ACC_CIRC */
198 
199   {	"@�BCDEFGHIJKLM��PQRSTUVWXYZ[\\]^_"
200 	"`�bcdefghijklm��pqrstuvwxyz{|}~\177"},	/* KBD_ACC_TILDE */
201 
202   {	"@�BCD�FGH�JKLMN�PQRST�VWXYZ[\\]^_"
203 	"`�bcd�fgh�jklmn�pqrst�vwxyz{|}~\177"},	/* KBD_ACC_DIER */
204 };
205 
206 
207