1 1.4 tsutsui /* $NetBSD: us-kbdmap.c,v 1.4 2021/05/29 09:50:04 tsutsui Exp $ */ 2 1.4 tsutsui 3 1.4 tsutsui #if !defined(_KERNEL) 4 1.4 tsutsui #include <stdlib.h> 5 1.4 tsutsui #include <unistd.h> 6 1.4 tsutsui #endif 7 1.1 leo 8 1.1 leo #include "../../../dev/kbdmap.h" 9 1.1 leo 10 1.1 leo /* mode shortcuts: */ 11 1.1 leo #define S KBD_MODE_STRING 12 1.4 tsutsui #define C KBD_MODE_CAPS 13 1.4 tsutsui #define K KBD_MODE_KPAD 14 1.1 leo 15 1.1 leo /* 16 1.1 leo | 20.June.95 17 1.1 leo | Abdulkareem asx (at) ccnet.com 18 1.4 tsutsui | 19 1.1 leo | Changes made for the US keyboard 20 1.1 leo | The pipe symbol '|', the double-quote '"', the at sign, '@', the 21 1.1 leo | tidle '~', the backslash '\' were incompatible to the built-in 22 1.1 leo | keymap and therefore not available on the US keyabords. 23 1.1 leo | 24 1.1 leo | I've added the loadkmap us-map line in my /etc/rc.local file; don't 25 1.1 leo | know where else to put it. 26 1.4 tsutsui | 27 1.1 leo */ 28 1.1 leo 29 1.1 leo struct kbdmap kbdmap; 30 1.1 leo struct kbdmap ascii_kbdmap = { 31 1.1 leo /* normal map */ 32 1.1 leo { 33 1.4 tsutsui /* 0x00 */ { 0, 0 }, { 0, ESC }, { 0, '1' }, { 0, '2' }, 34 1.4 tsutsui /* 0x04 */ { 0, '3' }, { 0, '4' }, { 0, '5' }, { 0, '6' }, 35 1.4 tsutsui /* 0x08 */ { 0, '7' }, { 0, '8' }, { 0, '9' }, { 0, '0' }, 36 1.4 tsutsui /* 0x0C */ { 0, '-' }, { 0, '=' }, { 0, '\b' }, { 0, '\t' }, 37 1.4 tsutsui /* 0x10 */ { C, 'q' }, { C, 'w' }, { C, 'e' }, { C, 'r' }, 38 1.4 tsutsui /* 0x14 */ { C, 't' }, { C, 'y' }, { C, 'u' }, { C, 'i' }, 39 1.4 tsutsui /* 0x18 */ { C, 'o' }, { C, 'p' }, { 0, '[' }, { 0, ']' }, 40 1.4 tsutsui /* 0x1C */ { 0, '\r' }, { 0, DEL }, { C, 'a' }, { C, 's' }, 41 1.4 tsutsui /* 0x20 */ { C, 'd' }, { C, 'f' }, { C, 'g' }, { C, 'h' }, 42 1.4 tsutsui /* 0x24 */ { C, 'j' }, { C, 'k' }, { C, 'l' }, { 0, ';' }, 43 1.4 tsutsui /* 0x28 */ { 0, '\'' }, { 0, '`' }, { 0, 0 }, { 0, '\\' }, 44 1.4 tsutsui /* 0x2C */ { C, 'z' }, { C, 'x' }, { C, 'c' }, { C, 'v' }, 45 1.4 tsutsui /* 0x30 */ { C, 'b' }, { C, 'n' }, { C, 'm' }, { 0, ',' }, 46 1.4 tsutsui /* 0x34 */ { 0, '.' }, { 0, '/' }, { 0, 0 }, { 0, 0 }, 47 1.4 tsutsui /* 0x38 */ { 0, 0 }, { 0, ' ' }, { 0, 0 }, { S, 0x10 }, 48 1.4 tsutsui /* 0x3C */ { S, 0x15 }, { S, 0x1A }, { S, 0x1F }, { S, 0x24 }, 49 1.4 tsutsui /* 0x40 */ { S, 0x29 }, { S, 0x2E }, { S, 0x33 }, { S, 0x38 }, 50 1.4 tsutsui /* 0x44 */ { S, 0x3D }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 51 1.4 tsutsui /* 0x48 */ { S, 0x00 }, { 0, 0 }, { 0, '-' }, { S, 0x0C }, 52 1.4 tsutsui /* 0x4C */ { 0, 0 }, { S, 0x08 }, { 0, '+' }, { 0, 0 }, 53 1.4 tsutsui /* 0x50 */ { S, 0x04 }, { 0, 0 }, { 0, 0 }, { 0, DEL }, 54 1.4 tsutsui /* 0x54 */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 55 1.4 tsutsui /* 0x58 */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 56 1.4 tsutsui /* 0x5C */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 57 1.1 leo /* 0x60 */ 58 1.4 tsutsui /* 0x60 */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, '(' }, 59 1.4 tsutsui /* 0x64 */ { 0, ')' }, { 0, '/' }, { 0, '*' }, { K, '7' }, 60 1.4 tsutsui /* 0x68 */ { K, '8' }, { K, '9' }, { K, '4' }, { K, '5' }, 61 1.4 tsutsui /* 0x6C */ { K, '6' }, { K, '1' }, { K, '2' }, { K, '3' }, 62 1.4 tsutsui /* 0x70 */ { K, '0' }, { K, '.' }, { K, '\r' }, { 0, 0 }, 63 1.4 tsutsui /* 0x74 */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 64 1.4 tsutsui /* 0x78 */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 65 1.4 tsutsui /* 0x7C */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } 66 1.1 leo }, 67 1.1 leo /* shifted map */ 68 1.1 leo { 69 1.4 tsutsui /* 0x00 */ { 0, 0 }, { 0, ESC }, { 0, '!' }, { 0, '@' }, 70 1.4 tsutsui /* 0x04 */ { 0, '#' }, { 0, '$' }, { 0, '%' }, { 0, '^' }, 71 1.4 tsutsui /* 0x08 */ { 0, '&' }, { 0, '*' }, { 0, '(' }, { 0, ')' }, 72 1.4 tsutsui /* 0x0C */ { 0, '_' }, { 0, '+' }, { 0, '\b' }, { 0, '\t' }, 73 1.4 tsutsui /* 0x10 */ { C, 'Q' }, { C, 'W' }, { C, 'E' }, { C, 'R' }, 74 1.4 tsutsui /* 0x14 */ { C, 'T' }, { C, 'Y' }, { C, 'U' }, { C, 'I' }, 75 1.4 tsutsui /* 0x18 */ { C, 'O' }, { C, 'P' }, { 0, '{' }, { 0, '}' }, 76 1.4 tsutsui /* 0x1C */ { 0, '\r' }, { 0, 0 }, { C, 'A' }, { C, 'S' }, 77 1.4 tsutsui /* 0x20 */ { C, 'D' }, { C, 'F' }, { C, 'G' }, { C, 'H' }, 78 1.4 tsutsui /* 0x24 */ { C, 'J' }, { C, 'K' }, { C, 'L' }, { 0, ':' }, 79 1.4 tsutsui /* 0x28 */ { 0, '"' }, { 0, '~' }, { 0, 0 }, { 0, '|' }, 80 1.4 tsutsui /* 0x2C */ { C, 'Z' }, { C, 'X' }, { C, 'C' }, { C, 'V' }, 81 1.4 tsutsui /* 0x30 */ { C, 'B' }, { C, 'N' }, { C, 'M' }, { 0, '<' }, 82 1.4 tsutsui /* 0x34 */ { 0, '>' }, { 0, '?' }, { 0, 0 }, { 0, 0 }, 83 1.4 tsutsui /* 0x38 */ { 0, 0 }, { 0, ' ' }, { 0, 0 }, { S, 0x5d }, 84 1.4 tsutsui /* 0x3C */ { S, 0x63 }, { S, 0x69 }, { S, 0x6F }, { S, 0x75 }, 85 1.4 tsutsui /* 0x40 */ { S, 0x7b }, { S, 0x81 }, { S, 0x87 }, { S, 0x8d }, 86 1.4 tsutsui /* 0x44 */ { S, 0x93 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 87 1.4 tsutsui /* 0x48 */ { S, 0x47 }, { 0, 0 }, { 0, '-' }, { S, 0x57 }, 88 1.4 tsutsui /* 0x4C */ { 0, 0 }, { S, 0x51 }, { 0, '+' }, { 0, 0 }, 89 1.4 tsutsui /* 0x50 */ { S, 0x4c }, { 0, 0 }, { 0, 0 }, { 0, DEL }, 90 1.4 tsutsui /* 0x54 */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 91 1.4 tsutsui /* 0x58 */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 92 1.4 tsutsui /* 0x5C */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 93 1.1 leo /* 0x60 */ 94 1.4 tsutsui /* 0x60 */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, '(' }, 95 1.4 tsutsui /* 0x64 */ { 0, ')' }, { 0, '/' }, { 0, '*' }, { K, '7' }, 96 1.4 tsutsui /* 0x68 */ { K, '8' }, { K, '9' }, { K, '4' }, { K, '5' }, 97 1.4 tsutsui /* 0x6C */ { K, '6' }, { K, '1' }, { K, '2' }, { K, '3' }, 98 1.4 tsutsui /* 0x70 */ { K, '0' }, { K, '.' }, { K, '\r' }, { 0, 0 }, 99 1.4 tsutsui /* 0x74 */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 100 1.4 tsutsui /* 0x78 */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, 101 1.4 tsutsui /* 0x7C */ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } 102 1.1 leo }, 103 1.4 tsutsui 104 1.1 leo /* alt map FIXME: No altmap yet.. */ 105 1.1 leo { 106 1.4 tsutsui { 0, 0 } 107 1.1 leo }, 108 1.1 leo 109 1.1 leo /* shift alt map FIXME: No shift altmap yet... */ 110 1.1 leo { 111 1.4 tsutsui { 0, 0 } 112 1.1 leo }, 113 1.1 leo 114 1.4 tsutsui { 115 1.4 tsutsui /* 116 1.4 tsutsui * string table. If there's a better way to get the offsets into the 117 1.4 tsutsui * above table, please tell me.. 118 1.4 tsutsui * 119 1.4 tsutsui * NOTE: save yourself and others a lot of grief by *not* using 120 1.4 tsutsui * CSI == 0x9b, using the two-character sequence gives 121 1.4 tsutsui * much less trouble, especially in GNU-Emacs.. 122 1.4 tsutsui */ 123 1.4 tsutsui 124 1.1 leo 3, ESC, '[', 'A', /* 0x00: CRSR UP */ 125 1.1 leo 3, ESC, '[', 'B', /* 0x04: CRSR DOWN */ 126 1.1 leo 3, ESC, '[', 'C', /* 0x08: CRSR RIGHT */ 127 1.1 leo 3, ESC, '[', 'D', /* 0x0C: CRSR LEFT */ 128 1.1 leo 4, ESC, '[', '0', '~', /* 0x10: F1 */ 129 1.1 leo 4, ESC, '[', '1', '~', /* 0x15: F2 */ 130 1.1 leo 4, ESC, '[', '2', '~', /* 0x1A: F3 */ 131 1.1 leo 4, ESC, '[', '3', '~', /* 0x1F: F4 */ 132 1.1 leo 4, ESC, '[', '4', '~', /* 0x24: F5 */ 133 1.1 leo 4, ESC, '[', '5', '~', /* 0x29: F6 */ 134 1.1 leo 4, ESC, '[', '6', '~', /* 0x2E: F7 */ 135 1.1 leo 4, ESC, '[', '7', '~', /* 0x33: F8 */ 136 1.1 leo 4, ESC, '[', '8', '~', /* 0x38: F9 */ 137 1.1 leo 4, ESC, '[', '9', '~', /* 0x3D: F10 */ 138 1.1 leo 4, ESC, '[', '?', '~', /* 0x42: HELP */ 139 1.1 leo 140 1.1 leo 4, ESC, '[', 'T', '~', /* 0x47: shift CRSR UP */ 141 1.1 leo 4, ESC, '[', 'S', '~', /* 0x4C: shift CRSR DOWN */ 142 1.1 leo 5, ESC, '[', ' ', '@', '~', /* 0x51: shift CRSR RIGHT */ 143 1.1 leo 5, ESC, '[', ' ', 'A', '~', /* 0x57: shift CRSR LEFT */ 144 1.1 leo 5, ESC, '[', '1', '0', '~', /* 0x5D: shift F1 */ 145 1.1 leo 5, ESC, '[', '1', '1', '~', /* 0x63: shift F2 */ 146 1.1 leo 5, ESC, '[', '1', '2', '~', /* 0x69: shift F3 */ 147 1.1 leo 5, ESC, '[', '1', '3', '~', /* 0x6F: shift F4 */ 148 1.1 leo 5, ESC, '[', '1', '4', '~', /* 0x75: shift F5 */ 149 1.1 leo 5, ESC, '[', '1', '5', '~', /* 0x7B: shift F6 */ 150 1.1 leo 5, ESC, '[', '1', '6', '~', /* 0x81: shift F7 */ 151 1.1 leo 5, ESC, '[', '1', '7', '~', /* 0x87: shift F8 */ 152 1.1 leo 5, ESC, '[', '1', '8', '~', /* 0x8D: shift F9 */ 153 1.1 leo 5, ESC, '[', '1', '9', '~', /* 0x93: shift F10 */ 154 1.1 leo 3, ESC, '[', 'Z', /* 0x99: shift TAB */ 155 1.1 leo 2, ESC, '[', /* 0x9d: alt ESC == CSI */ 156 1.1 leo }, 157 1.1 leo }; 158 1.1 leo 159 1.1 leo #ifndef _KERNEL 160 1.4 tsutsui int 161 1.4 tsutsui main(int argc, char *argv[]) 162 1.1 leo { 163 1.4 tsutsui 164 1.4 tsutsui exit(write(1, &ascii_kbdmap, sizeof(kbdmap)) == sizeof(kbdmap) ? 0 : 1); 165 1.1 leo } 166 1.1 leo #endif /* _KERNEL */ 167