Changes in uspace/drv/bus/usb/usbhid/mouse/mousedev.c [5f6e25e:5da7199] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
r5f6e25e r5da7199 42 42 #include <errno.h> 43 43 #include <async.h> 44 #include <async_obsolete.h>45 44 #include <str_error.h> 46 45 #include <ipc/mouseev.h> … … 56 55 #define ARROWS_PER_SINGLE_WHEEL 3 57 56 58 // FIXME: remove this header 59 #include <abi/ipc/methods.h> 60 61 #define NAME "mouse" 57 #define NAME "mouse" 62 58 63 59 /*----------------------------------------------------------------------------*/ … … 128 124 ipc_callid_t icallid, ipc_call_t *icall) 129 125 { 130 sysarg_t method = IPC_GET_IMETHOD(*icall); 131 132 usb_mouse_t *mouse_dev = (usb_mouse_t *)fun->driver_data; 126 usb_mouse_t *mouse_dev = (usb_mouse_t *) fun->driver_data; 133 127 134 128 if (mouse_dev == NULL) { … … 141 135 usb_log_debug("default_connection_handler: fun->name: %s\n", 142 136 fun->name); 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) { 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 { 153 153 usb_log_debug("default_connection_handler: Console " 154 " phoneto mouse already set.\n");154 "session to mouse already set.\n"); 155 155 async_answer_0(icallid, ELIMIT); 156 return;157 156 } 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); 157 } else { 158 usb_log_debug("default_connection_handler: Invalid function.\n"); 159 async_answer_0(icallid, EINVAL); 160 } 167 161 } 168 162 … … 175 169 return NULL; 176 170 } 177 mouse->mouse_ phone = -1;178 mouse->wheel_ phone = -1;171 mouse->mouse_sess = NULL; 172 mouse->wheel_sess = NULL; 179 173 180 174 return mouse; … … 187 181 assert(mouse_dev != NULL); 188 182 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 } 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); 197 189 } 198 190 … … 203 195 unsigned int key = (wheel > 0) ? KC_UP : KC_DOWN; 204 196 205 if (mouse_dev->wheel_ phone < 0) {197 if (mouse_dev->wheel_sess == NULL) { 206 198 usb_log_warning( 207 199 "Connection to console not ready, wheel roll discarded.\n"); … … 215 207 /* Send arrow press and release. */ 216 208 usb_log_debug2("Sending key %d to the console\n", key); 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); 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); 221 216 } 222 217 } … … 253 248 assert(mouse_dev != NULL); 254 249 255 if (mouse_dev->mouse_ phone < 0) {256 usb_log_warning(NAME " No console phone.\n");250 if (mouse_dev->mouse_sess == NULL) { 251 usb_log_warning(NAME " No console session.\n"); 257 252 return true; 258 253 } … … 266 261 267 262 if ((shift_x != 0) || (shift_y != 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) { 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) 273 269 usb_mouse_send_wheel(mouse_dev, wheel); 274 }275 270 276 271 /* … … 292 287 if (mouse_dev->buttons[field->usage - field->usage_minimum] == 0 293 288 && field->value != 0) { 294 async_obsolete_req_2_0(mouse_dev->mouse_phone, 295 MOUSEEV_BUTTON_EVENT, field->usage, 1); 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 296 294 mouse_dev->buttons[field->usage - field->usage_minimum] 297 295 = field->value; 298 296 } else if (mouse_dev->buttons[field->usage - field->usage_minimum] != 0 299 297 && field->value == 0) { 300 async_obsolete_req_2_0(mouse_dev->mouse_phone, 301 MOUSEEV_BUTTON_EVENT, field->usage, 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 302 303 mouse_dev->buttons[field->usage - field->usage_minimum] = 303 304 field->value;
Note:
See TracChangeset
for help on using the changeset viewer.