Changeset b0b5628 in mainline
- Timestamp:
- 2009-03-08T14:31:51Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6346efd
- Parents:
- 2270bef
- Location:
- uspace/srv/kbd
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/kbd/Makefile
r2270bef rb0b5628 45 45 GENERIC_SOURCES = \ 46 46 generic/kbd.c \ 47 genarch/gsp.c \ 48 genarch/stroke.c \ 47 49 generic/key_buffer.c 48 50 -
uspace/srv/kbd/ctl/gxe_fb.c
r2270bef rb0b5628 40 40 #include <kbd/keycode.h> 41 41 #include <kbd_ctl.h> 42 43 static void parse_ds_start(int scancode); 44 static void parse_ds_e(int scancode); 45 static void parse_ds_e1(int scancode); 46 static void parse_ds_e1a(int scancode); 47 static void parse_ds_e1b(int scancode); 48 static void parse_ds_e1c(int scancode); 49 50 static void parse_leaf(int scancode, int (*map)[2], size_t map_length); 51 52 enum dec_state { 53 ds_start, 54 ds_e, 55 ds_e1, 56 ds_e1a, 57 ds_e1b, 58 ds_e1c 42 #include <gsp.h> 43 #include <stroke.h> 44 45 /** Scancode parser */ 46 static gsp_t sp; 47 48 /** Current parser state */ 49 static int ds; 50 51 #include <stdio.h> 52 53 int seq_defs[] = { 54 /* Not shifted */ 55 56 0, KC_BACKTICK, 0x60, GSP_END, 57 58 0, KC_1, 0x31, GSP_END, 59 0, KC_2, 0x32, GSP_END, 60 0, KC_3, 0x33, GSP_END, 61 0, KC_4, 0x34, GSP_END, 62 0, KC_5, 0x35, GSP_END, 63 0, KC_6, 0x36, GSP_END, 64 0, KC_7, 0x37, GSP_END, 65 0, KC_8, 0x38, GSP_END, 66 0, KC_9, 0x39, GSP_END, 67 0, KC_0, 0x30, GSP_END, 68 69 0, KC_MINUS, 0x2d, GSP_END, 70 0, KC_EQUALS, 0x3d, GSP_END, 71 0, KC_BACKSPACE, 0x08, GSP_END, 72 73 0, KC_TAB, 0x09, GSP_END, 74 75 0, KC_Q, 0x71, GSP_END, 76 0, KC_W, 0x77, GSP_END, 77 0, KC_E, 0x65, GSP_END, 78 0, KC_R, 0x72, GSP_END, 79 0, KC_T, 0x74, GSP_END, 80 0, KC_Y, 0x79, GSP_END, 81 0, KC_U, 0x75, GSP_END, 82 0, KC_I, 0x69, GSP_END, 83 0, KC_O, 0x6f, GSP_END, 84 0, KC_P, 0x70, GSP_END, 85 86 0, KC_LBRACKET, 0x5b, GSP_END, 87 0, KC_RBRACKET, 0x5d, GSP_END, 88 89 0, KC_A, 0x61, GSP_END, 90 0, KC_S, 0x73, GSP_END, 91 0, KC_D, 0x64, GSP_END, 92 0, KC_F, 0x66, GSP_END, 93 0, KC_G, 0x67, GSP_END, 94 0, KC_H, 0x68, GSP_END, 95 0, KC_J, 0x6a, GSP_END, 96 0, KC_K, 0x6b, GSP_END, 97 0, KC_L, 0x6c, GSP_END, 98 99 0, KC_SEMICOLON, 0x3b, GSP_END, 100 0, KC_QUOTE, 0x27, GSP_END, 101 0, KC_BACKSLASH, 0x5c, GSP_END, 102 103 0, KC_Z, 0x7a, GSP_END, 104 0, KC_X, 0x78, GSP_END, 105 0, KC_C, 0x63, GSP_END, 106 0, KC_V, 0x76, GSP_END, 107 0, KC_B, 0x62, GSP_END, 108 0, KC_N, 0x6e, GSP_END, 109 0, KC_M, 0x6d, GSP_END, 110 111 0, KC_COMMA, 0x2c, GSP_END, 112 0, KC_PERIOD, 0x2e, GSP_END, 113 0, KC_SLASH, 0x2f, GSP_END, 114 115 /* Shifted */ 116 117 KM_SHIFT, KC_BACKTICK, 0x7e, GSP_END, 118 119 KM_SHIFT, KC_1, 0x21, GSP_END, 120 KM_SHIFT, KC_2, 0x40, GSP_END, 121 KM_SHIFT, KC_3, 0x23, GSP_END, 122 KM_SHIFT, KC_4, 0x24, GSP_END, 123 KM_SHIFT, KC_5, 0x25, GSP_END, 124 KM_SHIFT, KC_6, 0x5e, GSP_END, 125 KM_SHIFT, KC_7, 0x26, GSP_END, 126 KM_SHIFT, KC_8, 0x2a, GSP_END, 127 KM_SHIFT, KC_9, 0x28, GSP_END, 128 KM_SHIFT, KC_0, 0x29, GSP_END, 129 130 KM_SHIFT, KC_MINUS, 0x5f, GSP_END, 131 KM_SHIFT, KC_EQUALS, 0x2b, GSP_END, 132 133 KM_SHIFT, KC_Q, 0x51, GSP_END, 134 KM_SHIFT, KC_W, 0x57, GSP_END, 135 KM_SHIFT, KC_E, 0x45, GSP_END, 136 KM_SHIFT, KC_R, 0x52, GSP_END, 137 KM_SHIFT, KC_T, 0x54, GSP_END, 138 KM_SHIFT, KC_Y, 0x59, GSP_END, 139 KM_SHIFT, KC_U, 0x55, GSP_END, 140 KM_SHIFT, KC_I, 0x49, GSP_END, 141 KM_SHIFT, KC_O, 0x4f, GSP_END, 142 KM_SHIFT, KC_P, 0x50, GSP_END, 143 144 KM_SHIFT, KC_LBRACKET, 0x7b, GSP_END, 145 KM_SHIFT, KC_RBRACKET, 0x7d, GSP_END, 146 147 KM_SHIFT, KC_A, 0x41, GSP_END, 148 KM_SHIFT, KC_S, 0x53, GSP_END, 149 KM_SHIFT, KC_D, 0x44, GSP_END, 150 KM_SHIFT, KC_F, 0x46, GSP_END, 151 KM_SHIFT, KC_G, 0x47, GSP_END, 152 KM_SHIFT, KC_H, 0x48, GSP_END, 153 KM_SHIFT, KC_J, 0x4a, GSP_END, 154 KM_SHIFT, KC_K, 0x4b, GSP_END, 155 KM_SHIFT, KC_L, 0x4c, GSP_END, 156 157 KM_SHIFT, KC_SEMICOLON, 0x3a, GSP_END, 158 KM_SHIFT, KC_QUOTE, 0x22, GSP_END, 159 KM_SHIFT, KC_BACKSLASH, 0x7c, GSP_END, 160 161 KM_SHIFT, KC_Z, 0x5a, GSP_END, 162 KM_SHIFT, KC_X, 0x58, GSP_END, 163 KM_SHIFT, KC_C, 0x43, GSP_END, 164 KM_SHIFT, KC_V, 0x56, GSP_END, 165 KM_SHIFT, KC_B, 0x42, GSP_END, 166 KM_SHIFT, KC_N, 0x4e, GSP_END, 167 KM_SHIFT, KC_M, 0x4d, GSP_END, 168 169 KM_SHIFT, KC_COMMA, 0x3c, GSP_END, 170 KM_SHIFT, KC_PERIOD, 0x3e, GSP_END, 171 KM_SHIFT, KC_SLASH, 0x3f, GSP_END, 172 173 /* ... */ 174 175 0, KC_SPACE, 0x20, GSP_END, 176 0, KC_ENTER, 0x0a, GSP_END, 177 0, KC_ENTER, 0x0d, GSP_END, 178 179 0, KC_ESCAPE, 0x1b, 0x1b, GSP_END, 180 181 0, KC_F1, 0x1b, 0x5b, 0x4f, 0x50, GSP_END, 182 0, KC_F2, 0x1b, 0x5b, 0x4f, 0x51, GSP_END, 183 0, KC_F3, 0x1b, 0x5b, 0x4f, 0x52, GSP_END, 184 0, KC_F4, 0x1b, 0x5b, 0x4f, 0x53, GSP_END, 185 0, KC_F5, 0x1b, 0x5b, 0x31, 0x35, GSP_END, 186 0, KC_F6, 0x1b, 0x5b, 0x31, 0x37, GSP_END, 187 0, KC_F7, 0x1b, 0x5b, 0x31, 0x38, GSP_END, 188 0, KC_F8, 0x1b, 0x5b, 0x31, 0x39, GSP_END, 189 0, KC_F9, 0x1b, 0x5b, 0x32, 0x38, GSP_END, 190 0, KC_F10, 0x1b, 0x5b, 0x32, 0x39, GSP_END, 191 0, KC_F11, 0x1b, 0x5b, 0x32, 0x33, GSP_END, 192 0, KC_F12, 0x1b, 0x5b, 0x32, 0x34, GSP_END, 193 194 0, KC_INSERT, 0x1b, 0x5b, 0x32, 0x7e, GSP_END, 195 0, KC_HOME, 0x1b, 0x5b, 0x48, GSP_END, 196 0, KC_PAGE_UP, 0x1b, 0x5b, 0x35, 0x7e, GSP_END, 197 0, KC_DELETE, 0x1b, 0x5b, 0x33, 0x7e, GSP_END, 198 0, KC_END, 0x1b, 0x5b, 0x46, GSP_END, 199 0, KC_PAGE_DOWN, 0x1b, 0x5b, 0x36, 0x7e, GSP_END, 200 201 0, KC_UP, 0x1b, 0x5b, 0x41, GSP_END, 202 0, KC_LEFT, 0x1b, 0x5b, 0x44, GSP_END, 203 0, KC_DOWN, 0x1b, 0x5b, 0x42, GSP_END, 204 0, KC_RIGHT, 0x1b, 0x5b, 0x43, GSP_END, 205 206 0, 0 59 207 }; 60 208 61 static int map_start[][2] = { 62 63 [0x60] = { 0, KC_BACKTICK }, 64 65 [0x31] = { 0, KC_1 }, 66 [0x32] = { 0, KC_2 }, 67 [0x33] = { 0, KC_3 }, 68 [0x34] = { 0, KC_4 }, 69 [0x35] = { 0, KC_5 }, 70 [0x36] = { 0, KC_6 }, 71 [0x37] = { 0, KC_7 }, 72 [0x38] = { 0, KC_8 }, 73 [0x39] = { 0, KC_9 }, 74 [0x30] = { 0, KC_0 }, 75 76 [0x2d] = { 0, KC_MINUS }, 77 [0x3d] = { 0, KC_EQUALS }, 78 [0x08] = { 0, KC_BACKSPACE }, 79 80 [0x0f] = { 0, KC_TAB }, 81 82 [0x71] = { 0, KC_Q }, 83 [0x77] = { 0, KC_W }, 84 [0x65] = { 0, KC_E }, 85 [0x72] = { 0, KC_R }, 86 [0x74] = { 0, KC_T }, 87 [0x79] = { 0, KC_Y }, 88 [0x75] = { 0, KC_U }, 89 [0x69] = { 0, KC_I }, 90 [0x6f] = { 0, KC_O }, 91 [0x70] = { 0, KC_P }, 92 93 [0x5b] = { 0, KC_LBRACKET }, 94 [0x5d] = { 0, KC_RBRACKET }, 95 96 [0x61] = { 0, KC_A }, 97 [0x73] = { 0, KC_S }, 98 [0x64] = { 0, KC_D }, 99 [0x66] = { 0, KC_F }, 100 [0x67] = { 0, KC_G }, 101 [0x68] = { 0, KC_H }, 102 [0x6a] = { 0, KC_J }, 103 [0x6b] = { 0, KC_K }, 104 [0x6c] = { 0, KC_L }, 105 106 [0x3b] = { 0, KC_SEMICOLON }, 107 [0x27] = { 0, KC_QUOTE }, 108 [0x5c] = { 0, KC_BACKSLASH }, 109 110 [0x7a] = { 0, KC_Z }, 111 [0x78] = { 0, KC_X }, 112 [0x63] = { 0, KC_C }, 113 [0x76] = { 0, KC_V }, 114 [0x62] = { 0, KC_B }, 115 [0x6e] = { 0, KC_N }, 116 [0x6d] = { 0, KC_M }, 117 118 [0x2c] = { 0, KC_COMMA }, 119 [0x2e] = { 0, KC_PERIOD }, 120 [0x2f] = { 0, KC_SLASH }, 121 122 [0x20] = { 0, KC_SPACE }, 123 124 [0x1b] = { 0, KC_ESCAPE }, 125 126 [0x0a] = { 0, KC_ENTER }, 127 [0x0d] = { 0, KC_ENTER }, 128 129 /* with Shift pressed */ 130 131 [0x7e] = { KM_LSHIFT, KC_BACKTICK }, 132 133 [0x21] = { KM_LSHIFT, KC_1 }, 134 [0x40] = { KM_LSHIFT, KC_2 }, 135 [0x23] = { KM_LSHIFT, KC_3 }, 136 [0x24] = { KM_LSHIFT, KC_4 }, 137 [0x25] = { KM_LSHIFT, KC_5 }, 138 [0x5e] = { KM_LSHIFT, KC_6 }, 139 [0x26] = { KM_LSHIFT, KC_7 }, 140 [0x2a] = { KM_LSHIFT, KC_8 }, 141 [0x28] = { KM_LSHIFT, KC_9 }, 142 [0x29] = { KM_LSHIFT, KC_0 }, 143 144 [0x5f] = { KM_LSHIFT, KC_MINUS }, 145 [0x2b] = { KM_LSHIFT, KC_EQUALS }, 146 147 [0x51] = { KM_LSHIFT, KC_Q }, 148 [0x57] = { KM_LSHIFT, KC_W }, 149 [0x45] = { KM_LSHIFT, KC_E }, 150 [0x52] = { KM_LSHIFT, KC_R }, 151 [0x54] = { KM_LSHIFT, KC_T }, 152 [0x59] = { KM_LSHIFT, KC_Y }, 153 [0x55] = { KM_LSHIFT, KC_U }, 154 [0x49] = { KM_LSHIFT, KC_I }, 155 [0x4f] = { KM_LSHIFT, KC_O }, 156 [0x50] = { KM_LSHIFT, KC_P }, 157 158 [0x7b] = { KM_LSHIFT, KC_LBRACKET }, 159 [0x7d] = { KM_LSHIFT, KC_RBRACKET }, 160 161 [0x41] = { KM_LSHIFT, KC_A }, 162 [0x53] = { KM_LSHIFT, KC_S }, 163 [0x44] = { KM_LSHIFT, KC_D }, 164 [0x46] = { KM_LSHIFT, KC_F }, 165 [0x47] = { KM_LSHIFT, KC_G }, 166 [0x48] = { KM_LSHIFT, KC_H }, 167 [0x4a] = { KM_LSHIFT, KC_J }, 168 [0x4b] = { KM_LSHIFT, KC_K }, 169 [0x4c] = { KM_LSHIFT, KC_L }, 170 171 [0x3a] = { KM_LSHIFT, KC_SEMICOLON }, 172 [0x22] = { KM_LSHIFT, KC_QUOTE }, 173 [0x7c] = { KM_LSHIFT, KC_BACKSLASH }, 174 175 [0x5a] = { KM_LSHIFT, KC_Z }, 176 [0x58] = { KM_LSHIFT, KC_X }, 177 [0x43] = { KM_LSHIFT, KC_C }, 178 [0x56] = { KM_LSHIFT, KC_V }, 179 [0x42] = { KM_LSHIFT, KC_B }, 180 [0x4e] = { KM_LSHIFT, KC_N }, 181 [0x4d] = { KM_LSHIFT, KC_M }, 182 183 [0x3c] = { KM_LSHIFT, KC_COMMA }, 184 [0x3e] = { KM_LSHIFT, KC_PERIOD }, 185 [0x3f] = { KM_LSHIFT, KC_SLASH } 186 }; 187 188 static int map_e1[][2] = 209 int kbd_ctl_init(void) 189 210 { 190 }; 191 192 static int map_e1a[][2] = 193 { 194 [0x50] = { 0, KC_F1 }, 195 [0x51] = { 0, KC_F2 }, 196 [0x52] = { 0, KC_F3 }, 197 [0x53] = { 0, KC_F4 }, 198 }; 199 200 static int map_e1b[][2] = 201 { 202 [0x33] = { 0, KC_F5 }, 203 [0x37] = { 0, KC_F6 }, 204 [0x38] = { 0, KC_F7 }, 205 [0x39] = { 0, KC_F8 }, 206 }; 207 208 static int map_e1c[][2] = 209 { 210 [0x38] = { 0, KC_F9 }, 211 [0x39] = { 0, KC_F10 }, 212 [0x33] = { 0, KC_F11 }, 213 [0x34] = { 0, KC_F12 }, 214 }; 215 216 static unsigned int mods_keys[][2] = { 217 { KM_LSHIFT, KC_LSHIFT }, 218 { 0, 0 } 219 }; 220 221 static enum dec_state ds = ds_start; 211 ds = 0; 212 213 gsp_init(&sp); 214 return gsp_insert_defs(&sp, seq_defs); 215 } 222 216 223 217 void kbd_ctl_parse_scancode(int scancode) 224 218 { 225 switch (ds) { 226 case ds_start: parse_ds_start(scancode); break; 227 case ds_e: parse_ds_e(scancode); break; 228 case ds_e1: parse_ds_e1(scancode); break; 229 case ds_e1a: parse_ds_e1a(scancode); break; 230 case ds_e1b: parse_ds_e1b(scancode); break; 231 case ds_e1c: parse_ds_e1c(scancode); break; 232 } 233 } 234 235 static void parse_ds_start(int scancode) 236 { 237 if (scancode == 0x1b) { 238 ds = ds_e; 239 return; 240 } 241 242 parse_leaf(scancode, map_start, sizeof(map_start) / (2 * sizeof(int))); 243 } 244 245 static void parse_ds_e(int scancode) 246 { 247 switch (scancode) { 248 case 0x5b: ds = ds_e1; return; 249 case 0x1b: ds = ds_start; break; 250 default: ds = ds_start; return; 251 } 252 253 kbd_push_ev(KE_PRESS, KC_ESCAPE); 254 } 255 256 static void parse_ds_e1(int scancode) 257 { 258 switch (scancode) { 259 case 0x4f: ds = ds_e1a; return; 260 case 0x31: ds = ds_e1b; return; 261 case 0x32: ds = ds_e1c; return; 262 default: ds = ds_start; break; 263 } 264 265 parse_leaf(scancode, map_e1, sizeof(map_e1) / (2 * sizeof(int))); 266 } 267 268 static void parse_ds_e1a(int scancode) 269 { 270 parse_leaf(scancode, map_e1a, sizeof(map_e1a) / (2 * sizeof(int))); 271 } 272 273 static void parse_ds_e1b(int scancode) 274 { 275 parse_leaf(scancode, map_e1b, sizeof(map_e1b) / (2 * sizeof(int))); 276 } 277 278 static void parse_ds_e1c(int scancode) 279 { 280 parse_leaf(scancode, map_e1c, sizeof(map_e1c) / (2 * sizeof(int))); 281 } 282 283 static void parse_leaf(int scancode, int (*map)[2], size_t map_length) 284 { 285 unsigned int key, mod; 286 int i; 287 288 ds = ds_start; 289 290 if (scancode < 0 || scancode >= map_length) 291 return; 292 293 mod = map[scancode][0]; 294 key = map[scancode][1]; 295 296 /* Simulate modifier pressing. */ 297 i = 0; 298 while (mods_keys[i][0] != 0) { 299 if (mod & mods_keys[i][0]) { 300 kbd_push_ev(KE_PRESS, mods_keys[i][1]); 301 } 302 ++i; 303 } 304 219 unsigned mods, key; 220 221 ds = gsp_step(&sp, ds, scancode, &mods, &key); 305 222 if (key != 0) { 306 kbd_push_ev(KE_PRESS, key); 307 kbd_push_ev(KE_RELEASE, key); 308 } 309 310 /* Simulate modifier releasing. */ 311 i = 0; 312 while (mods_keys[i][0] != 0) { 313 if (mod & mods_keys[i][0]) { 314 kbd_push_ev(KE_RELEASE, mods_keys[i][1]); 315 } 316 ++i; 223 stroke_sim(mods, key); 317 224 } 318 225 } -
uspace/srv/kbd/ctl/pc.c
r2270bef rb0b5628 40 40 #include <kbd/keycode.h> 41 41 #include <kbd_ctl.h> 42 #include <gsp.h> 42 43 43 44 enum dec_state { … … 46 47 }; 47 48 48 static enum dec_state ds = ds_s;49 static enum dec_state ds; 49 50 50 51 static int scanmap_simple[] = { … … 180 181 }; 181 182 183 int kbd_ctl_init(void) 184 { 185 ds = ds_s; 186 return 0; 187 } 182 188 183 189 void kbd_ctl_parse_scancode(int scancode) -
uspace/srv/kbd/ctl/stty.c
r2270bef rb0b5628 40 40 #include <kbd/keycode.h> 41 41 #include <kbd_ctl.h> 42 43 static void parse_ds_start(int scancode); 44 static void parse_ds_e(int scancode); 45 static void parse_ds_e1(int scancode); 46 static void parse_ds_e2(int scancode); 47 static void parse_ds_e2a(int scancode); 48 static void parse_ds_e2b(int scancode); 49 50 static void parse_leaf(int scancode, int (*map)[2], size_t map_length); 51 52 enum dec_state { 53 ds_start, 54 ds_e, 55 ds_e1, 56 ds_e2, 57 ds_e2a, 58 ds_e2b 42 #include <gsp.h> 43 #include <stroke.h> 44 45 /** Scancode parser */ 46 static gsp_t sp; 47 48 /** Current parser state */ 49 static int ds; 50 51 #include <stdio.h> 52 53 int seq_defs[] = { 54 /* Not shifted */ 55 56 0, KC_BACKTICK, 0x60, GSP_END, 57 58 0, KC_1, 0x31, GSP_END, 59 0, KC_2, 0x32, GSP_END, 60 0, KC_3, 0x33, GSP_END, 61 0, KC_4, 0x34, GSP_END, 62 0, KC_5, 0x35, GSP_END, 63 0, KC_6, 0x36, GSP_END, 64 0, KC_7, 0x37, GSP_END, 65 0, KC_8, 0x38, GSP_END, 66 0, KC_9, 0x39, GSP_END, 67 0, KC_0, 0x30, GSP_END, 68 69 0, KC_MINUS, 0x2d, GSP_END, 70 0, KC_EQUALS, 0x3d, GSP_END, 71 0, KC_BACKSPACE, 0x08, GSP_END, 72 73 0, KC_TAB, 0x09, GSP_END, 74 75 0, KC_Q, 0x71, GSP_END, 76 0, KC_W, 0x77, GSP_END, 77 0, KC_E, 0x65, GSP_END, 78 0, KC_R, 0x72, GSP_END, 79 0, KC_T, 0x74, GSP_END, 80 0, KC_Y, 0x79, GSP_END, 81 0, KC_U, 0x75, GSP_END, 82 0, KC_I, 0x69, GSP_END, 83 0, KC_O, 0x6f, GSP_END, 84 0, KC_P, 0x70, GSP_END, 85 86 0, KC_LBRACKET, 0x5b, GSP_END, 87 0, KC_RBRACKET, 0x5d, GSP_END, 88 89 0, KC_A, 0x61, GSP_END, 90 0, KC_S, 0x73, GSP_END, 91 0, KC_D, 0x64, GSP_END, 92 0, KC_F, 0x66, GSP_END, 93 0, KC_G, 0x67, GSP_END, 94 0, KC_H, 0x68, GSP_END, 95 0, KC_J, 0x6a, GSP_END, 96 0, KC_K, 0x6b, GSP_END, 97 0, KC_L, 0x6c, GSP_END, 98 99 0, KC_SEMICOLON, 0x3b, GSP_END, 100 0, KC_QUOTE, 0x27, GSP_END, 101 0, KC_BACKSLASH, 0x5c, GSP_END, 102 103 0, KC_Z, 0x7a, GSP_END, 104 0, KC_X, 0x78, GSP_END, 105 0, KC_C, 0x63, GSP_END, 106 0, KC_V, 0x76, GSP_END, 107 0, KC_B, 0x62, GSP_END, 108 0, KC_N, 0x6e, GSP_END, 109 0, KC_M, 0x6d, GSP_END, 110 111 0, KC_COMMA, 0x2c, GSP_END, 112 0, KC_PERIOD, 0x2e, GSP_END, 113 0, KC_SLASH, 0x2f, GSP_END, 114 115 /* Shifted */ 116 117 KM_SHIFT, KC_BACKTICK, 0x7e, GSP_END, 118 119 KM_SHIFT, KC_1, 0x21, GSP_END, 120 KM_SHIFT, KC_2, 0x40, GSP_END, 121 KM_SHIFT, KC_3, 0x23, GSP_END, 122 KM_SHIFT, KC_4, 0x24, GSP_END, 123 KM_SHIFT, KC_5, 0x25, GSP_END, 124 KM_SHIFT, KC_6, 0x5e, GSP_END, 125 KM_SHIFT, KC_7, 0x26, GSP_END, 126 KM_SHIFT, KC_8, 0x2a, GSP_END, 127 KM_SHIFT, KC_9, 0x28, GSP_END, 128 KM_SHIFT, KC_0, 0x29, GSP_END, 129 130 KM_SHIFT, KC_MINUS, 0x5f, GSP_END, 131 KM_SHIFT, KC_EQUALS, 0x2b, GSP_END, 132 133 KM_SHIFT, KC_Q, 0x51, GSP_END, 134 KM_SHIFT, KC_W, 0x57, GSP_END, 135 KM_SHIFT, KC_E, 0x45, GSP_END, 136 KM_SHIFT, KC_R, 0x52, GSP_END, 137 KM_SHIFT, KC_T, 0x54, GSP_END, 138 KM_SHIFT, KC_Y, 0x59, GSP_END, 139 KM_SHIFT, KC_U, 0x55, GSP_END, 140 KM_SHIFT, KC_I, 0x49, GSP_END, 141 KM_SHIFT, KC_O, 0x4f, GSP_END, 142 KM_SHIFT, KC_P, 0x50, GSP_END, 143 144 KM_SHIFT, KC_LBRACKET, 0x7b, GSP_END, 145 KM_SHIFT, KC_RBRACKET, 0x7d, GSP_END, 146 147 KM_SHIFT, KC_A, 0x41, GSP_END, 148 KM_SHIFT, KC_S, 0x53, GSP_END, 149 KM_SHIFT, KC_D, 0x44, GSP_END, 150 KM_SHIFT, KC_F, 0x46, GSP_END, 151 KM_SHIFT, KC_G, 0x47, GSP_END, 152 KM_SHIFT, KC_H, 0x48, GSP_END, 153 KM_SHIFT, KC_J, 0x4a, GSP_END, 154 KM_SHIFT, KC_K, 0x4b, GSP_END, 155 KM_SHIFT, KC_L, 0x4c, GSP_END, 156 157 KM_SHIFT, KC_SEMICOLON, 0x3a, GSP_END, 158 KM_SHIFT, KC_QUOTE, 0x22, GSP_END, 159 KM_SHIFT, KC_BACKSLASH, 0x7c, GSP_END, 160 161 KM_SHIFT, KC_Z, 0x5a, GSP_END, 162 KM_SHIFT, KC_X, 0x58, GSP_END, 163 KM_SHIFT, KC_C, 0x43, GSP_END, 164 KM_SHIFT, KC_V, 0x56, GSP_END, 165 KM_SHIFT, KC_B, 0x42, GSP_END, 166 KM_SHIFT, KC_N, 0x4e, GSP_END, 167 KM_SHIFT, KC_M, 0x4d, GSP_END, 168 169 KM_SHIFT, KC_COMMA, 0x3c, GSP_END, 170 KM_SHIFT, KC_PERIOD, 0x3e, GSP_END, 171 KM_SHIFT, KC_SLASH, 0x3f, GSP_END, 172 173 /* ... */ 174 175 0, KC_SPACE, 0x20, GSP_END, 176 0, KC_ENTER, 0x0a, GSP_END, 177 0, KC_ENTER, 0x0d, GSP_END, 178 179 0, KC_ESCAPE, 0x1b, 0x1b, GSP_END, 180 181 0, KC_F1, 0x1b, 0x4f, 0x50, GSP_END, 182 0, KC_F2, 0x1b, 0x4f, 0x51, GSP_END, 183 0, KC_F3, 0x1b, 0x4f, 0x52, GSP_END, 184 0, KC_F4, 0x1b, 0x4f, 0x53, GSP_END, 185 0, KC_F5, 0x1b, 0x5b, 0x31, 0x35, 0x7e, GSP_END, 186 0, KC_F6, 0x1b, 0x5b, 0x31, 0x37, 0x7e, GSP_END, 187 0, KC_F7, 0x1b, 0x5b, 0x31, 0x38, 0x7e, GSP_END, 188 0, KC_F8, 0x1b, 0x5b, 0x31, 0x39, 0x7e, GSP_END, 189 0, KC_F9, 0x1b, 0x5b, 0x32, 0x30, 0x7e, GSP_END, 190 0, KC_F10, 0x1b, 0x5b, 0x32, 0x31, 0x7e, GSP_END, 191 0, KC_F11, 0x1b, 0x5b, 0x32, 0x33, 0x7e, GSP_END, 192 0, KC_F12, 0x1b, 0x5b, 0x32, 0x34, 0x7e, GSP_END, 193 194 0, KC_INSERT, 0x1b, 0x5b, 0x32, 0x7e, GSP_END, 195 0, KC_HOME, 0x1b, 0x5b, 0x48, GSP_END, 196 0, KC_PAGE_UP, 0x1b, 0x5b, 0x35, 0x7e, GSP_END, 197 0, KC_DELETE, 0x1b, 0x5b, 0x33, 0x7e, GSP_END, 198 0, KC_END, 0x1b, 0x5b, 0x46, GSP_END, 199 0, KC_PAGE_DOWN, 0x1b, 0x5b, 0x36, 0x7e, GSP_END, 200 201 0, KC_UP, 0x1b, 0x5b, 0x41, GSP_END, 202 0, KC_LEFT, 0x1b, 0x5b, 0x44, GSP_END, 203 0, KC_DOWN, 0x1b, 0x5b, 0x42, GSP_END, 204 0, KC_RIGHT, 0x1b, 0x5b, 0x43, GSP_END, 205 206 0, 0 59 207 }; 60 208 61 static int map_start[][2] = { 62 63 [0x60] = { 0, KC_BACKTICK }, 64 65 [0x31] = { 0, KC_1 }, 66 [0x32] = { 0, KC_2 }, 67 [0x33] = { 0, KC_3 }, 68 [0x34] = { 0, KC_4 }, 69 [0x35] = { 0, KC_5 }, 70 [0x36] = { 0, KC_6 }, 71 [0x37] = { 0, KC_7 }, 72 [0x38] = { 0, KC_8 }, 73 [0x39] = { 0, KC_9 }, 74 [0x30] = { 0, KC_0 }, 75 76 [0x2d] = { 0, KC_MINUS }, 77 [0x3d] = { 0, KC_EQUALS }, 78 [0x08] = { 0, KC_BACKSPACE }, 79 80 [0x0f] = { 0, KC_TAB }, 81 82 [0x71] = { 0, KC_Q }, 83 [0x77] = { 0, KC_W }, 84 [0x65] = { 0, KC_E }, 85 [0x72] = { 0, KC_R }, 86 [0x74] = { 0, KC_T }, 87 [0x79] = { 0, KC_Y }, 88 [0x75] = { 0, KC_U }, 89 [0x69] = { 0, KC_I }, 90 [0x6f] = { 0, KC_O }, 91 [0x70] = { 0, KC_P }, 92 93 [0x5b] = { 0, KC_LBRACKET }, 94 [0x5d] = { 0, KC_RBRACKET }, 95 96 [0x61] = { 0, KC_A }, 97 [0x73] = { 0, KC_S }, 98 [0x64] = { 0, KC_D }, 99 [0x66] = { 0, KC_F }, 100 [0x67] = { 0, KC_G }, 101 [0x68] = { 0, KC_H }, 102 [0x6a] = { 0, KC_J }, 103 [0x6b] = { 0, KC_K }, 104 [0x6c] = { 0, KC_L }, 105 106 [0x3b] = { 0, KC_SEMICOLON }, 107 [0x27] = { 0, KC_QUOTE }, 108 [0x5c] = { 0, KC_BACKSLASH }, 109 110 [0x7a] = { 0, KC_Z }, 111 [0x78] = { 0, KC_X }, 112 [0x63] = { 0, KC_C }, 113 [0x76] = { 0, KC_V }, 114 [0x62] = { 0, KC_B }, 115 [0x6e] = { 0, KC_N }, 116 [0x6d] = { 0, KC_M }, 117 118 [0x2c] = { 0, KC_COMMA }, 119 [0x2e] = { 0, KC_PERIOD }, 120 [0x2f] = { 0, KC_SLASH }, 121 122 [0x20] = { 0, KC_SPACE }, 123 124 [0x1b] = { 0, KC_ESCAPE }, 125 126 [0x0a] = { 0, KC_ENTER }, 127 [0x0d] = { 0, KC_ENTER }, 128 129 /* with Shift pressed */ 130 131 [0x7e] = { KM_LSHIFT, KC_BACKTICK }, 132 133 [0x21] = { KM_LSHIFT, KC_1 }, 134 [0x40] = { KM_LSHIFT, KC_2 }, 135 [0x23] = { KM_LSHIFT, KC_3 }, 136 [0x24] = { KM_LSHIFT, KC_4 }, 137 [0x25] = { KM_LSHIFT, KC_5 }, 138 [0x5e] = { KM_LSHIFT, KC_6 }, 139 [0x26] = { KM_LSHIFT, KC_7 }, 140 [0x2a] = { KM_LSHIFT, KC_8 }, 141 [0x28] = { KM_LSHIFT, KC_9 }, 142 [0x29] = { KM_LSHIFT, KC_0 }, 143 144 [0x5f] = { KM_LSHIFT, KC_MINUS }, 145 [0x2b] = { KM_LSHIFT, KC_EQUALS }, 146 147 [0x51] = { KM_LSHIFT, KC_Q }, 148 [0x57] = { KM_LSHIFT, KC_W }, 149 [0x45] = { KM_LSHIFT, KC_E }, 150 [0x52] = { KM_LSHIFT, KC_R }, 151 [0x54] = { KM_LSHIFT, KC_T }, 152 [0x59] = { KM_LSHIFT, KC_Y }, 153 [0x55] = { KM_LSHIFT, KC_U }, 154 [0x49] = { KM_LSHIFT, KC_I }, 155 [0x4f] = { KM_LSHIFT, KC_O }, 156 [0x50] = { KM_LSHIFT, KC_P }, 157 158 [0x7b] = { KM_LSHIFT, KC_LBRACKET }, 159 [0x7d] = { KM_LSHIFT, KC_RBRACKET }, 160 161 [0x41] = { KM_LSHIFT, KC_A }, 162 [0x53] = { KM_LSHIFT, KC_S }, 163 [0x44] = { KM_LSHIFT, KC_D }, 164 [0x46] = { KM_LSHIFT, KC_F }, 165 [0x47] = { KM_LSHIFT, KC_G }, 166 [0x48] = { KM_LSHIFT, KC_H }, 167 [0x4a] = { KM_LSHIFT, KC_J }, 168 [0x4b] = { KM_LSHIFT, KC_K }, 169 [0x4c] = { KM_LSHIFT, KC_L }, 170 171 [0x3a] = { KM_LSHIFT, KC_SEMICOLON }, 172 [0x22] = { KM_LSHIFT, KC_QUOTE }, 173 [0x7c] = { KM_LSHIFT, KC_BACKSLASH }, 174 175 [0x5a] = { KM_LSHIFT, KC_Z }, 176 [0x58] = { KM_LSHIFT, KC_X }, 177 [0x43] = { KM_LSHIFT, KC_C }, 178 [0x56] = { KM_LSHIFT, KC_V }, 179 [0x42] = { KM_LSHIFT, KC_B }, 180 [0x4e] = { KM_LSHIFT, KC_N }, 181 [0x4d] = { KM_LSHIFT, KC_M }, 182 183 [0x3c] = { KM_LSHIFT, KC_COMMA }, 184 [0x3e] = { KM_LSHIFT, KC_PERIOD }, 185 [0x3f] = { KM_LSHIFT, KC_SLASH } 186 }; 187 188 static int map_e1[][2] = 209 int kbd_ctl_init(void) 189 210 { 190 [0x50] = { 0, KC_F1 }, 191 [0x51] = { 0, KC_F2 }, 192 [0x52] = { 0, KC_F3 }, 193 [0x53] = { 0, KC_F4 }, 194 }; 195 196 static int map_e2[][2] = 197 { 198 [0x41] = { 0, KC_UP }, 199 [0x42] = { 0, KC_DOWN }, 200 [0x44] = { 0, KC_LEFT }, 201 [0x43] = { 0, KC_RIGHT }, 202 }; 203 204 static int map_e2a[][2] = 205 { 206 [0x35] = { 0, KC_F5 }, 207 [0x37] = { 0, KC_F6 }, 208 [0x38] = { 0, KC_F7 }, 209 [0x39] = { 0, KC_F8 }, 210 }; 211 212 static int map_e2b[][2] = 213 { 214 [0x30] = { 0, KC_F9 }, 215 [0x31] = { 0, KC_F10 }, 216 [0x32] = { 0, KC_F11 }, 217 [0x33] = { 0, KC_F12 }, 218 }; 219 220 static unsigned int mods_keys[][2] = { 221 { KM_LSHIFT, KC_LSHIFT }, 222 { 0, 0 } 223 }; 224 225 static enum dec_state ds; 211 ds = 0; 212 213 gsp_init(&sp); 214 return gsp_insert_defs(&sp, seq_defs); 215 } 226 216 227 217 void kbd_ctl_parse_scancode(int scancode) 228 218 { 229 switch (ds) { 230 case ds_start: parse_ds_start(scancode); break; 231 case ds_e: parse_ds_e(scancode); break; 232 case ds_e1: parse_ds_e1(scancode); break; 233 case ds_e2: parse_ds_e2(scancode); break; 234 case ds_e2a: parse_ds_e2a(scancode); break; 235 case ds_e2b: parse_ds_e2b(scancode); break; 219 unsigned mods, key; 220 221 ds = gsp_step(&sp, ds, scancode, &mods, &key); 222 if (key != 0) { 223 stroke_sim(mods, key); 236 224 } 237 225 } 238 239 static void parse_ds_start(int scancode)240 {241 if (scancode == 0x1b) {242 ds = ds_e;243 return;244 }245 246 parse_leaf(scancode, map_start, sizeof(map_start) / (2 * sizeof(int)));247 }248 249 static void parse_ds_e(int scancode)250 {251 if (scancode < 0 || scancode >= 0x80) return;252 253 switch (scancode) {254 case 0x4f: ds = ds_e1; return;255 case 0x5b: ds = ds_e2; return;256 case 0x1b: ds = ds_start; break;257 default: ds = ds_start; return;258 }259 260 kbd_push_ev(KE_PRESS, KC_ESCAPE);261 }262 263 static void parse_ds_e1(int scancode)264 {265 parse_leaf(scancode, map_e1, sizeof(map_e1) / (2 * sizeof(int)));266 }267 268 static void parse_ds_e2(int scancode)269 {270 switch (scancode) {271 case 0x31: ds = ds_e2a; break;272 case 0x32: ds = ds_e2b; break;273 default: ds = ds_start; break;274 }275 276 parse_leaf(scancode, map_e2, sizeof(map_e2) / (2 * sizeof(int)));277 }278 279 static void parse_ds_e2a(int scancode)280 {281 parse_leaf(scancode, map_e2a, sizeof(map_e2a) / (2 * sizeof(int)));282 }283 284 static void parse_ds_e2b(int scancode)285 {286 parse_leaf(scancode, map_e2b, sizeof(map_e2b) / (2 * sizeof(int)));287 }288 289 static void parse_leaf(int scancode, int (*map)[2], size_t map_length)290 {291 unsigned int key, mod;292 int i;293 294 ds = ds_start;295 296 if (scancode < 0 || scancode >= map_length)297 return;298 299 mod = map[scancode][0];300 key = map[scancode][1];301 302 /* Simulate modifier pressing. */303 i = 0;304 while (mods_keys[i][0] != 0) {305 if (mod & mods_keys[i][0]) {306 kbd_push_ev(KE_PRESS, mods_keys[i][1]);307 }308 ++i;309 }310 311 if (key != 0) {312 kbd_push_ev(KE_PRESS, key);313 kbd_push_ev(KE_RELEASE, key);314 }315 316 /* Simulate modifier releasing. */317 i = 0;318 while (mods_keys[i][0] != 0) {319 if (mod & mods_keys[i][0]) {320 kbd_push_ev(KE_RELEASE, mods_keys[i][1]);321 }322 ++i;323 }324 }325 326 226 327 227 /** -
uspace/srv/kbd/ctl/sun.c
r2270bef rb0b5628 45 45 46 46 static int scanmap_simple[]; 47 48 int kbd_ctl_init(void) 49 { 50 return 0; 51 } 47 52 48 53 void kbd_ctl_parse_scancode(int scancode) -
uspace/srv/kbd/generic/kbd.c
r2270bef rb0b5628 190 190 191 191 /* Initialize port driver. */ 192 if (kbd_port_init()) 192 if (kbd_port_init() != 0) 193 return -1; 194 195 /* Initialize controller driver. */ 196 if (kbd_ctl_init() != 0) 193 197 return -1; 194 198 -
uspace/srv/kbd/include/kbd_ctl.h
r2270bef rb0b5628 39 39 40 40 extern void kbd_ctl_parse_scancode(int); 41 extern int kbd_ctl_init(void); 42 41 43 42 44 #endif
Note:
See TracChangeset
for help on using the changeset viewer.