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