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