Changes in uspace/srv/hid/console/console.c [e273e9e:5d1ff11] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/console.c
re273e9e r5d1ff11 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * Copyright (c) 2011 Martin Decky 4 4 * All rights reserved. … … 37 37 #include <stdio.h> 38 38 #include <adt/prodcons.h> 39 #include <io/console.h>40 39 #include <io/input.h> 41 40 #include <ipc/vfs.h> … … 90 89 } console_t; 91 90 92 static loc_srv_t *console_srv;93 94 91 /** Input server proxy */ 95 92 static input_t *input; … … 123 120 static errno_t input_ev_active(input_t *); 124 121 static errno_t input_ev_deactive(input_t *); 125 static errno_t input_ev_key(input_t *, unsigned, kbd_event_type_t, keycode_t, 126 keymod_t, char32_t); 127 static errno_t input_ev_move(input_t *, unsigned, int, int); 128 static errno_t input_ev_abs_move(input_t *, unsigned, unsigned, unsigned, 129 unsigned, unsigned); 130 static errno_t input_ev_button(input_t *, unsigned, int, int); 131 static errno_t input_ev_dclick(input_t *, unsigned, int); 122 static errno_t input_ev_key(input_t *, kbd_event_type_t, keycode_t, keymod_t, char32_t); 123 static errno_t input_ev_move(input_t *, int, int); 124 static errno_t input_ev_abs_move(input_t *, unsigned, unsigned, unsigned, unsigned); 125 static errno_t input_ev_button(input_t *, int, int); 132 126 133 127 static input_ev_ops_t input_ev_ops = { … … 137 131 .move = input_ev_move, 138 132 .abs_move = input_ev_abs_move, 139 .button = input_ev_button, 140 .dclick = input_ev_dclick 133 .button = input_ev_button 141 134 }; 142 135 … … 156 149 static void cons_set_rgb_color(con_srv_t *, pixel_t, pixel_t); 157 150 static void cons_set_cursor_visibility(con_srv_t *, bool); 158 static errno_t cons_set_caption(con_srv_t *, const char *);159 151 static errno_t cons_get_event(con_srv_t *, cons_event_t *); 160 152 static errno_t cons_map(con_srv_t *, sysarg_t, sysarg_t, charfield_t **); … … 178 170 .set_rgb_color = cons_set_rgb_color, 179 171 .set_cursor_visibility = cons_set_cursor_visibility, 180 .set_caption = cons_set_caption,181 172 .get_event = cons_get_event, 182 173 .map = cons_map, … … 334 325 { 335 326 /* Got key press/release event */ 336 cons_ qevent_t *event =337 (cons_ qevent_t *) malloc(sizeof(cons_qevent_t));327 cons_event_t *event = 328 (cons_event_t *) malloc(sizeof(cons_event_t)); 338 329 if (event == NULL) 339 330 return; 340 331 341 event->ev= *ev;332 *event = *ev; 342 333 link_initialize(&event->link); 343 334 … … 362 353 } 363 354 364 static errno_t input_ev_key(input_t *input, unsigned kbd_id,365 k bd_event_type_t type, keycode_t key, keymod_t mods, char32_t c)355 static errno_t input_ev_key(input_t *input, kbd_event_type_t type, keycode_t key, 356 keymod_t mods, char32_t c) 366 357 { 367 358 cons_event_t event; 368 bool alt; 369 bool shift; 370 371 alt = (mods & KM_ALT) != 0 && (mods & (KM_CTRL | KM_SHIFT)) == 0; 372 shift = (mods & KM_SHIFT) != 0 && (mods & (KM_CTRL | KM_ALT)) == 0; 373 374 /* Switch console on Alt+Fn or Shift+Fn */ 359 375 360 if ((key >= KC_F1) && (key <= KC_F1 + CONSOLE_COUNT) && 376 ( alt || shift)) {361 ((mods & KM_CTRL) == 0)) { 377 362 cons_switch(key - KC_F1); 378 363 } else { … … 380 365 event.type = CEV_KEY; 381 366 382 (void)kbd_id;383 367 event.ev.key.type = type; 384 368 event.ev.key.key = key; … … 429 413 } 430 414 431 static errno_t input_ev_move(input_t *input, unsigned pos_id, int dx, int dy) 432 { 433 (void) pos_id; 415 static errno_t input_ev_move(input_t *input, int dx, int dy) 416 { 434 417 pointer_update(pointer_x + dx, pointer_y + dy); 435 418 return EOK; 436 419 } 437 420 438 static errno_t input_ev_abs_move(input_t *input, unsigned pos_id, unsigned x, 439 unsigned y, unsigned max_x, unsigned max_y) 440 { 441 (void)pos_id; 421 static errno_t input_ev_abs_move(input_t *input, unsigned x, unsigned y, 422 unsigned max_x, unsigned max_y) 423 { 442 424 pointer_update(mouse_scale_x * cols * x / max_x, mouse_scale_y * rows * y / max_y); 443 425 return EOK; 444 426 } 445 427 446 static errno_t input_ev_button(input_t *input, unsigned pos_id, int bnum, 447 int bpress) 428 static errno_t input_ev_button(input_t *input, int bnum, int bpress) 448 429 { 449 430 cons_event_t event; 450 451 (void)pos_id;452 431 453 432 event.type = CEV_POS; 454 433 event.ev.pos.type = bpress ? POS_PRESS : POS_RELEASE; 455 event.ev.pos.btn_num = bnum;456 event.ev.pos.hpos = pointer_x / mouse_scale_x;457 event.ev.pos.vpos = pointer_y / mouse_scale_y;458 459 console_queue_cons_event(active_console, &event);460 return EOK;461 }462 463 static errno_t input_ev_dclick(input_t *input, unsigned pos_id, int bnum)464 {465 cons_event_t event;466 467 (void)pos_id;468 469 event.type = CEV_POS;470 event.ev.pos.type = POS_DCLICK;471 434 event.ev.pos.btn_num = bnum; 472 435 event.ev.pos.hpos = pointer_x / mouse_scale_x; … … 556 519 if (pos < size) { 557 520 link_t *link = prodcons_consume(&cons->input_pc); 558 cons_qevent_t *qevent = list_get_instance(link, 559 cons_qevent_t, link); 560 cons_event_t *event = &qevent->ev; 521 cons_event_t *event = list_get_instance(link, 522 cons_event_t, link); 561 523 562 524 /* Accept key presses of printable chars only. */ … … 568 530 } 569 531 570 free( qevent);532 free(event); 571 533 } 572 534 } … … 691 653 } 692 654 693 static errno_t cons_set_caption(con_srv_t *srv, const char *caption)694 {695 console_t *cons = srv_to_console(srv);696 697 (void) cons;698 (void) caption;699 return EOK;700 }701 702 655 static errno_t cons_get_event(con_srv_t *srv, cons_event_t *event) 703 656 { 704 657 console_t *cons = srv_to_console(srv); 705 658 link_t *link = prodcons_consume(&cons->input_pc); 706 cons_ qevent_t *qevent = list_get_instance(link, cons_qevent_t, link);707 708 *event = qevent->ev;709 free( qevent);659 cons_event_t *cevent = list_get_instance(link, cons_event_t, link); 660 661 *event = *cevent; 662 free(cevent); 710 663 return EOK; 711 664 } … … 912 865 /* Register server */ 913 866 async_set_fallback_port_handler(client_connection, NULL); 914 rc = loc_server_register(NAME , &console_srv);867 rc = loc_server_register(NAME); 915 868 if (rc != EOK) { 916 869 printf("%s: Unable to register server (%s)\n", NAME, … … 962 915 snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i); 963 916 964 if (loc_service_register(console_srv, vc, 965 &consoles[i].dsid) != EOK) { 917 if (loc_service_register(vc, &consoles[i].dsid) != EOK) { 966 918 printf("%s: Unable to register device %s\n", NAME, vc); 967 919 return false;
Note:
See TracChangeset
for help on using the changeset viewer.