Changeset a81a1d09 in mainline for uspace/drv/usbhid/usbhid.c


Ignore:
Timestamp:
2011-05-11T16:49:28Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
19387b61
Parents:
e1dbcbc (diff), 9212f8a (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 development/ changes

File:
1 edited

Legend:

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

    re1dbcbc ra81a1d09  
    6363static const int USB_HID_MAX_SUBDRIVERS = 10;
    6464
     65static fibril_local bool report_received;
     66
    6567/*----------------------------------------------------------------------------*/
    6668
     
    136138       
    137139        // set the init callback
    138         hid_dev->subdrivers[0].init = NULL;
     140        hid_dev->subdrivers[0].init = usb_generic_hid_init;
    139141       
    140142        // set the polling callback
     
    412414        }
    413415       
    414         // TODO: remove the mouse hack
    415         if (hid_dev->poll_pipe_index == USB_HID_MOUSE_POLL_EP_NO ||
    416             fallback) {
     416        if (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       
    492519        bool cont = false;
    493520       
     
    528555/*----------------------------------------------------------------------------*/
    529556
    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         }
     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
     592void usb_hid_new_report(void)
     593{
     594        report_received = false;
     595}
     596
     597/*----------------------------------------------------------------------------*/
     598
     599void usb_hid_report_received(void)
     600{
     601        report_received = true;
     602}
     603
     604/*----------------------------------------------------------------------------*/
     605
     606bool usb_hid_report_ready(void)
     607{
     608        return !report_received;
    561609}
    562610
Note: See TracChangeset for help on using the changeset viewer.