Changeset 8edec53 in mainline for uspace/srv/hid/input/proto/mousedev.c
- Timestamp:
- 2021-10-25T17:51:10Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 91ece11b
- Parents:
- 805a149
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.