Changes in uspace/drv/bus/usb/usbhid/mouse/mousedev.c [5da7199:5f6e25e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
r5da7199 r5f6e25e 42 42 #include <errno.h> 43 43 #include <async.h> 44 #include <async_obsolete.h> 44 45 #include <str_error.h> 45 46 #include <ipc/mouseev.h> … … 55 56 #define ARROWS_PER_SINGLE_WHEEL 3 56 57 57 #define NAME "mouse" 58 // FIXME: remove this header 59 #include <abi/ipc/methods.h> 60 61 #define NAME "mouse" 58 62 59 63 /*----------------------------------------------------------------------------*/ … … 124 128 ipc_callid_t icallid, ipc_call_t *icall) 125 129 { 126 usb_mouse_t *mouse_dev = (usb_mouse_t *) fun->driver_data; 130 sysarg_t method = IPC_GET_IMETHOD(*icall); 131 132 usb_mouse_t *mouse_dev = (usb_mouse_t *)fun->driver_data; 127 133 128 134 if (mouse_dev == NULL) { … … 135 141 usb_log_debug("default_connection_handler: fun->name: %s\n", 136 142 fun->name); 137 usb_log_debug("default_connection_handler: mouse_sess: %p, " 138 "wheel_sess: %p\n", mouse_dev->mouse_sess, mouse_dev->wheel_sess); 139 140 async_sess_t **sess_ptr = 141 (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0) ? 142 &mouse_dev->mouse_sess : &mouse_dev->wheel_sess; 143 144 async_sess_t *sess = 145 async_callback_receive_start(EXCHANGE_SERIALIZE, icall); 146 if (sess != NULL) { 147 if (*sess_ptr == NULL) { 148 *sess_ptr = sess; 149 usb_log_debug("Console session to mouse set ok (%p).\n", 150 sess); 151 async_answer_0(icallid, EOK); 152 } else { 143 usb_log_debug("default_connection_handler: mouse_phone: %d, wheel " 144 "phone: %d\n", mouse_dev->mouse_phone, mouse_dev->wheel_phone); 145 146 int *phone = (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0) 147 ? &mouse_dev->mouse_phone : &mouse_dev->wheel_phone; 148 149 if (method == IPC_M_CONNECT_TO_ME) { 150 int callback = IPC_GET_ARG5(*icall); 151 152 if (*phone != -1) { 153 153 usb_log_debug("default_connection_handler: Console " 154 " sessionto mouse already set.\n");154 "phone to mouse already set.\n"); 155 155 async_answer_0(icallid, ELIMIT); 156 return; 156 157 } 157 } else { 158 usb_log_debug("default_connection_handler: Invalid function.\n"); 159 async_answer_0(icallid, EINVAL); 160 } 158 159 *phone = callback; 160 usb_log_debug("Console phone to mouse set ok (%d).\n", *phone); 161 async_answer_0(icallid, EOK); 162 return; 163 } 164 165 usb_log_debug("default_connection_handler: Invalid function.\n"); 166 async_answer_0(icallid, EINVAL); 161 167 } 162 168 … … 169 175 return NULL; 170 176 } 171 mouse->mouse_ sess = NULL;172 mouse->wheel_ sess = NULL;177 mouse->mouse_phone = -1; 178 mouse->wheel_phone = -1; 173 179 174 180 return mouse; … … 181 187 assert(mouse_dev != NULL); 182 188 183 // hangup session to the console 184 if (mouse_dev->mouse_sess != NULL) 185 async_hangup(mouse_dev->mouse_sess); 186 187 if (mouse_dev->wheel_sess != NULL) 188 async_hangup(mouse_dev->wheel_sess); 189 // hangup phone to the console 190 if (mouse_dev->mouse_phone >= 0) { 191 async_obsolete_hangup(mouse_dev->mouse_phone); 192 } 193 194 if (mouse_dev->wheel_phone >= 0) { 195 async_obsolete_hangup(mouse_dev->wheel_phone); 196 } 189 197 } 190 198 … … 195 203 unsigned int key = (wheel > 0) ? KC_UP : KC_DOWN; 196 204 197 if (mouse_dev->wheel_ sess == NULL) {205 if (mouse_dev->wheel_phone < 0) { 198 206 usb_log_warning( 199 207 "Connection to console not ready, wheel roll discarded.\n"); … … 207 215 /* Send arrow press and release. */ 208 216 usb_log_debug2("Sending key %d to the console\n", key); 209 210 async_exch_t *exch = async_exchange_begin(mouse_dev->wheel_sess); 211 212 async_msg_4(exch, KBDEV_EVENT, KEY_PRESS, key, 0, 0); 213 async_msg_4(exch, KBDEV_EVENT, KEY_RELEASE, key, 0, 0); 214 215 async_exchange_end(exch); 217 async_obsolete_msg_4(mouse_dev->wheel_phone, KBDEV_EVENT, 218 KEY_PRESS, key, 0, 0); 219 async_obsolete_msg_4(mouse_dev->wheel_phone, KBDEV_EVENT, 220 KEY_RELEASE, key, 0, 0); 216 221 } 217 222 } … … 248 253 assert(mouse_dev != NULL); 249 254 250 if (mouse_dev->mouse_ sess == NULL) {251 usb_log_warning(NAME " No console session.\n");255 if (mouse_dev->mouse_phone < 0) { 256 usb_log_warning(NAME " No console phone.\n"); 252 257 return true; 253 258 } … … 261 266 262 267 if ((shift_x != 0) || (shift_y != 0)) { 263 async_exch_t *exch = async_exchange_begin(mouse_dev->mouse_sess); 264 async_req_2_0(exch, MOUSEEV_MOVE_EVENT, shift_x, shift_y); 265 async_exchange_end(exch); 266 } 267 268 if (wheel != 0) 268 async_obsolete_req_2_0(mouse_dev->mouse_phone, 269 MOUSEEV_MOVE_EVENT, shift_x, shift_y); 270 } 271 272 if (wheel != 0) { 269 273 usb_mouse_send_wheel(mouse_dev, wheel); 274 } 270 275 271 276 /* … … 287 292 if (mouse_dev->buttons[field->usage - field->usage_minimum] == 0 288 293 && field->value != 0) { 289 async_exch_t *exch = 290 async_exchange_begin(mouse_dev->mouse_sess); 291 async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, field->usage, 1); 292 async_exchange_end(exch); 293 294 async_obsolete_req_2_0(mouse_dev->mouse_phone, 295 MOUSEEV_BUTTON_EVENT, field->usage, 1); 294 296 mouse_dev->buttons[field->usage - field->usage_minimum] 295 297 = field->value; 296 298 } else if (mouse_dev->buttons[field->usage - field->usage_minimum] != 0 297 299 && field->value == 0) { 298 async_exch_t *exch = 299 async_exchange_begin(mouse_dev->mouse_sess); 300 async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, field->usage, 0); 301 async_exchange_end(exch); 302 300 async_obsolete_req_2_0(mouse_dev->mouse_phone, 301 MOUSEEV_BUTTON_EVENT, field->usage, 0); 303 302 mouse_dev->buttons[field->usage - field->usage_minimum] = 304 303 field->value;
Note:
See TracChangeset
for help on using the changeset viewer.