Changes in uspace/drv/usbhid/usbhid.c [f8e549b:36f737a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/usbhid.c
rf8e549b r36f737a 63 63 static const int USB_HID_MAX_SUBDRIVERS = 10; 64 64 65 static fibril_local bool report_received;66 67 65 /*----------------------------------------------------------------------------*/ 68 66 … … 138 136 139 137 // set the init callback 140 hid_dev->subdrivers[0].init = usb_generic_hid_init;138 hid_dev->subdrivers[0].init = NULL; 141 139 142 140 // set the polling callback … … 414 412 } 415 413 416 if (fallback) { 414 // TODO: remove the mouse hack 415 if (hid_dev->poll_pipe_index == USB_HID_MOUSE_POLL_EP_NO || 416 fallback) { 417 417 // fall back to boot protocol 418 418 switch (hid_dev->poll_pipe_index) { … … 490 490 usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg; 491 491 492 int allocated = (hid_dev->input_report != NULL);493 494 if (!allocated495 || hid_dev->input_report_size < buffer_size) {496 uint8_t *input_old = hid_dev->input_report;497 uint8_t *input_new = (uint8_t *)malloc(buffer_size);498 499 if (input_new == NULL) {500 usb_log_error("Failed to allocate space for input "501 "buffer. This event may not be reported\n");502 memset(hid_dev->input_report, 0,503 hid_dev->input_report_size);504 } else {505 memcpy(input_new, input_old,506 hid_dev->input_report_size);507 hid_dev->input_report = input_new;508 if (allocated) {509 free(input_old);510 }511 usb_hid_new_report();512 }513 }514 515 /*! @todo This should probably be atomic. */516 memcpy(hid_dev->input_report, buffer, buffer_size);517 hid_dev->input_report_size = buffer_size;518 519 492 bool cont = false; 520 493 … … 555 528 /*----------------------------------------------------------------------------*/ 556 529 557 //const char *usb_hid_get_function_name(const usb_hid_dev_t *hid_dev) 558 //{ 559 // switch (hid_dev->poll_pipe_index) { 560 // case USB_HID_KBD_POLL_EP_NO: 561 // return HID_KBD_FUN_NAME; 562 // break; 563 // case USB_HID_MOUSE_POLL_EP_NO: 564 // return HID_MOUSE_FUN_NAME; 565 // break; 566 // default: 567 // return HID_GENERIC_FUN_NAME; 568 // } 569 //} 570 571 /*----------------------------------------------------------------------------*/ 572 573 //const char *usb_hid_get_class_name(const usb_hid_dev_t *hid_dev) 574 //{ 575 // // this means that only boot protocol keyboards will be connected 576 // // to the console; there is probably no better way to do this 577 578 // switch (hid_dev->poll_pipe_index) { 579 // case USB_HID_KBD_POLL_EP_NO: 580 // return HID_KBD_CLASS_NAME; 581 // break; 582 // case USB_HID_MOUSE_POLL_EP_NO: 583 // return HID_MOUSE_CLASS_NAME; 584 // break; 585 // default: 586 // return HID_GENERIC_CLASS_NAME; 587 // } 588 //} 589 590 /*----------------------------------------------------------------------------*/ 591 592 void usb_hid_new_report(void) 593 { 594 report_received = false; 595 } 596 597 /*----------------------------------------------------------------------------*/ 598 599 void usb_hid_report_received(void) 600 { 601 report_received = true; 602 } 603 604 /*----------------------------------------------------------------------------*/ 605 606 bool usb_hid_report_ready(void) 607 { 608 return !report_received; 530 const char *usb_hid_get_function_name(const usb_hid_dev_t *hid_dev) 531 { 532 switch (hid_dev->poll_pipe_index) { 533 case USB_HID_KBD_POLL_EP_NO: 534 return HID_KBD_FUN_NAME; 535 break; 536 case USB_HID_MOUSE_POLL_EP_NO: 537 return HID_MOUSE_FUN_NAME; 538 break; 539 default: 540 return HID_GENERIC_FUN_NAME; 541 } 542 } 543 544 /*----------------------------------------------------------------------------*/ 545 546 const char *usb_hid_get_class_name(const usb_hid_dev_t *hid_dev) 547 { 548 // this means that only boot protocol keyboards will be connected 549 // to the console; there is probably no better way to do this 550 551 switch (hid_dev->poll_pipe_index) { 552 case USB_HID_KBD_POLL_EP_NO: 553 return HID_KBD_CLASS_NAME; 554 break; 555 case USB_HID_MOUSE_POLL_EP_NO: 556 return HID_MOUSE_CLASS_NAME; 557 break; 558 default: 559 return HID_GENERIC_CLASS_NAME; 560 } 609 561 } 610 562
Note:
See TracChangeset
for help on using the changeset viewer.