Changes in uspace/srv/hid/console/console.c [49aaa0e:5d1ff11] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/console.c
r49aaa0e 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, … … 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; … … 690 653 } 691 654 692 static errno_t cons_set_caption(con_srv_t *srv, const char *caption)693 {694 console_t *cons = srv_to_console(srv);695 696 (void) cons;697 (void) caption;698 return EOK;699 }700 701 655 static errno_t cons_get_event(con_srv_t *srv, cons_event_t *event) 702 656 { … … 911 865 /* Register server */ 912 866 async_set_fallback_port_handler(client_connection, NULL); 913 rc = loc_server_register(NAME , &console_srv);867 rc = loc_server_register(NAME); 914 868 if (rc != EOK) { 915 869 printf("%s: Unable to register server (%s)\n", NAME, … … 961 915 snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i); 962 916 963 if (loc_service_register(console_srv, vc, 964 &consoles[i].dsid) != EOK) { 917 if (loc_service_register(vc, &consoles[i].dsid) != EOK) { 965 918 printf("%s: Unable to register device %s\n", NAME, vc); 966 919 return false;
Note:
See TracChangeset
for help on using the changeset viewer.