Changeset d1eece6 in mainline
- Timestamp:
- 2009-02-19T22:54:32Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 013c4d6
- Parents:
- 91825d90
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/include/kbd/keycode.h
r91825d90 rd1eece6 200 200 201 201 enum keymod { 202 KM_SHIFT = 0x01, 203 KM_CTRL = 0x02, 204 KM_ALT = 0x04 202 KM_LSHIFT = 0x001, 203 KM_RSHIFT = 0x002, 204 KM_LCTRL = 0x004, 205 KM_RCTRL = 0x008, 206 KM_LALT = 0x010, 207 KM_RALT = 0x020, 208 KM_CAPS_LOCK = 0x040, 209 KM_NUM_LOCK = 0x080, 210 KM_SCROLL_LOCK = 0x100, 211 212 KM_SHIFT = KM_LSHIFT | KM_RSHIFT, 213 KM_CTRL = KM_LCTRL | KM_RCTRL, 214 KM_ALT = KM_LALT | KM_RALT 205 215 } keymod_t; 206 216 -
uspace/srv/kbd/ctl/gxe_fb.c
r91825d90 rd1eece6 203 203 } 204 204 205 kbd_push_ev(KE_PRESS, KC_ESCAPE , 0);205 kbd_push_ev(KE_PRESS, KC_ESCAPE); 206 206 } 207 207 -
uspace/srv/kbd/ctl/pc.c
r91825d90 rd1eece6 60 60 key = scanmap_simple[scancode]; 61 61 if (key != 0) 62 kbd_push_ev(type, key , 0);62 kbd_push_ev(type, key); 63 63 } 64 64 -
uspace/srv/kbd/ctl/stty.c
r91825d90 rd1eece6 213 213 } 214 214 215 kbd_push_ev(KE_PRESS, KC_ESCAPE , 0);215 kbd_push_ev(KE_PRESS, KC_ESCAPE); 216 216 } 217 217 … … 253 253 key = map[scancode]; 254 254 if (key != 0) 255 kbd_push_ev(KE_PRESS, key , 0);255 kbd_push_ev(KE_PRESS, key); 256 256 } 257 257 -
uspace/srv/kbd/ctl/sun.c
r91825d90 rd1eece6 66 66 key = scanmap_simple[scancode]; 67 67 if (key != 0) 68 kbd_push_ev(type, key , 0);68 kbd_push_ev(type, key); 69 69 } 70 70 -
uspace/srv/kbd/generic/kbd.c
r91825d90 rd1eece6 58 58 int cons_connected = 0; 59 59 int phone2cons = -1; 60 keybuffer_t keybuffer; 60 keybuffer_t keybuffer; 61 62 /** Currently active modifiers. */ 63 static unsigned mods; 61 64 62 65 void kbd_push_scancode(int scancode) … … 67 70 68 71 #include <kbd/keycode.h> 69 void kbd_push_ev(int type, unsigned int key , unsigned int mods)72 void kbd_push_ev(int type, unsigned int key) 70 73 { 71 74 kbd_event_t ev; 75 unsigned mod_mask; 76 77 switch (key) { 78 case KC_LCTRL: mod_mask = KM_LCTRL; break; 79 case KC_RCTRL: mod_mask = KM_RCTRL; break; 80 case KC_LSHIFT: mod_mask = KM_LSHIFT; break; 81 case KC_RSHIFT: mod_mask = KM_RSHIFT; break; 82 case KC_LALT: mod_mask = KM_LALT; break; 83 case KC_RALT: mod_mask = KM_RALT; break; 84 default: mod_mask = 0; break; 85 } 86 87 if (mod_mask != 0) { 88 if (type == KE_PRESS) 89 mods = mods | mod_mask; 90 else 91 mods = mods & ~mod_mask; 92 } 93 94 switch (key) { 95 case KC_CAPS_LOCK: mod_mask = KM_CAPS_LOCK; break; 96 case KC_NUM_LOCK: mod_mask = KM_NUM_LOCK; break; 97 case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; break; 98 default: mod_mask = 0; break; 99 } 100 101 if (mod_mask != 0 && type == KE_PRESS) 102 mods = mods ^ mod_mask; 72 103 73 104 printf("type: %d\n", type); … … 83 114 async_msg_4(phone2cons, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c); 84 115 } 85 86 //static void irq_handler(ipc_callid_t iid, ipc_call_t *call)87 //{88 // kbd_event_t ev;89 //90 // kbd_arch_process(&keybuffer, call);91 //92 // if (cons_connected && phone2cons != -1) {93 // /*94 // * One interrupt can produce more than one event so the result95 // * is stored in a FIFO.96 // */97 // while (!keybuffer_empty(&keybuffer)) {98 // if (!keybuffer_pop(&keybuffer, &ev))99 // break;100 //101 // async_msg_4(phone2cons, KBD_EVENT, ev.type, ev.key,102 // ev.mods, ev.c);103 // }104 // }105 //}106 116 107 117 static void console_connection(ipc_callid_t iid, ipc_call_t *icall) … … 143 153 144 154 145 146 155 int main(int argc, char **argv) 147 156 { -
uspace/srv/kbd/include/kbd.h
r91825d90 rd1eece6 47 47 48 48 extern void kbd_push_scancode(int); 49 extern void kbd_push_ev(int, unsigned int , unsigned int);49 extern void kbd_push_ev(int, unsigned int); 50 50 51 51 #endif -
uspace/srv/kbd/layout/us_dvorak.c
r91825d90 rd1eece6 37 37 #include <layout.h> 38 38 39 static int map_normal[] = { 39 static char map_lcase[] = { 40 [KC_R] = 'p', 41 [KC_T] = 'y', 42 [KC_Y] = 'f', 43 [KC_U] = 'g', 44 [KC_I] = 'c', 45 [KC_O] = 'r', 46 [KC_P] = 'l', 47 48 [KC_A] = 'a', 49 [KC_S] = 'o', 50 [KC_D] = 'e', 51 [KC_F] = 'u', 52 [KC_G] = 'i', 53 [KC_H] = 'd', 54 [KC_J] = 'h', 55 [KC_K] = 't', 56 [KC_L] = 'n', 57 58 [KC_SEMICOLON] = 's', 59 60 [KC_X] = 'q', 61 [KC_C] = 'j', 62 [KC_V] = 'k', 63 [KC_B] = 'x', 64 [KC_N] = 'b', 65 [KC_M] = 'm', 66 67 [KC_COMMA] = 'w', 68 [KC_PERIOD] = 'v', 69 [KC_SLASH] = 'z', 70 }; 71 72 static char map_ucase[] = { 73 [KC_R] = 'P', 74 [KC_T] = 'Y', 75 [KC_Y] = 'F', 76 [KC_U] = 'G', 77 [KC_I] = 'C', 78 [KC_O] = 'R', 79 [KC_P] = 'L', 80 81 [KC_A] = 'A', 82 [KC_S] = 'O', 83 [KC_D] = 'E', 84 [KC_F] = 'U', 85 [KC_G] = 'I', 86 [KC_H] = 'D', 87 [KC_J] = 'H', 88 [KC_K] = 'T', 89 [KC_L] = 'N', 90 91 [KC_SEMICOLON] = 'S', 92 93 [KC_X] = 'Q', 94 [KC_C] = 'J', 95 [KC_V] = 'K', 96 [KC_B] = 'X', 97 [KC_N] = 'B', 98 [KC_M] = 'M', 99 100 [KC_COMMA] = 'W', 101 [KC_PERIOD] = 'V', 102 [KC_SLASH] = 'Z', 103 }; 104 105 static char map_not_shifted[] = { 40 106 [KC_BACKTICK] = '`', 41 107 … … 53 119 [KC_MINUS] = '[', 54 120 [KC_EQUALS] = ']', 55 [KC_BACKSPACE] = '\b',56 57 [KC_TAB] = '\t',58 121 59 122 [KC_Q] = '\'', 60 123 [KC_W] = ',', 61 124 [KC_E] = '.', 62 [KC_R] = 'p',63 [KC_T] = 'y',64 [KC_Y] = 'f',65 [KC_U] = 'g',66 [KC_I] = 'c',67 [KC_O] = 'r',68 [KC_P] = 'l',69 125 70 126 [KC_LBRACKET] = '/', 71 127 [KC_RBRACKET] = '=', 72 128 73 [KC_A] = 'a',74 [KC_S] = 'o',75 [KC_D] = 'e',76 [KC_F] = 'u',77 [KC_G] = 'i',78 [KC_H] = 'd',79 [KC_J] = 'h',80 [KC_K] = 't',81 [KC_L] = 'n',82 83 [KC_SEMICOLON] = 's',84 129 [KC_QUOTE] = '-', 85 130 [KC_BACKSLASH] = '\\', 86 131 87 132 [KC_Z] = ';', 88 [KC_X] = 'q', 89 [KC_C] = 'j', 90 [KC_V] = 'k', 91 [KC_B] = 'x', 92 [KC_N] = 'b', 93 [KC_M] = 'm', 94 95 [KC_COMMA] = 'w', 96 [KC_PERIOD] = 'v', 97 [KC_SLASH] = 'z', 98 133 }; 134 135 static char map_shifted[] = { 136 [KC_BACKTICK] = '~', 137 138 [KC_1] = '!', 139 [KC_2] = '@', 140 [KC_3] = '#', 141 [KC_4] = '$', 142 [KC_5] = '%', 143 [KC_6] = '^', 144 [KC_7] = '&', 145 [KC_8] = '*', 146 [KC_9] = '(', 147 [KC_0] = ')', 148 149 [KC_MINUS] = '{', 150 [KC_EQUALS] = '}', 151 152 [KC_Q] = '"', 153 [KC_W] = '<', 154 [KC_E] = '>', 155 156 [KC_LBRACKET] = '?', 157 [KC_RBRACKET] = '+', 158 159 [KC_QUOTE] = '_', 160 [KC_BACKSLASH] = '|', 161 162 [KC_Z] = ':', 163 }; 164 165 static char map_neutral[] = { 166 [KC_BACKSPACE] = '\b', 167 [KC_TAB] = '\t', 99 168 [KC_ENTER] = '\n' 100 169 }; 170 171 static int translate(unsigned int key, char *map, size_t map_length) 172 { 173 if (key >= map_length) return 0; 174 return map[key]; 175 } 101 176 102 177 char layout_parse_ev(kbd_event_t *ev) 103 178 { 104 if (ev->key >= sizeof(map_normal) / sizeof(int)) 179 char c; 180 181 /* Produce no characters when Ctrl or Alt is pressed. */ 182 if ((ev->mods & (KM_CTRL | KM_ALT)) != 0) 105 183 return 0; 106 184 107 return map_normal[ev->key]; 185 c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char)); 186 if (c != 0) return c; 187 188 if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) 189 c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(char)); 190 else 191 c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(char)); 192 193 if (c != 0) return c; 194 195 if ((ev->mods & KM_SHIFT) != 0) 196 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char)); 197 else 198 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char)); 199 200 if (c != 0 ) return c; 201 108 202 } 203 109 204 110 205 /** -
uspace/srv/kbd/layout/us_qwerty.c
r91825d90 rd1eece6 37 37 #include <layout.h> 38 38 39 static int map_normal[] = { 39 static char map_lcase[] = { 40 [KC_Q] = 'q', 41 [KC_W] = 'w', 42 [KC_E] = 'e', 43 [KC_R] = 'r', 44 [KC_T] = 't', 45 [KC_Y] = 'y', 46 [KC_U] = 'u', 47 [KC_I] = 'i', 48 [KC_O] = 'o', 49 [KC_P] = 'p', 50 51 [KC_A] = 'a', 52 [KC_S] = 's', 53 [KC_D] = 'd', 54 [KC_F] = 'f', 55 [KC_G] = 'g', 56 [KC_H] = 'h', 57 [KC_J] = 'j', 58 [KC_K] = 'k', 59 [KC_L] = 'l', 60 61 [KC_Z] = 'z', 62 [KC_X] = 'x', 63 [KC_C] = 'c', 64 [KC_V] = 'v', 65 [KC_B] = 'b', 66 [KC_N] = 'n', 67 [KC_M] = 'm', 68 }; 69 70 static char map_ucase[] = { 71 [KC_Q] = 'Q', 72 [KC_W] = 'W', 73 [KC_E] = 'E', 74 [KC_R] = 'R', 75 [KC_T] = 'T', 76 [KC_Y] = 'Y', 77 [KC_U] = 'U', 78 [KC_I] = 'I', 79 [KC_O] = 'O', 80 [KC_P] = 'P', 81 82 [KC_A] = 'A', 83 [KC_S] = 'S', 84 [KC_D] = 'D', 85 [KC_F] = 'F', 86 [KC_G] = 'G', 87 [KC_H] = 'H', 88 [KC_J] = 'J', 89 [KC_K] = 'K', 90 [KC_L] = 'L', 91 92 [KC_Z] = 'Z', 93 [KC_X] = 'X', 94 [KC_C] = 'C', 95 [KC_V] = 'V', 96 [KC_B] = 'B', 97 [KC_N] = 'N', 98 [KC_M] = 'M', 99 }; 100 101 static char map_not_shifted[] = { 40 102 [KC_BACKTICK] = '`', 41 103 … … 53 115 [KC_MINUS] = '-', 54 116 [KC_EQUALS] = '=', 55 [KC_BACKSPACE] = '\b',56 57 [KC_TAB] = '\t',58 59 [KC_Q] = 'q',60 [KC_W] = 'w',61 [KC_E] = 'e',62 [KC_R] = 'r',63 [KC_T] = 't',64 [KC_Y] = 'y',65 [KC_U] = 'u',66 [KC_I] = 'i',67 [KC_O] = 'o',68 [KC_P] = 'p',69 117 70 118 [KC_LBRACKET] = '[', 71 119 [KC_RBRACKET] = ']', 72 73 [KC_A] = 'a',74 [KC_S] = 's',75 [KC_D] = 'd',76 [KC_F] = 'f',77 [KC_G] = 'g',78 [KC_H] = 'h',79 [KC_J] = 'j',80 [KC_K] = 'k',81 [KC_L] = 'l',82 120 83 121 [KC_SEMICOLON] = ';', 84 122 [KC_QUOTE] = '\'', 85 123 [KC_BACKSLASH] = '\\', 86 [KC_ENTER] = '\n',87 88 [KC_Z] = 'z',89 [KC_X] = 'x',90 [KC_C] = 'c',91 [KC_V] = 'v',92 [KC_B] = 'b',93 [KC_N] = 'n',94 [KC_M] = 'm',95 124 96 125 [KC_COMMA] = ',', 97 126 [KC_PERIOD] = '.', 98 127 [KC_SLASH] = '/', 99 128 }; 129 130 static char map_shifted[] = { 131 [KC_BACKTICK] = '~', 132 133 [KC_1] = '!', 134 [KC_2] = '@', 135 [KC_3] = '#', 136 [KC_4] = '$', 137 [KC_5] = '%', 138 [KC_6] = '^', 139 [KC_7] = '&', 140 [KC_8] = '*', 141 [KC_9] = '(', 142 [KC_0] = ')', 143 144 [KC_MINUS] = '_', 145 [KC_EQUALS] = '+', 146 147 [KC_LBRACKET] = '{', 148 [KC_RBRACKET] = '}', 149 150 [KC_SEMICOLON] = ':', 151 [KC_QUOTE] = '"', 152 [KC_BACKSLASH] = '|', 153 154 [KC_COMMA] = '<', 155 [KC_PERIOD] = '>', 156 [KC_SLASH] = '?', 157 }; 158 159 static char map_neutral[] = { 160 [KC_BACKSPACE] = '\b', 161 [KC_TAB] = '\t', 162 [KC_ENTER] = '\n', 100 163 [KC_SPACE] = ' ' 101 164 }; 165 166 static int translate(unsigned int key, char *map, size_t map_length) 167 { 168 if (key >= map_length) return 0; 169 return map[key]; 170 } 102 171 103 172 char layout_parse_ev(kbd_event_t *ev) 104 173 { 105 if (ev->key >= sizeof(map_normal) / sizeof(int)) 174 char c; 175 176 /* Produce no characters when Ctrl or Alt is pressed. */ 177 if ((ev->mods & (KM_CTRL | KM_ALT)) != 0) 106 178 return 0; 107 179 108 return map_normal[ev->key]; 180 c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char)); 181 if (c != 0) return c; 182 183 if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) 184 c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(char)); 185 else 186 c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(char)); 187 188 if (c != 0) return c; 189 190 if ((ev->mods & KM_SHIFT) != 0) 191 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char)); 192 else 193 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char)); 194 195 if (c != 0 ) return c; 196 109 197 } 110 198
Note:
See TracChangeset
for help on using the changeset viewer.