Changes in uspace/drv/usbhid/mouse/mousedev.c [faa44e58:61f49a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/mouse/mousedev.c
rfaa44e58 r61f49a0 122 122 sysarg_t method = IPC_GET_IMETHOD(*icall); 123 123 124 usb_ hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;125 126 if ( hid_dev == NULL || hid_dev->data== NULL) {124 usb_mouse_t *mouse_dev = (usb_mouse_t *)fun->driver_data; 125 126 if (mouse_dev == NULL) { 127 127 usb_log_debug("default_connection_handler: Missing " 128 128 "parameters.\n"); … … 131 131 } 132 132 133 assert(hid_dev != NULL); 134 assert(hid_dev->data != NULL); 135 usb_mouse_t *mouse_dev = (usb_mouse_t *)hid_dev->data; 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); 136 137 137 138 int *phone = (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0) … … 145 146 "phone to mouse already set.\n"); 146 147 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", callback);152 usb_log_debug("Console phone to mouse set ok (%d).\n", *phone); 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, uint8_t *buffer, 227 size_t buffer_size) 228 { 229 usb_mouse_t *mouse_dev = (usb_mouse_t *)hid_dev->data; 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); 230 231 231 232 usb_log_debug2("got buffer: %s.\n", … … 233 234 234 235 if (mouse_dev->mouse_phone < 0) { 235 usb_log_ error(NAME " No console phone.\n");236 return false; // ??236 usb_log_warning(NAME " No console phone.\n"); 237 return true; 237 238 } 238 239 … … 378 379 /*----------------------------------------------------------------------------*/ 379 380 380 static int usb_mouse_create_function(usb_hid_dev_t *hid_dev) 381 { 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 382 386 /* Create the function exposed under /dev/devices. */ 383 387 usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME); … … 389 393 } 390 394 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 395 fun->ops = &mouse->ops; 396 fun->driver_data = mouse; // 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 = & hid_dev->ops;434 fun->driver_data = hid_dev; // TODO: maybe change to hid_dev->data433 fun->ops = &mouse->ops; 434 fun->driver_data = mouse; // 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 )460 int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data) 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 hid_dev->data = mouse_dev;487 *data = mouse_dev; 488 488 489 489 // set handler for incoming calls 490 hid_dev->ops.default_handler = default_connection_handler; 490 // TODO: must be one for each subdriver!! 491 mouse_dev->ops.default_handler = default_connection_handler; 491 492 492 493 // TODO: how to know if the device supports the request??? … … 494 495 // hid_dev->usb_dev->interface_no, IDLE_RATE); 495 496 496 int rc = usb_mouse_create_function(hid_dev );497 int rc = usb_mouse_create_function(hid_dev, mouse_dev); 497 498 if (rc != EOK) { 498 499 usb_mouse_free(&mouse_dev); … … 505 506 /*----------------------------------------------------------------------------*/ 506 507 507 bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, uint8_t *buffer,508 size_t buffer_size)508 bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, void *data, 509 uint8_t *buffer, size_t buffer_size) 509 510 { 510 511 usb_log_debug("usb_mouse_polling_callback()\n"); 511 512 usb_debug_str_buffer(buffer, buffer_size, 0); 512 513 513 if (hid_dev == NULL ) {514 if (hid_dev == NULL || data == NULL) { 514 515 usb_log_error("Missing argument to the mouse polling callback." 515 516 "\n"); … … 517 518 } 518 519 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); 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 } 533 533 } 534 534
Note:
See TracChangeset
for help on using the changeset viewer.