Changes in uspace/srv/hid/input/proto/mousedev.c [8edec53:fafb8e5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/proto/mousedev.c
r8edec53 rfafb8e5 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda3 2 * Copyright (c) 2011 Martin Decky 4 3 * All rights reserved. … … 44 43 #include <loc.h> 45 44 #include <stdlib.h> 46 #include <time.h>47 45 #include "../mouse.h" 48 46 #include "../mouse_port.h" … … 50 48 #include "../input.h" 51 49 52 enum {53 /** Default double-click speed in milliseconds */54 dclick_delay_ms = 50055 };56 57 50 /** Mousedev softstate */ 58 51 typedef struct { 59 52 /** Link to generic mouse device */ 60 53 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;65 54 } mousedev_t; 66 55 … … 72 61 73 62 mousedev->mouse_dev = mdev; 74 mousedev->press_bnum = -1;75 63 76 64 return mousedev; … … 80 68 { 81 69 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;106 70 } 107 71 … … 139 103 mouse_push_event_button(mousedev->mouse_dev, 140 104 ipc_get_arg1(&call), ipc_get_arg2(&call)); 141 if (ipc_get_arg2(&call) != 0)142 mousedev_press(mousedev, ipc_get_arg1(&call));143 105 retval = EOK; 144 106 break;
Note:
See TracChangeset
for help on using the changeset viewer.