Changes in uspace/drv/usbhid/mouse/mousedev.c [61f49a0:faa44e58] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/mouse/mousedev.c
r61f49a0 rfaa44e58 122 122 sysarg_t method = IPC_GET_IMETHOD(*icall); 123 123 124 usb_ mouse_t *mouse_dev = (usb_mouse_t *)fun->driver_data;125 126 if ( mouse_dev== NULL) {124 usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data; 125 126 if (hid_dev == NULL || hid_dev->data == NULL) { 127 127 usb_log_debug("default_connection_handler: Missing " 128 128 "parameters.\n"); … … 131 131 } 132 132 133 usb_log_debug("default_connection_handler: fun->name: %s\n", 134 fun->name); 135 usb_log_debug("default_connection_handler: mouse_phone: %d, wheel " 136 "phone: %d\n", mouse_dev->mouse_phone, mouse_dev->wheel_phone); 133 assert(hid_dev != NULL); 134 assert(hid_dev->data != NULL); 135 usb_mouse_t *mouse_dev = (usb_mouse_t *)hid_dev->data; 137 136 138 137 int *phone = (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0) … … 146 145 "phone to mouse already set.\n"); 147 146 async_answer_0(icallid, ELIMIT); 147 //async_answer_0(icallid, EOK); 148 148 return; 149 149 } 150 150 151 151 *phone = callback; 152 usb_log_debug("Console phone to mouse set ok (%d).\n", *phone);152 usb_log_debug("Console phone to mouse set ok (%d).\n", callback); 153 153 async_answer_0(icallid, EOK); 154 154 return; … … 224 224 /*----------------------------------------------------------------------------*/ 225 225 226 static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev, 227 usb_mouse_t *mouse_dev, uint8_t *buffer, 228 size_t buffer_size) 229 { 230 assert(mouse_dev != NULL); 226 static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev, uint8_t *buffer, 227 size_t buffer_size) 228 { 229 usb_mouse_t *mouse_dev = (usb_mouse_t *)hid_dev->data; 231 230 232 231 usb_log_debug2("got buffer: %s.\n", … … 234 233 235 234 if (mouse_dev->mouse_phone < 0) { 236 usb_log_ warning(NAME " No console phone.\n");237 return true;235 usb_log_error(NAME " No console phone.\n"); 236 return false; // ?? 238 237 } 239 238 … … 379 378 /*----------------------------------------------------------------------------*/ 380 379 381 static int usb_mouse_create_function(usb_hid_dev_t *hid_dev, usb_mouse_t *mouse) 382 { 383 assert(hid_dev != NULL); 384 assert(mouse != NULL); 385 380 static int usb_mouse_create_function(usb_hid_dev_t *hid_dev) 381 { 386 382 /* Create the function exposed under /dev/devices. */ 387 383 usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME); … … 393 389 } 394 390 395 fun->ops = &mouse->ops; 396 fun->driver_data = mouse; // TODO: maybe change to hid_dev->data 391 /* 392 * Store the initialized HID device and HID ops 393 * to the DDF function. 394 */ 395 fun->ops = &hid_dev->ops; 396 fun->driver_data = hid_dev; // TODO: maybe change to hid_dev->data 397 397 398 398 int rc = ddf_fun_bind(fun); … … 431 431 * to the DDF function. 432 432 */ 433 fun->ops = & mouse->ops;434 fun->driver_data = mouse; // TODO: maybe change to hid_dev->data433 fun->ops = &hid_dev->ops; 434 fun->driver_data = hid_dev; // TODO: maybe change to hid_dev->data 435 435 436 436 rc = ddf_fun_bind(fun); … … 458 458 /*----------------------------------------------------------------------------*/ 459 459 460 int usb_mouse_init(usb_hid_dev_t *hid_dev , void **data)460 int usb_mouse_init(usb_hid_dev_t *hid_dev) 461 461 { 462 462 usb_log_debug("Initializing HID/Mouse structure...\n"); … … 485 485 486 486 // save the Mouse device structure into the HID device structure 487 *data = mouse_dev;487 hid_dev->data = mouse_dev; 488 488 489 489 // set handler for incoming calls 490 // TODO: must be one for each subdriver!! 491 mouse_dev->ops.default_handler = default_connection_handler; 490 hid_dev->ops.default_handler = default_connection_handler; 492 491 493 492 // TODO: how to know if the device supports the request??? … … 495 494 // hid_dev->usb_dev->interface_no, IDLE_RATE); 496 495 497 int rc = usb_mouse_create_function(hid_dev , mouse_dev);496 int rc = usb_mouse_create_function(hid_dev); 498 497 if (rc != EOK) { 499 498 usb_mouse_free(&mouse_dev); … … 506 505 /*----------------------------------------------------------------------------*/ 507 506 508 bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, void *data,509 uint8_t *buffer,size_t buffer_size)507 bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, uint8_t *buffer, 508 size_t buffer_size) 510 509 { 511 510 usb_log_debug("usb_mouse_polling_callback()\n"); 512 511 usb_debug_str_buffer(buffer, buffer_size, 0); 513 512 514 if (hid_dev == NULL || data == NULL) {513 if (hid_dev == NULL) { 515 514 usb_log_error("Missing argument to the mouse polling callback." 516 515 "\n"); … … 518 517 } 519 518 520 usb_mouse_t *mouse_dev = (usb_mouse_t *)data; 521 522 return usb_mouse_process_report(hid_dev, mouse_dev, buffer, 523 buffer_size); 524 } 525 526 /*----------------------------------------------------------------------------*/ 527 528 void usb_mouse_deinit(usb_hid_dev_t *hid_dev, void *data) 529 { 530 if (data != NULL) { 531 usb_mouse_free((usb_mouse_t **)&data); 532 } 519 if (hid_dev->data == NULL) { 520 usb_log_error("Wrong argument to the mouse polling callback." 521 "\n"); 522 return false; 523 } 524 525 return usb_mouse_process_report(hid_dev, buffer, buffer_size); 526 } 527 528 /*----------------------------------------------------------------------------*/ 529 530 void usb_mouse_deinit(usb_hid_dev_t *hid_dev) 531 { 532 usb_mouse_free((usb_mouse_t **)&hid_dev->data); 533 533 } 534 534
Note:
See TracChangeset
for help on using the changeset viewer.