Changeset 07b7c48 in mainline
- Timestamp:
- 2013-04-12T09:01:10Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 902f0906
- Parents:
- bc4bf97
- Location:
- uspace
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cat/cat.c
rbc4bf97 r07b7c48 117 117 static void waitkey() 118 118 { 119 kbd_event_t ev; 119 cons_event_t ev; 120 kbd_event_t *kev; 120 121 121 122 while (true) { 122 if (!console_get_ kbd_event(console, &ev)) {123 if (!console_get_event(console, &ev)) { 123 124 return; 124 125 } 125 if (ev.type == KEY_PRESS) { 126 if (ev.key == KC_ESCAPE || ev.key == KC_Q) { 126 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) { 127 kev = &ev.ev.key; 128 129 if (kev->key == KC_ESCAPE || kev->key == KC_Q) { 127 130 should_quit = true; 128 131 return; 129 132 } 130 if ( ev.key == KC_C) {133 if (kev->key == KC_C) { 131 134 paging_enabled = false; 132 135 return; 133 136 } 134 if ( ev.key == KC_ENTER || ev.key == KC_SPACE ||135 ev.key == KC_PAGE_DOWN) {137 if (kev->key == KC_ENTER || kev->key == KC_SPACE || 138 kev->key == KC_PAGE_DOWN) { 136 139 return; 137 140 } -
uspace/app/bdsh/cmds/modules/cp/cp.c
rbc4bf97 r07b7c48 152 152 153 153 while (true) { 154 kbd_event_t ev;154 cons_event_t ev; 155 155 console_flush(con); 156 console_get_ kbd_event(con, &ev);157 if ( (ev.type != KEY_PRESS)158 || (ev.mods & (KM_CTRL | KM_ALT)) != 0) {156 console_get_event(con, &ev); 157 if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS || 158 (ev.ev.key.mods & (KM_CTRL | KM_ALT)) != 0) { 159 159 continue; 160 160 } 161 161 162 switch(ev. key) {162 switch(ev.ev.key.key) { 163 163 case KC_Y: 164 164 printf("y\n"); -
uspace/app/edit/edit.c
rbc4bf97 r07b7c48 182 182 int main(int argc, char *argv[]) 183 183 { 184 kbd_event_t ev; 184 cons_event_t ev; 185 kbd_event_t *kev; 185 186 bool new_file; 186 187 int rc; … … 245 246 246 247 while (!done) { 247 console_get_ kbd_event(con, &ev);248 console_get_event(con, &ev); 248 249 pane.rflags = 0; 249 250 250 if (ev.type == KEY_PRESS) { 251 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) { 252 kev = &ev.ev.key; 253 251 254 /* Handle key press. */ 252 if ((( ev.mods & KM_ALT) == 0) &&253 (( ev.mods & KM_SHIFT) == 0) &&254 ( ev.mods & KM_CTRL) != 0) {255 key_handle_ctrl( &ev);256 } else if ((( ev.mods & KM_ALT) == 0) &&257 (( ev.mods & KM_CTRL) == 0) &&258 ( ev.mods & KM_SHIFT) != 0) {259 key_handle_shift( &ev);260 } else if ((( ev.mods & KM_ALT) == 0) &&261 (( ev.mods & KM_CTRL) != 0) &&262 ( ev.mods & KM_SHIFT) != 0) {263 key_handle_shift_ctrl( &ev);264 } else if (( ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) {265 key_handle_unmod( &ev);255 if (((kev->mods & KM_ALT) == 0) && 256 ((kev->mods & KM_SHIFT) == 0) && 257 (kev->mods & KM_CTRL) != 0) { 258 key_handle_ctrl(kev); 259 } else if (((kev->mods & KM_ALT) == 0) && 260 ((kev->mods & KM_CTRL) == 0) && 261 (kev->mods & KM_SHIFT) != 0) { 262 key_handle_shift(kev); 263 } else if (((kev->mods & KM_ALT) == 0) && 264 ((kev->mods & KM_CTRL) != 0) && 265 (kev->mods & KM_SHIFT) != 0) { 266 key_handle_shift_ctrl(kev); 267 } else if ((kev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) { 268 key_handle_unmod(kev); 266 269 } 267 270 } … … 592 595 static char *prompt(char const *prompt, char const *init_value) 593 596 { 594 kbd_event_t ev; 597 cons_event_t ev; 598 kbd_event_t *kev; 595 599 char *str; 596 600 wchar_t buffer[INFNAME_MAX_LEN + 1]; … … 612 616 613 617 while (!done) { 614 console_get_kbd_event(con, &ev); 615 616 if (ev.type == KEY_PRESS) { 618 console_get_event(con, &ev); 619 620 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) { 621 kev = &ev.ev.key; 622 617 623 /* Handle key press. */ 618 if ((( ev.mods & KM_ALT) == 0) &&619 ( ev.mods & KM_CTRL) != 0) {624 if (((kev->mods & KM_ALT) == 0) && 625 (kev->mods & KM_CTRL) != 0) { 620 626 ; 621 } else if (( ev.mods & (KM_CTRL | KM_ALT)) == 0) {622 switch ( ev.key) {627 } else if ((kev->mods & (KM_CTRL | KM_ALT)) == 0) { 628 switch (kev->key) { 623 629 case KC_ESCAPE: 624 630 return NULL; … … 634 640 break; 635 641 default: 636 if ( ev.c >= 32 && nc < max_len) {637 putchar( ev.c);642 if (kev->c >= 32 && nc < max_len) { 643 putchar(kev->c); 638 644 console_flush(con); 639 buffer[nc++] = ev.c;645 buffer[nc++] = kev->c; 640 646 } 641 647 break; -
uspace/app/mkbd/main.c
rbc4bf97 r07b7c48 178 178 179 179 while (1) { 180 kbd_event_t ev;181 bool ok = console_get_ kbd_event(con, &ev);180 cons_event_t ev; 181 bool ok = console_get_event(con, &ev); 182 182 if (!ok) { 183 183 printf("Connection with console broken: %s.\n", … … 186 186 } 187 187 188 if (ev.key == KC_ESCAPE) { 188 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS && 189 ev.ev.key.key == KC_ESCAPE) { 189 190 break; 190 191 } -
uspace/app/msim/arch_helenos/input.c
rbc4bf97 r07b7c48 91 91 bool stdin_poll(char *key) 92 92 { 93 kbd_event_t ev;93 cons_event_t ev; 94 94 suseconds_t timeout = 0; 95 95 errno = EOK; 96 96 console_flush(input_prompt->console); 97 bool has_input = console_get_ kbd_event_timeout(input_prompt->console, &ev, &timeout);97 bool has_input = console_get_event_timeout(input_prompt->console, &ev, &timeout); 98 98 if (!has_input) { 99 99 return false; 100 100 } 101 101 102 if (ev.type != KEY_PRESS)102 if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS) 103 103 return false; 104 104 105 *key = ev. c;105 *key = ev.ev.key.c; 106 106 107 107 return true; -
uspace/app/nterm/nterm.c
rbc4bf97 r07b7c48 109 109 int main(int argc, char *argv[]) 110 110 { 111 kbd_event_t ev;111 cons_event_t ev; 112 112 int rc; 113 113 … … 129 129 done = false; 130 130 while (!done) { 131 console_get_ kbd_event(con, &ev);132 if (ev.type == KEY_PRESS)133 key_handle(&ev );131 console_get_event(con, &ev); 132 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) 133 key_handle(&ev.ev.key); 134 134 } 135 135 -
uspace/app/ping/ping.c
rbc4bf97 r07b7c48 188 188 { 189 189 console_ctrl_t *con; 190 kbd_event_t ev;190 cons_event_t ev; 191 191 192 192 con = console_init(stdin, stdout); … … 194 194 195 195 while (true) { 196 if (!console_get_ kbd_event(con, &ev))196 if (!console_get_event(con, &ev)) 197 197 break; 198 198 199 if (ev.type == KEY_PRESS && (ev.mods & (KM_ALT | KM_SHIFT)) == 200 0 && (ev.mods & KM_CTRL) != 0) { 199 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS && 200 (ev.ev.key.mods & (KM_ALT | KM_SHIFT)) == 201 0 && (ev.ev.key.mods & KM_CTRL) != 0) { 201 202 /* Ctrl+key */ 202 if (ev. key == KC_Q) {203 if (ev.ev.key.key == KC_Q) { 203 204 ping_signal_done(); 204 205 return 0; -
uspace/app/tester/ipc/starve.c
rbc4bf97 r07b7c48 62 62 break; 63 63 64 kbd_event_t ev;64 cons_event_t ev; 65 65 suseconds_t timeout = 0; 66 bool has_event = console_get_ kbd_event_timeout(console, &ev, &timeout);67 if (has_event && (ev.type == KEY_PRESS)) {68 TPRINTF("Key %d pressed, terminating.\n", ev. key);66 bool has_event = console_get_event_timeout(console, &ev, &timeout); 67 if (has_event && ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) { 68 TPRINTF("Key %d pressed, terminating.\n", ev.ev.key.key); 69 69 break; 70 70 } -
uspace/app/tetris/scores.c
rbc4bf97 r07b7c48 125 125 int j; 126 126 size_t off; 127 kbd_event_t ev; 127 cons_event_t ev; 128 kbd_event_t *kev; 128 129 129 130 clear_screen(); … … 141 142 while (1) { 142 143 console_flush(console); 143 if (!console_get_ kbd_event(console, &ev))144 if (!console_get_event(console, &ev)) 144 145 exit(1); 145 146 146 if (ev.type == KEY_RELEASE)147 if (ev.type != CEV_KEY || ev.ev.key.type == KEY_RELEASE) 147 148 continue; 148 149 149 if (ev.key == KC_ENTER || ev.key == KC_NENTER) 150 kev = &ev.ev.key; 151 152 if (kev->key == KC_ENTER || kev->key == KC_NENTER) 150 153 break; 151 154 152 if ( ev.key == KC_BACKSPACE) {155 if (kev->key == KC_BACKSPACE) { 153 156 if (i > 0) { 154 157 wchar_t uc; … … 166 169 scores[NUMSPOTS - 1].hs_name[off] = '\0'; 167 170 } 168 } else if ( ev.c != '\0') {171 } else if (kev->c != '\0') { 169 172 if (i < (MAXLOGNAME - 1)) { 170 if (chr_encode( ev.c, scores[NUMSPOTS - 1].hs_name,173 if (chr_encode(kev->c, scores[NUMSPOTS - 1].hs_name, 171 174 &off, STR_BOUNDS(MAXLOGNAME) + 1) == EOK) { 172 175 ++i; -
uspace/app/tetris/screen.c
rbc4bf97 r07b7c48 344 344 345 345 while (timeout > 0) { 346 kbd_event_t event;347 348 if (!console_get_ kbd_event_timeout(console, &event, &timeout))346 cons_event_t event; 347 348 if (!console_get_event_timeout(console, &event, &timeout)) 349 349 break; 350 350 } … … 376 376 377 377 while (c == 0) { 378 kbd_event_t event;379 380 if (!console_get_ kbd_event_timeout(console, &event, &timeleft)) {378 cons_event_t event; 379 380 if (!console_get_event_timeout(console, &event, &timeleft)) { 381 381 timeleft = 0; 382 382 return -1; 383 383 } 384 384 385 if (event.type == KEY_PRESS)386 c = event. c;385 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) 386 c = event.ev.key.c; 387 387 } 388 388 … … 398 398 399 399 while (c == 0) { 400 kbd_event_t event;401 402 if (!console_get_ kbd_event(console, &event))400 cons_event_t event; 401 402 if (!console_get_event(console, &event)) 403 403 return -1; 404 404 405 if (event.type == KEY_PRESS)406 c = event. c;405 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) 406 c = event.ev.key.c; 407 407 } 408 408 -
uspace/app/top/screen.c
rbc4bf97 r07b7c48 556 556 557 557 while (c == 0) { 558 kbd_event_t event;558 cons_event_t event; 559 559 560 560 warning_timeleft -= timeleft; 561 if (!console_get_ kbd_event_timeout(console, &event, &timeleft)) {561 if (!console_get_event_timeout(console, &event, &timeleft)) { 562 562 timeleft = 0; 563 563 return -1; … … 565 565 warning_timeleft += timeleft; 566 566 567 if (event.type == KEY_PRESS)568 c = event. c;567 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) 568 c = event.ev.key.c; 569 569 } 570 570 -
uspace/app/trace/trace.c
rbc4bf97 r07b7c48 565 565 static int cev_fibril(void *arg) 566 566 { 567 cons_event_t event; 568 567 569 (void) arg; 568 570 … … 575 577 fibril_mutex_unlock(&state_lock); 576 578 577 if (!console_get_ kbd_event(console, &cev))579 if (!console_get_event(console, &event)) 578 580 return -1; 579 581 580 fibril_mutex_lock(&state_lock); 581 cev_valid = true; 582 fibril_condvar_broadcast(&state_cv); 583 fibril_mutex_unlock(&state_lock); 582 if (event.type == CEV_KEY) { 583 fibril_mutex_lock(&state_lock); 584 cev = event.ev.key; 585 cev_valid = true; 586 fibril_condvar_broadcast(&state_cv); 587 fibril_mutex_unlock(&state_lock); 588 } 584 589 } 585 590 } -
uspace/dist/src/c/demos/tetris/scores.c
rbc4bf97 r07b7c48 125 125 int j; 126 126 size_t off; 127 kbd_event_t ev; 127 cons_event_t ev; 128 kbd_event_t *kev; 128 129 129 130 clear_screen(); … … 141 142 while (1) { 142 143 console_flush(console); 143 if (!console_get_ kbd_event(console, &ev))144 if (!console_get_event(console, &ev)) 144 145 exit(1); 145 146 146 if (ev.type == KEY_RELEASE)147 if (ev.type != CEV_KEY || ev.ev.key.type == KEY_RELEASE) 147 148 continue; 148 149 149 if (ev.key == KC_ENTER || ev.key == KC_NENTER) 150 kev = &ev.ev.key; 151 152 if (kev->key == KC_ENTER || kev->key == KC_NENTER) 150 153 break; 151 154 152 if ( ev.key == KC_BACKSPACE) {155 if (kev->key == KC_BACKSPACE) { 153 156 if (i > 0) { 154 157 wchar_t uc; … … 166 169 scores[NUMSPOTS - 1].hs_name[off] = '\0'; 167 170 } 168 } else if ( ev.c != '\0') {171 } else if (kev->c != '\0') { 169 172 if (i < (MAXLOGNAME - 1)) { 170 if (chr_encode( ev.c, scores[NUMSPOTS - 1].hs_name,173 if (chr_encode(kev->c, scores[NUMSPOTS - 1].hs_name, 171 174 &off, STR_BOUNDS(MAXLOGNAME) + 1) == EOK) { 172 175 ++i; -
uspace/dist/src/c/demos/top/screen.c
rbc4bf97 r07b7c48 553 553 554 554 while (c == 0) { 555 kbd_event_t event;556 557 if (!console_get_ kbd_event_timeout(console, &event, &timeleft)) {555 cons_event_t event; 556 557 if (!console_get_event_timeout(console, &event, &timeleft)) { 558 558 timeleft = 0; 559 559 return -1; 560 560 } 561 561 562 if (event.type == KEY_PRESS)563 c = event. c;562 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) 563 c = event.ev.key.c; 564 564 } 565 565 -
uspace/lib/c/generic/io/console.c
rbc4bf97 r07b7c48 154 154 } 155 155 156 bool console_get_ kbd_event(console_ctrl_t *ctrl, kbd_event_t *event)156 bool console_get_event(console_ctrl_t *ctrl, cons_event_t *event) 157 157 { 158 158 if (ctrl->input_aid == 0) { … … 171 171 } 172 172 173 event->type = type; 174 event->key = key; 175 event->mods = mods; 176 event->c = c; 173 event->type = CEV_KEY; 174 event->ev.key.type = type; 175 event->ev.key.key = key; 176 event->ev.key.mods = mods; 177 event->ev.key.c = c; 177 178 } else { 178 179 sysarg_t retval; … … 186 187 } 187 188 188 event->type = IPC_GET_ARG1(ctrl->input_call); 189 event->key = IPC_GET_ARG2(ctrl->input_call); 190 event->mods = IPC_GET_ARG3(ctrl->input_call); 191 event->c = IPC_GET_ARG4(ctrl->input_call); 189 event->type = CEV_KEY; 190 event->ev.key.type = IPC_GET_ARG1(ctrl->input_call); 191 event->ev.key.key = IPC_GET_ARG2(ctrl->input_call); 192 event->ev.key.mods = IPC_GET_ARG3(ctrl->input_call); 193 event->ev.key.c = IPC_GET_ARG4(ctrl->input_call); 192 194 } 193 195 … … 195 197 } 196 198 197 bool console_get_ kbd_event_timeout(console_ctrl_t *ctrl, kbd_event_t *event,199 bool console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event, 198 200 suseconds_t *timeout) 199 201 { … … 223 225 } 224 226 225 event->type = IPC_GET_ARG1(ctrl->input_call); 226 event->key = IPC_GET_ARG2(ctrl->input_call); 227 event->mods = IPC_GET_ARG3(ctrl->input_call); 228 event->c = IPC_GET_ARG4(ctrl->input_call); 227 event->type = CEV_KEY; 228 event->ev.key.type = IPC_GET_ARG1(ctrl->input_call); 229 event->ev.key.key = IPC_GET_ARG2(ctrl->input_call); 230 event->ev.key.mods = IPC_GET_ARG3(ctrl->input_call); 231 event->ev.key.c = IPC_GET_ARG4(ctrl->input_call); 229 232 230 233 /* Update timeout */ -
uspace/lib/c/include/io/console.h
rbc4bf97 r07b7c48 39 39 #include <io/concaps.h> 40 40 #include <io/kbd_event.h> 41 #include <io/cons_event.h> 41 42 #include <io/keycode.h> 42 43 #include <async.h> … … 82 83 extern void console_cursor_visibility(console_ctrl_t *, bool); 83 84 extern int console_get_color_cap(console_ctrl_t *, sysarg_t *); 84 extern bool console_get_ kbd_event(console_ctrl_t *, kbd_event_t *);85 extern bool console_get_ kbd_event_timeout(console_ctrl_t *, kbd_event_t *,85 extern bool console_get_event(console_ctrl_t *, cons_event_t *); 86 extern bool console_get_event_timeout(console_ctrl_t *, cons_event_t *, 86 87 suseconds_t *); 87 88 -
uspace/lib/clui/tinput.c
rbc4bf97 r07b7c48 816 816 console_flush(ti->console); 817 817 818 kbd_event_t ev;819 if (!console_get_ kbd_event(ti->console, &ev))818 cons_event_t ev; 819 if (!console_get_event(ti->console, &ev)) 820 820 return EIO; 821 821 822 if (ev.type != KEY_PRESS)822 if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS) 823 823 continue; 824 824 825 if (((ev.mods & KM_CTRL) != 0) && 826 ((ev.mods & (KM_ALT | KM_SHIFT)) == 0)) 827 tinput_key_ctrl(ti, &ev); 828 829 if (((ev.mods & KM_SHIFT) != 0) && 830 ((ev.mods & (KM_CTRL | KM_ALT)) == 0)) 831 tinput_key_shift(ti, &ev); 832 833 if (((ev.mods & KM_CTRL) != 0) && 834 ((ev.mods & KM_SHIFT) != 0) && 835 ((ev.mods & KM_ALT) == 0)) 836 tinput_key_ctrl_shift(ti, &ev); 837 838 if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) 839 tinput_key_unmod(ti, &ev); 840 841 if (ev.c >= ' ') { 825 kbd_event_t *kev = &ev.ev.key; 826 827 if (((kev->mods & KM_CTRL) != 0) && 828 ((kev->mods & (KM_ALT | KM_SHIFT)) == 0)) 829 tinput_key_ctrl(ti, kev); 830 831 if (((kev->mods & KM_SHIFT) != 0) && 832 ((kev->mods & (KM_CTRL | KM_ALT)) == 0)) 833 tinput_key_shift(ti, kev); 834 835 if (((kev->mods & KM_CTRL) != 0) && 836 ((kev->mods & KM_SHIFT) != 0) && 837 ((kev->mods & KM_ALT) == 0)) 838 tinput_key_ctrl_shift(ti, kev); 839 840 if ((kev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) 841 tinput_key_unmod(ti, kev); 842 843 if (kev->c >= ' ') { 842 844 tinput_sel_delete(ti); 843 tinput_insert_char(ti, ev.c);845 tinput_insert_char(ti, kev->c); 844 846 } 845 847 }
Note:
See TracChangeset
for help on using the changeset viewer.