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