Changeset 26f6094 in mainline for uspace/drv/usbhid/usbhid.c


Ignore:
Timestamp:
2011-05-06T09:25:44Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d0c060b
Parents:
9e929a0 (diff), 310c4df (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge with usb/development

File:
1 edited

Legend:

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

    r9e929a0 r26f6094  
    136136       
    137137        // set the init callback
    138         hid_dev->subdrivers[0].init = NULL;
     138        hid_dev->subdrivers[0].init = usb_generic_hid_init;
    139139       
    140140        // set the polling callback
     
    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                }
     512        }
     513       
     514        /*! @todo This should probably be atomic. */
     515        memcpy(hid_dev->input_report, buffer, buffer_size);
     516        hid_dev->input_report_size = buffer_size;
     517       
    492518        bool cont = false;
    493519       
     
    528554/*----------------------------------------------------------------------------*/
    529555
    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         }
    561 }
     556//const char *usb_hid_get_function_name(const usb_hid_dev_t *hid_dev)
     557//{
     558//      switch (hid_dev->poll_pipe_index) {
     559//      case USB_HID_KBD_POLL_EP_NO:
     560//              return HID_KBD_FUN_NAME;
     561//              break;
     562//      case USB_HID_MOUSE_POLL_EP_NO:
     563//              return HID_MOUSE_FUN_NAME;
     564//              break;
     565//      default:
     566//              return HID_GENERIC_FUN_NAME;
     567//      }
     568//}
     569
     570/*----------------------------------------------------------------------------*/
     571
     572//const char *usb_hid_get_class_name(const usb_hid_dev_t *hid_dev)
     573//{
     574//      // this means that only boot protocol keyboards will be connected
     575//      // to the console; there is probably no better way to do this
     576       
     577//      switch (hid_dev->poll_pipe_index) {
     578//      case USB_HID_KBD_POLL_EP_NO:
     579//              return HID_KBD_CLASS_NAME;
     580//              break;
     581//      case USB_HID_MOUSE_POLL_EP_NO:
     582//              return HID_MOUSE_CLASS_NAME;
     583//              break;
     584//      default:
     585//              return HID_GENERIC_CLASS_NAME;
     586//      }
     587//}
    562588
    563589/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.