Changeset 8edec53 in mainline for uspace/srv
- Timestamp:
- 2021-10-25T17:51:10Z (4 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 91ece11b
- Parents:
- 805a149
- Location:
- uspace/srv/hid
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/console.c
r805a149 r8edec53 124 124 static errno_t input_ev_abs_move(input_t *, unsigned, unsigned, unsigned, unsigned); 125 125 static errno_t input_ev_button(input_t *, int, int); 126 static errno_t input_ev_dclick(input_t *, int); 126 127 127 128 static input_ev_ops_t input_ev_ops = { … … 131 132 .move = input_ev_move, 132 133 .abs_move = input_ev_abs_move, 133 .button = input_ev_button 134 .button = input_ev_button, 135 .dclick = input_ev_dclick 134 136 }; 135 137 … … 440 442 } 441 443 444 static errno_t input_ev_dclick(input_t *input, int bnum) 445 { 446 cons_event_t event; 447 448 event.type = CEV_POS; 449 event.ev.pos.type = POS_DCLICK; 450 event.ev.pos.btn_num = bnum; 451 event.ev.pos.hpos = pointer_x / mouse_scale_x; 452 event.ev.pos.vpos = pointer_y / mouse_scale_y; 453 454 console_queue_cons_event(active_console, &event); 455 return EOK; 456 } 457 442 458 /** Process a character from the client (TTY emulation). */ 443 459 static void cons_write_char(console_t *cons, char32_t ch) -
uspace/srv/hid/display/input.c
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 49 49 static errno_t ds_input_ev_abs_move(input_t *, unsigned, unsigned, unsigned, unsigned); 50 50 static errno_t ds_input_ev_button(input_t *, int, int); 51 static errno_t ds_input_ev_dclick(input_t *, int); 51 52 52 53 static input_ev_ops_t ds_input_ev_ops = { … … 56 57 .move = ds_input_ev_move, 57 58 .abs_move = ds_input_ev_abs_move, 58 .button = ds_input_ev_button 59 .button = ds_input_ev_button, 60 .dclick = ds_input_ev_dclick 59 61 }; 60 62 … … 131 133 132 134 event.type = bpress ? PTD_PRESS : PTD_RELEASE; 135 event.btn_num = bnum; 136 event.dmove.x = 0; 137 event.dmove.y = 0; 138 139 ds_display_lock(disp); 140 rc = ds_display_post_ptd_event(disp, &event); 141 ds_display_unlock(disp); 142 return rc; 143 } 144 145 static errno_t ds_input_ev_dclick(input_t *input, int bnum) 146 { 147 ds_display_t *disp = (ds_display_t *) input->user; 148 ptd_event_t event; 149 errno_t rc; 150 151 event.type = PTD_DCLICK; 133 152 event.btn_num = bnum; 134 153 event.dmove.x = 0; -
uspace/srv/hid/display/seat.c
r805a149 r8edec53 362 362 } 363 363 364 if (event->type == PTD_PRESS || event->type == PTD_RELEASE) { 364 if (event->type == PTD_PRESS || event->type == PTD_RELEASE || 365 event->type == PTD_DCLICK) { 365 366 pevent.pos_id = 0; 366 pevent.type = (event->type == PTD_PRESS) ? 367 POS_PRESS : POS_RELEASE; 367 switch (event->type) { 368 case PTD_PRESS: 369 pevent.type = POS_PRESS; 370 break; 371 case PTD_RELEASE: 372 pevent.type = POS_RELEASE; 373 break; 374 case PTD_DCLICK: 375 pevent.type = POS_DCLICK; 376 break; 377 default: 378 assert(false); 379 } 380 368 381 pevent.btn_num = event->btn_num; 369 382 pevent.hpos = seat->pntpos.x; -
uspace/srv/hid/display/types/display/ptd_event.h
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 42 42 PTD_ABS_MOVE, 43 43 PTD_PRESS, 44 PTD_RELEASE 44 PTD_RELEASE, 45 PTD_DCLICK 45 46 } ptd_event_type_t; 46 47 -
uspace/srv/hid/input/input.c
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda4 4 * All rights reserved. 5 5 * … … 311 311 } 312 312 313 /** Arbitrate client actiovation */ 313 /** Mouse button has been double-clicked. */ 314 void mouse_push_event_dclick(mouse_dev_t *mdev, int bnum) 315 { 316 list_foreach(clients, link, client_t, client) { 317 if (client->active) { 318 async_exch_t *exch = async_exchange_begin(client->sess); 319 async_msg_1(exch, INPUT_EVENT_DCLICK, bnum); 320 async_exchange_end(exch); 321 } 322 } 323 } 324 325 /** Arbitrate client activation */ 314 326 static void client_arbitration(void) 315 327 { -
uspace/srv/hid/input/mouse.h
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 20 11 Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 66 66 unsigned int, unsigned int); 67 67 extern void mouse_push_event_button(mouse_dev_t *, int, int); 68 extern void mouse_push_event_dclick(mouse_dev_t *, int); 68 69 69 70 #endif -
uspace/srv/hid/input/proto/mousedev.c
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2011 Martin Decky 3 4 * All rights reserved. … … 43 44 #include <loc.h> 44 45 #include <stdlib.h> 46 #include <time.h> 45 47 #include "../mouse.h" 46 48 #include "../mouse_port.h" … … 48 50 #include "../input.h" 49 51 52 enum { 53 /** Default double-click speed in milliseconds */ 54 dclick_delay_ms = 500 55 }; 56 50 57 /** Mousedev softstate */ 51 58 typedef struct { 52 59 /** Link to generic mouse device */ 53 60 mouse_dev_t *mouse_dev; 61 /** Button number of last button pressed (or -1 if none) */ 62 int press_bnum; 63 /** Time at which button was last pressed */ 64 struct timespec press_time; 54 65 } mousedev_t; 55 66 … … 61 72 62 73 mousedev->mouse_dev = mdev; 74 mousedev->press_bnum = -1; 63 75 64 76 return mousedev; … … 68 80 { 69 81 free(mousedev); 82 } 83 84 static void mousedev_press(mousedev_t *mousedev, int bnum) 85 { 86 struct timespec now; 87 nsec_t ms_delay; 88 89 getuptime(&now); 90 91 /* Same button was pressed previously */ 92 if (mousedev->press_bnum == bnum) { 93 /* Compute milliseconds since previous press */ 94 ms_delay = ts_sub_diff(&now, &mousedev->press_time) / 1000000; 95 96 if (ms_delay <= dclick_delay_ms) { 97 mouse_push_event_dclick(mousedev->mouse_dev, bnum); 98 mousedev->press_bnum = -1; 99 return; 100 } 101 } 102 103 /* Record which button was last pressed and at what time */ 104 mousedev->press_bnum = bnum; 105 mousedev->press_time = now; 70 106 } 71 107 … … 103 139 mouse_push_event_button(mousedev->mouse_dev, 104 140 ipc_get_arg1(&call), ipc_get_arg2(&call)); 141 if (ipc_get_arg2(&call) != 0) 142 mousedev_press(mousedev, ipc_get_arg1(&call)); 105 143 retval = EOK; 106 144 break;
Note:
See TracChangeset
for help on using the changeset viewer.