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