Changes in uspace/srv/hid/console/console.c [2f90b46:8a99c7e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/console.c
r2f90b46 r8a99c7e 76 76 } console_state_t; 77 77 78 #define UTF8_CHAR_BUFFER_SIZE (STR_BOUNDS(1) + 1) 79 78 80 typedef struct { 79 81 atomic_t refcnt; /**< Connection reference count */ 80 82 prodcons_t input_pc; /**< Incoming keyboard events */ 83 char char_remains[UTF8_CHAR_BUFFER_SIZE]; /**< Not yet sent bytes of last char event. */ 84 size_t char_remains_len; /**< Number of not yet sent bytes. */ 81 85 82 86 fibril_mutex_t mtx; /**< Lock protecting mutable fields */ … … 379 383 380 384 fb_pointer_update(fb_sess, mouse.x, mouse.y, true); 385 } 386 387 static void cons_mouse_abs_move(sysarg_t x, sysarg_t y, 388 sysarg_t max_x, sysarg_t max_y) 389 { 390 if (max_x && max_y) { 391 mouse.x = limit(x * xres / max_x, 0, xres); 392 mouse.y = limit(y * yres / max_y, 0, yres); 393 394 fb_pointer_update(fb_sess, mouse.x, mouse.y, true); 395 } 381 396 } 382 397 … … 499 514 async_answer_0(callid, EOK); 500 515 break; 516 case INPUT_EVENT_ABS_MOVE: 517 cons_mouse_abs_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call), 518 IPC_GET_ARG3(call), IPC_GET_ARG4(call)); 519 async_answer_0(callid, EOK); 520 break; 501 521 case INPUT_EVENT_BUTTON: 502 522 /* Got pointer button press/release event */ … … 613 633 614 634 size_t pos = 0; 635 636 /* 637 * Read input from keyboard and copy it to the buffer. 638 * We need to handle situation when wchar is split by 2 following 639 * reads. 640 */ 615 641 while (pos < size) { 616 link_t *link = prodcons_consume(&cons->input_pc); 617 kbd_event_t *event = list_get_instance(link, kbd_event_t, link); 618 619 if (event->type == KEY_PRESS) { 620 buf[pos] = event->c; 642 /* Copy to the buffer remaining characters. */ 643 while ((pos < size) && (cons->char_remains_len > 0)) { 644 buf[pos] = cons->char_remains[0]; 621 645 pos++; 622 } 623 624 free(event); 646 647 /* Unshift the array. */ 648 for (size_t i = 1; i < cons->char_remains_len; i++) 649 cons->char_remains[i - 1] = cons->char_remains[i]; 650 651 cons->char_remains_len--; 652 } 653 654 /* Still not enough? Then get another key from the queue. */ 655 if (pos < size) { 656 link_t *link = prodcons_consume(&cons->input_pc); 657 kbd_event_t *event = list_get_instance(link, kbd_event_t, link); 658 659 /* Accept key presses of printable chars only. */ 660 if ((event->type == KEY_PRESS) && (event->c != 0)) { 661 wchar_t tmp[2] = { event->c, 0 }; 662 wstr_to_str(cons->char_remains, UTF8_CHAR_BUFFER_SIZE, tmp); 663 cons->char_remains_len = str_size(cons->char_remains); 664 } 665 666 free(event); 667 } 625 668 } 626 669 … … 930 973 fibril_mutex_initialize(&consoles[i].mtx); 931 974 prodcons_initialize(&consoles[i].input_pc); 975 consoles[i].char_remains_len = 0; 932 976 933 977 if (graphics_state == GRAPHICS_FULL) {
Note:
See TracChangeset
for help on using the changeset viewer.