Changeset 31cfee16 in mainline for uspace/drv/usbhid/mouse/mousedev.c


Ignore:
Timestamp:
2011-05-03T09:16:39Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3facf63a
Parents:
30710035
Message:

Creating DDF functions in subdrivers + saving input report.

  • Keyboard function.
  • Mouse function.
  • Lgtch UltraX function - added to class keyboard.
  • Saving input report in hid dev structure.
File:
1 edited

Legend:

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

    r30710035 r31cfee16  
    300300/*----------------------------------------------------------------------------*/
    301301
     302static int usb_mouse_create_function(usb_hid_dev_t *hid_dev)
     303{
     304        /* Create the function exposed under /dev/devices. */
     305        usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME);
     306        ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,
     307            HID_MOUSE_FUN_NAME);
     308        if (fun == NULL) {
     309                usb_log_error("Could not create DDF function node.\n");
     310                return ENOMEM;
     311        }
     312       
     313        /*
     314         * Store the initialized HID device and HID ops
     315         * to the DDF function.
     316         */
     317        fun->ops = &hid_dev->ops;
     318        fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
     319
     320        int rc = ddf_fun_bind(fun);
     321        if (rc != EOK) {
     322                usb_log_error("Could not bind DDF function: %s.\n",
     323                    str_error(rc));
     324                ddf_fun_destroy(fun);
     325                return rc;
     326        }
     327       
     328        usb_log_debug("Adding DDF function to class %s...\n",
     329            HID_MOUSE_CLASS_NAME);
     330        rc = ddf_fun_add_to_class(fun, HID_MOUSE_CLASS_NAME);
     331        if (rc != EOK) {
     332                usb_log_error(
     333                    "Could not add DDF function to class %s: %s.\n",
     334                    HID_MOUSE_CLASS_NAME, str_error(rc));
     335                ddf_fun_destroy(fun);
     336                return rc;
     337        }
     338       
     339        return EOK;
     340}
     341
     342/*----------------------------------------------------------------------------*/
     343
    302344int usb_mouse_init(usb_hid_dev_t *hid_dev)
    303345{
     
    317359        }
    318360       
    319 //      usb_hid_report_path_t *path = usb_hid_report_path();
    320 //      usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_BUTTON, 0);
    321        
    322 //      usb_hid_report_path_set_report_id(path, 0);
    323        
    324 //      mouse_dev->button_count = usb_hid_report_input_length(
    325 //          hid_dev->report, path,
    326 //          USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
    327 //      usb_hid_report_path_free(path);
    328        
    329 //      usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count);
    330        
    331361        mouse_dev->buttons = (int32_t *)calloc(USB_MOUSE_BUTTON_COUNT,
    332362            sizeof(int32_t));
     
    348378//          hid_dev->usb_dev->interface_no, IDLE_RATE);
    349379       
     380        int rc = usb_mouse_create_function(hid_dev);
     381        if (rc != EOK) {
     382                usb_mouse_free(&mouse_dev);
     383                return rc;
     384        }
     385       
    350386        return EOK;
    351387}
Note: See TracChangeset for help on using the changeset viewer.