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