sw-kbdmap.c revision 1.1 1 /* $NetBSD: sw-kbdmap.c,v 1.1 1996/01/28 20:19:51 chopps Exp $ */
2
3 /*
4 * Copyright (c) 1993 Markus Wild
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 Markus Wild.
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 #include <amiga/dev/kbdmap.h>
33
34 /* define a default keymap. This can be changed by keyboard ioctl's
35 (later at least..) */
36 /*
37 * Modified to standard swedish keyboard layout by Stefan Pedersen
38 * di4ped (at) cse.hks.se 960103
39 */
40
41 /* mode shortcuts: */
42 #define S KBD_MODE_STRING
43 #define DG (KBD_MODE_DEAD | KBD_MODE_GRAVE)
44 #define DA (KBD_MODE_DEAD | KBD_MODE_ACUTE)
45 #define DC (KBD_MODE_DEAD | KBD_MODE_CIRC)
46 #define DT (KBD_MODE_DEAD | KBD_MODE_TILDE)
47 #define DD (KBD_MODE_DEAD | KBD_MODE_DIER)
48 #define C KBD_MODE_CAPS
49 #define K KBD_MODE_KPAD
50
51 struct kbdmap kbdmap;
52 struct kbdmap ascii_kbdmap = {
53 /* normal map */
54 {
55 0, '`', /* 0x00 */
56 0, '1',
57 0, '2',
58 0, '3',
59 0, '4',
60 0, '5',
61 0, '6',
62 0, '7',
63 0, '8', /* 0x08 */
64 0, '9',
65 0, '0',
66 0, '+',
67 0, '\'',
68 0, '\\',
69 0, 0,
70 K, '0',
71 C, 'q', /* 0x10 */
72 C, 'w',
73 C, 'e',
74 C, 'r',
75 C, 't',
76 C, 'y',
77 C, 'u',
78 C, 'i',
79 C, 'o', /* 0x18 */
80 C, 'p',
81 C, '',
82 0, ']',
83 0, 0,
84 K, '1',
85 K, '2',
86 K, '3',
87 C, 'a', /* 0x20 */
88 C, 's',
89 C, 'd',
90 C, 'f',
91 C, 'g',
92 C, 'h',
93 C, 'j',
94 C, 'k',
95 C, 'l', /* 0x28 */
96 C, '',
97 C, '',
98 C, '\'',
99 0, 0,
100 K, '4',
101 K, '5',
102 K, '6',
103 0, '<', /* 0x30 */
104 C, 'z',
105 C, 'x',
106 C, 'c',
107 C, 'v',
108 C, 'b',
109 C, 'n',
110 C, 'm',
111 0, ',', /* 0x38 */
112 0, '.',
113 0, '-',
114 0, 0,
115 K, '.',
116 K, '7',
117 K, '8',
118 K, '9',
119 0, ' ', /* 0x40 */
120 0, DEL, /* really BS, DEL & BS swapped */
121 0, '\t',
122 K, '\r', /* enter */
123 0, '\r', /* return */
124 0, ESC,
125 0, '\b', /* really DEL, BS & DEL swapped */
126 0, 0,
127 0, 0, /* 0x48 */
128 0, 0,
129 0, '-',
130 0, 0,
131 S, 0x00, /* now it gets hairy.. CRSR UP */
132 S, 0x04, /* CRSR DOWN */
133 S, 0x08, /* CRSR RIGHT */
134 S, 0x0C, /* CRSR LEFT */
135 S, 0x10, /* 0x50 F1 */
136 S, 0x15, /* F2 */
137 S, 0x1A, /* F3 */
138 S, 0x1F, /* F4 */
139 S, 0x24, /* F5 */
140 S, 0x29, /* F6 */
141 S, 0x2E, /* F7 */
142 S, 0x33, /* 0x58 F8 */
143 S, 0x38, /* F9 */
144 S, 0x3D, /* F10 */
145 K, '[',
146 K, ']',
147 K, '/',
148 K, '*',
149 S, 0x42, /* HELP */
150 },
151
152 /* shifted map */
153 {
154 0, '~', /* 0x00 */
155 0, '!',
156 0, '\"',
157 0, '#',
158 0, '$',
159 0, '%',
160 0, '&',
161 0, '/',
162 0, '(', /* 0x08 */
163 0, ')',
164 0, '=',
165 0, '?',
166 0, '`',
167 0, '|',
168 0, 0,
169 K, '0',
170 C, 'Q', /* 0x10 */
171 C, 'W',
172 C, 'E',
173 C, 'R',
174 C, 'T',
175 C, 'Y',
176 C, 'U',
177 C, 'I',
178 C, 'O', /* 0x18 */
179 C, 'P',
180 C, '',
181 C, '^',
182 0, 0,
183 K, '1',
184 K, '2',
185 K, '3',
186 C, 'A', /* 0x20 */
187 C, 'S',
188 C, 'D',
189 C, 'F',
190 C, 'G',
191 C, 'H',
192 C, 'J',
193 C, 'K',
194 C, 'L', /* 0x28 */
195 C, '',
196 C, '',
197 C, '*',
198 0, 0,
199 K, '4',
200 K, '5',
201 K, '6',
202 0, '>', /* 0x30 */
203 C, 'Z',
204 C, 'X',
205 C, 'C',
206 C, 'V',
207 C, 'B',
208 C, 'N',
209 C, 'M',
210 0, ';', /* 0x38 */
211 0, ':',
212 0, '_',
213 0, 0,
214 K, '.',
215 K, '7',
216 K, '8',
217 K, '9',
218 0, ' ', /* 0x40 */
219 0, DEL, /* really BS, DEL & BS swapped */
220 S, 0x99, /* shift TAB */
221 K, '\r', /* enter */
222 0, '\r', /* return */
223 0, ESC,
224 0, '\b', /* really DEL, BS & DEL swapped */
225 0, 0,
226 0, 0, /* 0x48 */
227 0, 0,
228 K, '-',
229 0, 0,
230 S, 0x47, /* shift CRSR UP */
231 S, 0x4C, /* shift CRSR DOWN */
232 S, 0x51, /* shift CRSR RIGHT */
233 S, 0x57, /* shift CRSR LEFT */
234 S, 0x5D, /* 0x50 shift F1 */
235 S, 0x63, /* shift F2 */
236 S, 0x69, /* shift F3 */
237 S, 0x6F, /* shift F4 */
238 S, 0x75, /* shift F5 */
239 S, 0x7B, /* shift F6 */
240 S, 0x81, /* shift F7 */
241 S, 0x87, /* 0x58 shift F8 */
242 S, 0x8D, /* shift F9 */
243 S, 0x93, /* shift F10 */
244 K, '{',
245 K, '}',
246 K, '/',
247 K, '*',
248 S, 0x42, /* HELP (no special shift code) */
249 },
250
251
252 /* alt map */
253 {
254 0, '`', /* 0x00 */
255 0, '',
256 0, '',
257 0, '',
258 0, '',
259 0, '',
260 0, '',
261 0, '',
262 0, '', /* 0x08 */
263 0, '',
264 0, '',
265 0, '-',
266 0, '=',
267 0, '\\',
268 0, 0,
269 K, '0',
270 C, '', /* 0x10 */
271 0, '',
272 0, '',
273 0, '',
274 C, '',
275 0, '',
276 0, '',
277 0, '',
278 C, '', /* 0x18 */
279 0, '',
280 0, '[',
281 0, ']',
282 0, 0,
283 K, '1',
284 K, '2',
285 K, '3',
286 C, '', /* 0x20 */
287 0, '',
288 C, '',
289 DA, '',
290 DG, '`',
291 DC, '^',
292 DT, '~',
293 DD, '',
294 0, '', /* 0x28 */
295 0, ',',
296 0, '\'',
297 0, 0,
298 0, 0,
299 K, '4',
300 K, '5',
301 K, '6',
302 0, 0, /* 0x30 */
303 0, '',
304 0, '',
305 C, '',
306 0, '',
307 0, '',
308 0, '',
309 0, '',
310 0, ',', /* 0x38 */
311 0, '.',
312 0, '/',
313 0, 0,
314 K, '.',
315 K, '7',
316 K, '8',
317 K, '9',
318 0, ' ', /* 0x40 */
319 0, DEL, /* really BS, DEL & BS swapped */
320 0, '\t',
321 K, '\r', /* enter */
322 0, '\r', /* return */
323 S, 0x9d, /* CSI */
324 0, '\b', /* really DEL, BS & DEL swapped */
325 0, 0,
326 0, 0, /* 0x48 */
327 0, 0,
328 K, '-',
329 0, 0,
330 S, 0x00, /* now it gets hairy.. CRSR UP */
331 S, 0x04, /* CRSR DOWN */
332 S, 0x08, /* CRSR RIGHT */
333 S, 0x0C, /* CRSR LEFT */
334 S, 0x10, /* 0x50 F1 */
335 S, 0x15, /* F2 */
336 S, 0x1A, /* F3 */
337 S, 0x1F, /* F4 */
338 S, 0x24, /* F5 */
339 S, 0x29, /* F6 */
340 S, 0x2E, /* F7 */
341 S, 0x33, /* 0x58 F8 */
342 S, 0x38, /* F9 */
343 S, 0x3D, /* F10 */
344 K, '(',
345 K, ')',
346 K, '/',
347 K, '*',
348 S, 0x42, /* HELP */
349 },
350
351 /* shift alt map */
352 {
353 0, '~', /* 0x00 */
354 0, '!',
355 0, '@',
356 0, '#',
357 0, '$',
358 0, '%',
359 0, '^',
360 0, '&',
361 0, '*', /* 0x08 */
362 0, '(',
363 0, ')',
364 0, '_',
365 0, '+',
366 0, '|',
367 0, 0,
368 K, '0',
369 C, '', /* 0x10 */
370 0, '',
371 0, '',
372 0, '',
373 C, '',
374 0, '',
375 0, '',
376 0, '',
377 C, '', /* 0x18 */
378 0, '',
379 0, '[',
380 0, ']',
381 0, 0,
382 K, '1',
383 K, '2',
384 K, '3',
385 C, '', /* 0x20 */
386 0, '',
387 C, '',
388 DA, '',
389 DG, '`',
390 DC, '^',
391 DT, '~',
392 DD, '',
393 0, '', /* 0x28 */
394 0, ':',
395 0, '\"',
396 0, 0,
397 0, 0,
398 K, '4',
399 K, '5',
400 K, '6',
401 0, 0, /* 0x30 */
402 0, '',
403 0, '',
404 C, '',
405 0, '',
406 0, '',
407 0, '',
408 0, '',
409 0, '<', /* 0x38 */
410 0, '>',
411 0, '?',
412 0, 0,
413 K, '.',
414 K, '7',
415 K, '8',
416 K, '9',
417 0, ' ', /* 0x40 */
418 0, DEL, /* really BS, DEL & BS swapped */
419 0, '\t',
420 K, '\r', /* enter */
421 0, '\r', /* return */
422 S, 0x9d, /* CSI */
423 0, '\b', /* really DEL, BS & DEL swapped */
424 0, 0,
425 0, 0, /* 0x48 */
426 0, 0,
427 K, '-',
428 0, 0,
429 S, 0x00, /* now it gets hairy.. CRSR UP */
430 S, 0x04, /* CRSR DOWN */
431 S, 0x08, /* CRSR RIGHT */
432 S, 0x0C, /* CRSR LEFT */
433 S, 0x10, /* 0x50 F1 */
434 S, 0x15, /* F2 */
435 S, 0x1A, /* F3 */
436 S, 0x1F, /* F4 */
437 S, 0x24, /* F5 */
438 S, 0x29, /* F6 */
439 S, 0x2E, /* F7 */
440 S, 0x33, /* 0x58 F8 */
441 S, 0x38, /* F9 */
442 S, 0x3D, /* F10 */
443 K, '(',
444 K, ')',
445 K, '/',
446 K, '*',
447 S, 0x42, /* HELP */
448 },
449
450 {
451 /* string table. If there's a better way to get the offsets into the
452 above table, please tell me..
453
454 NOTE: save yourself and others a lot of grief by *not* using
455 CSI == 0x9b, using the two-character sequence gives
456 much less trouble, especially in GNU-Emacs.. */
457
458 3, ESC, '[', 'A', /* 0x00: CRSR UP */
459 3, ESC, '[', 'B', /* 0x04: CRSR DOWN */
460 3, ESC, '[', 'C', /* 0x08: CRSR RIGHT */
461 3, ESC, '[', 'D', /* 0x0C: CRSR LEFT */
462 4, ESC, '[', '0', '~', /* 0x10: F1 */
463 4, ESC, '[', '1', '~', /* 0x15: F2 */
464 4, ESC, '[', '2', '~', /* 0x1A: F3 */
465 4, ESC, '[', '3', '~', /* 0x1F: F4 */
466 4, ESC, '[', '4', '~', /* 0x24: F5 */
467 4, ESC, '[', '5', '~', /* 0x29: F6 */
468 4, ESC, '[', '6', '~', /* 0x2E: F7 */
469 4, ESC, '[', '7', '~', /* 0x33: F8 */
470 4, ESC, '[', '8', '~', /* 0x38: F9 */
471 4, ESC, '[', '9', '~', /* 0x3D: F10 */
472 4, ESC, '[', '?', '~', /* 0x42: HELP */
473
474 4, ESC, '[', 'T', '~', /* 0x47: shift CRSR UP */
475 4, ESC, '[', 'S', '~', /* 0x4C: shift CRSR DOWN */
476 5, ESC, '[', ' ', '@', '~', /* 0x51: shift CRSR RIGHT */
477 5, ESC, '[', ' ', 'A', '~', /* 0x57: shift CRSR LEFT */
478 5, ESC, '[', '1', '0', '~', /* 0x5D: shift F1 */
479 5, ESC, '[', '1', '1', '~', /* 0x63: shift F2 */
480 5, ESC, '[', '1', '2', '~', /* 0x69: shift F3 */
481 5, ESC, '[', '1', '3', '~', /* 0x6F: shift F4 */
482 5, ESC, '[', '1', '4', '~', /* 0x75: shift F5 */
483 5, ESC, '[', '1', '5', '~', /* 0x7B: shift F6 */
484 5, ESC, '[', '1', '6', '~', /* 0x81: shift F7 */
485 5, ESC, '[', '1', '7', '~', /* 0x87: shift F8 */
486 5, ESC, '[', '1', '8', '~', /* 0x8D: shift F9 */
487 5, ESC, '[', '1', '9', '~', /* 0x93: shift F10 */
488 3, ESC, '[', 'Z', /* 0x99: shift TAB */
489 2, ESC, '[', /* 0x9d: alt ESC == CSI */
490 },
491 };
492
493 unsigned char acctable[KBD_NUM_ACC][64] = {
494 { "@BCDFGHJKLMNPQRSTVWXYZ[\\]^_"
495 "`bcdfghjklmnpqrstvwxyz{|}~\177"}, /* KBD_ACC_GRAVE */
496
497 { "@BCDFGHJKLMNPQRSTVWXYZ[\\]^_"
498 "`bcdfghjklmnpqrstvwxyz{|}~\177"}, /* KBD_ACC_ACUTE */
499
500 { "@BCDFGHJKLMNPQRSTVWXYZ[\\]^_"
501 "`bcdfghjklmnpqrstvwxyz{|}~\177"}, /* KBD_ACC_CIRC */
502
503 { "@BCDEFGHIJKLMPQRSTUVWXYZ[\\]^_"
504 "`bcdefghijklmpqrstuvwxyz{|}~\177"}, /* KBD_ACC_TILDE */
505
506 { "@BCDFGHJKLMNPQRSTVWXYZ[\\]^_"
507 "`bcdfghjklmnpqrstvwxyz{|}~\177"}, /* KBD_ACC_DIER */
508 };
509
510
511
512