Ignore:
File:
1 edited

Legend:

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

    rfaa44e58 r61f49a0  
    122122        sysarg_t method = IPC_GET_IMETHOD(*icall);
    123123       
    124         usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
    125        
    126         if (hid_dev == NULL || hid_dev->data == NULL) {
     124        usb_mouse_t *mouse_dev = (usb_mouse_t *)fun->driver_data;
     125       
     126        if (mouse_dev == NULL) {
    127127                usb_log_debug("default_connection_handler: Missing "
    128128                    "parameters.\n");
     
    131131        }
    132132       
    133         assert(hid_dev != NULL);
    134         assert(hid_dev->data != NULL);
    135         usb_mouse_t *mouse_dev = (usb_mouse_t *)hid_dev->data;
     133        usb_log_debug("default_connection_handler: fun->name: %s\n",
     134                      fun->name);
     135        usb_log_debug("default_connection_handler: mouse_phone: %d, wheel "
     136            "phone: %d\n", mouse_dev->mouse_phone, mouse_dev->wheel_phone);
    136137       
    137138        int *phone = (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0)
     
    145146                            "phone to mouse already set.\n");
    146147                        async_answer_0(icallid, ELIMIT);
    147                         //async_answer_0(icallid, EOK);
    148148                        return;
    149149                }
    150150
    151151                *phone = callback;
    152                 usb_log_debug("Console phone to mouse set ok (%d).\n", callback);
     152                usb_log_debug("Console phone to mouse set ok (%d).\n", *phone);
    153153                async_answer_0(icallid, EOK);
    154154                return;
     
    224224/*----------------------------------------------------------------------------*/
    225225
    226 static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev, uint8_t *buffer,
    227     size_t buffer_size)
    228 {
    229         usb_mouse_t *mouse_dev = (usb_mouse_t *)hid_dev->data;
     226static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev,
     227                                     usb_mouse_t *mouse_dev, uint8_t *buffer,
     228                                     size_t buffer_size)
     229{
     230        assert(mouse_dev != NULL);
    230231       
    231232        usb_log_debug2("got buffer: %s.\n",
     
    233234       
    234235        if (mouse_dev->mouse_phone < 0) {
    235                 usb_log_error(NAME " No console phone.\n");
    236                 return false;   // ??
     236                usb_log_warning(NAME " No console phone.\n");
     237                return true;
    237238        }
    238239
     
    378379/*----------------------------------------------------------------------------*/
    379380
    380 static int usb_mouse_create_function(usb_hid_dev_t *hid_dev)
    381 {
     381static int usb_mouse_create_function(usb_hid_dev_t *hid_dev, usb_mouse_t *mouse)
     382{
     383        assert(hid_dev != NULL);
     384        assert(mouse != NULL);
     385       
    382386        /* Create the function exposed under /dev/devices. */
    383387        usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME);
     
    389393        }
    390394       
    391         /*
    392          * Store the initialized HID device and HID ops
    393          * to the DDF function.
    394          */
    395         fun->ops = &hid_dev->ops;
    396         fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
     395        fun->ops = &mouse->ops;
     396        fun->driver_data = mouse;   // TODO: maybe change to hid_dev->data
    397397
    398398        int rc = ddf_fun_bind(fun);
     
    431431         * to the DDF function.
    432432         */
    433         fun->ops = &hid_dev->ops;
    434         fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
     433        fun->ops = &mouse->ops;
     434        fun->driver_data = mouse;   // TODO: maybe change to hid_dev->data
    435435
    436436        rc = ddf_fun_bind(fun);
     
    458458/*----------------------------------------------------------------------------*/
    459459
    460 int usb_mouse_init(usb_hid_dev_t *hid_dev)
     460int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data)
    461461{
    462462        usb_log_debug("Initializing HID/Mouse structure...\n");
     
    485485       
    486486        // save the Mouse device structure into the HID device structure
    487         hid_dev->data = mouse_dev;
     487        *data = mouse_dev;
    488488       
    489489        // set handler for incoming calls
    490         hid_dev->ops.default_handler = default_connection_handler;
     490        // TODO: must be one for each subdriver!!
     491        mouse_dev->ops.default_handler = default_connection_handler;
    491492       
    492493        // TODO: how to know if the device supports the request???
     
    494495//          hid_dev->usb_dev->interface_no, IDLE_RATE);
    495496       
    496         int rc = usb_mouse_create_function(hid_dev);
     497        int rc = usb_mouse_create_function(hid_dev, mouse_dev);
    497498        if (rc != EOK) {
    498499                usb_mouse_free(&mouse_dev);
     
    505506/*----------------------------------------------------------------------------*/
    506507
    507 bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, uint8_t *buffer,
    508      size_t buffer_size)
     508bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, void *data,
     509     uint8_t *buffer, size_t buffer_size)
    509510{
    510511        usb_log_debug("usb_mouse_polling_callback()\n");
    511512        usb_debug_str_buffer(buffer, buffer_size, 0);
    512513       
    513         if (hid_dev == NULL) {
     514        if (hid_dev == NULL || data == NULL) {
    514515                usb_log_error("Missing argument to the mouse polling callback."
    515516                    "\n");
     
    517518        }
    518519       
    519         if (hid_dev->data == NULL) {
    520                 usb_log_error("Wrong argument to the mouse polling callback."
    521                     "\n");
    522                 return false;
    523         }
    524        
    525         return usb_mouse_process_report(hid_dev, buffer, buffer_size);
    526 }
    527 
    528 /*----------------------------------------------------------------------------*/
    529 
    530 void usb_mouse_deinit(usb_hid_dev_t *hid_dev)
    531 {
    532         usb_mouse_free((usb_mouse_t **)&hid_dev->data);
     520        usb_mouse_t *mouse_dev = (usb_mouse_t *)data;
     521               
     522        return usb_mouse_process_report(hid_dev, mouse_dev, buffer,
     523                                        buffer_size);
     524}
     525
     526/*----------------------------------------------------------------------------*/
     527
     528void usb_mouse_deinit(usb_hid_dev_t *hid_dev, void *data)
     529{
     530        if (data != NULL) {
     531                usb_mouse_free((usb_mouse_t **)&data);
     532        }
    533533}
    534534
Note: See TracChangeset for help on using the changeset viewer.