Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/usbhid.c

    rf8e549b r36f737a  
    6363static const int USB_HID_MAX_SUBDRIVERS = 10;
    6464
    65 static fibril_local bool report_received;
    66 
    6765/*----------------------------------------------------------------------------*/
    6866
     
    138136       
    139137        // set the init callback
    140         hid_dev->subdrivers[0].init = usb_generic_hid_init;
     138        hid_dev->subdrivers[0].init = NULL;
    141139       
    142140        // set the polling callback
     
    414412        }
    415413       
    416         if (fallback) {
     414        // TODO: remove the mouse hack
     415        if (hid_dev->poll_pipe_index == USB_HID_MOUSE_POLL_EP_NO ||
     416            fallback) {
    417417                // fall back to boot protocol
    418418                switch (hid_dev->poll_pipe_index) {
     
    490490        usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg;
    491491       
    492         int allocated = (hid_dev->input_report != NULL);
    493        
    494         if (!allocated
    495             || 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        
    519492        bool cont = false;
    520493       
     
    555528/*----------------------------------------------------------------------------*/
    556529
    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;
     530const 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
     546const 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        }
    609561}
    610562
Note: See TracChangeset for help on using the changeset viewer.