Changeset cc29622 in mainline for uspace/drv/bus/usb/usbhid/mouse/mousedev.c
- Timestamp:
- 2011-10-14T12:40:31Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e5024111
- Parents:
- 3002434
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
r3002434 rcc29622 124 124 { 125 125 usb_mouse_t *mouse_dev = (usb_mouse_t *) fun->driver_data; 126 126 127 127 if (mouse_dev == NULL) { 128 128 usb_log_debug("default_connection_handler: Missing " … … 131 131 return; 132 132 } 133 133 134 134 usb_log_debug("default_connection_handler: fun->name: %s\n", 135 135 fun->name); 136 136 usb_log_debug("default_connection_handler: mouse_sess: %p, " 137 137 "wheel_sess: %p\n", mouse_dev->mouse_sess, mouse_dev->wheel_sess); 138 138 139 139 async_sess_t **sess_ptr = 140 140 (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0) ? 141 141 &mouse_dev->mouse_sess : &mouse_dev->wheel_sess; 142 142 143 143 async_sess_t *sess = 144 144 async_callback_receive_start(EXCHANGE_SERIALIZE, icall); … … 170 170 mouse->mouse_sess = NULL; 171 171 mouse->wheel_sess = NULL; 172 172 173 173 return mouse; 174 174 } … … 179 179 { 180 180 assert(mouse_dev != NULL); 181 181 182 182 // hangup session to the console 183 183 if (mouse_dev->mouse_sess != NULL) 184 184 async_hangup(mouse_dev->mouse_sess); 185 185 186 186 if (mouse_dev->wheel_sess != NULL) 187 187 async_hangup(mouse_dev->wheel_sess); … … 199 199 return; 200 200 } 201 201 202 202 int count = ((wheel < 0) ? -wheel : wheel) * ARROWS_PER_SINGLE_WHEEL; 203 203 int i; 204 204 205 205 for (i = 0; i < count; i++) { 206 206 /* Send arrow press and release. */ … … 246 246 { 247 247 assert(mouse_dev != NULL); 248 248 249 249 if (mouse_dev->mouse_sess == NULL) { 250 250 usb_log_warning(NAME " No console session.\n"); … … 264 264 async_exchange_end(exch); 265 265 } 266 266 267 267 if (wheel != 0) 268 268 usb_mouse_send_wheel(mouse_dev, wheel); 269 269 270 270 /* 271 271 * Buttons … … 274 274 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_BUTTON, 0); 275 275 usb_hid_report_path_set_report_id(path, hid_dev->report_id); 276 276 277 277 usb_hid_report_field_t *field = usb_hid_report_get_sibling( 278 278 hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END … … 309 309 USB_HID_REPORT_TYPE_INPUT); 310 310 } 311 311 312 312 usb_hid_report_path_free(path); 313 313 … … 321 321 assert(hid_dev != NULL); 322 322 assert(mouse != NULL); 323 323 324 324 /* Create the exposed function. */ 325 325 usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME); … … 330 330 return ENOMEM; 331 331 } 332 332 333 333 fun->ops = &mouse->ops; 334 334 fun->driver_data = mouse; … … 341 341 return rc; 342 342 } 343 343 344 344 usb_log_debug("Adding DDF function to category %s...\n", 345 345 HID_MOUSE_CATEGORY); … … 352 352 return rc; 353 353 } 354 354 355 355 /* 356 356 * Special function for acting as keyboard (wheel) … … 364 364 return ENOMEM; 365 365 } 366 366 367 367 /* 368 368 * Store the initialized HID device and HID ops … … 379 379 return rc; 380 380 } 381 381 382 382 usb_log_debug("Adding DDF function to category %s...\n", 383 383 HID_MOUSE_WHEEL_CATEGORY); … … 390 390 return rc; 391 391 } 392 392 393 393 return EOK; 394 394 } … … 441 441 { 442 442 usb_log_debug("Initializing HID/Mouse structure...\n"); 443 443 444 444 if (hid_dev == NULL) { 445 445 usb_log_error("Failed to init keyboard structure: no structure" … … 447 447 return EINVAL; 448 448 } 449 449 450 450 usb_mouse_t *mouse_dev = usb_mouse_new(); 451 451 if (mouse_dev == NULL) { … … 454 454 return ENOMEM; 455 455 } 456 456 457 457 // FIXME: This may not be optimal since stupid hardware vendor may 458 458 // use buttons 1, 2, 3 and 6000 and we would allocate array of … … 464 464 hid_dev->report_id) + 1; 465 465 mouse_dev->buttons = calloc(mouse_dev->buttons_count, sizeof(int32_t)); 466 466 467 467 if (mouse_dev->buttons == NULL) { 468 468 usb_log_error(NAME ": out of memory, giving up on device!\n"); … … 474 474 // save the Mouse device structure into the HID device structure 475 475 *data = mouse_dev; 476 476 477 477 // set handler for incoming calls 478 478 mouse_dev->ops.default_handler = default_connection_handler; 479 479 480 480 // TODO: how to know if the device supports the request??? 481 481 usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe, 482 482 hid_dev->usb_dev->interface_no, IDLE_RATE); 483 483 484 484 int rc = usb_mouse_create_function(hid_dev, mouse_dev); 485 485 if (rc != EOK) { … … 487 487 return rc; 488 488 } 489 489 490 490 return EOK; 491 491 } … … 500 500 return false; 501 501 } 502 502 503 503 usb_mouse_t *mouse_dev = (usb_mouse_t *)data; 504 504 … … 522 522 USB_MOUSE_BOOT_REPORT_DESCRIPTOR, 523 523 USB_MOUSE_BOOT_REPORT_DESCRIPTOR_SIZE); 524 524 525 525 if (rc != EOK) { 526 526 usb_log_error("Failed to parse boot report descriptor: %s\n", … … 528 528 return rc; 529 529 } 530 530 531 531 rc = usbhid_req_set_protocol(&hid_dev->usb_dev->ctrl_pipe, 532 532 hid_dev->usb_dev->interface_no, USB_HID_PROTOCOL_BOOT); 533 533 534 534 if (rc != EOK) { 535 535 usb_log_warning("Failed to set boot protocol to the device: " … … 537 537 return rc; 538 538 } 539 539 540 540 return EOK; 541 541 }
Note:
See TracChangeset
for help on using the changeset viewer.