Changeset 70172dc4 in mainline


Ignore:
Timestamp:
2011-12-28T11:55:14Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3fac882d
Parents:
edb3cf2
Message:

usbhid, mouse: Remove wheel support workaround.

Location:
uspace/drv/bus/usb/usbhid/mouse
Files:
2 edited

Legend:

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

    redb3cf2 r70172dc4  
    5252#include "../usbhid.h"
    5353
    54 /** Number of simulated arrow-key presses for singel wheel step. */
    55 #define ARROWS_PER_SINGLE_WHEEL 3
    56 
    5754#define NAME "mouse"
    5855
     
    6966
    7067const char *HID_MOUSE_FUN_NAME = "mouse";
    71 const char *HID_MOUSE_WHEEL_FUN_NAME = "mouse-wheel";
    7268const char *HID_MOUSE_CATEGORY = "mouse";
    73 const char *HID_MOUSE_WHEEL_CATEGORY = "keyboard";
    7469
    7570/** Default idle rate for mouses. */
     
    126121
    127122        usb_log_debug("%s: fun->name: %s\n", __FUNCTION__, fun->name);
    128         usb_log_debug("%s: mouse_sess: %p, wheel_sess: %p\n",
    129             __FUNCTION__, mouse_dev->mouse_sess, mouse_dev->wheel_sess);
    130 
    131         async_sess_t **sess_ptr = (fun == mouse_dev->mouse_fun) ?
    132             &mouse_dev->mouse_sess : &mouse_dev->wheel_sess;
     123        usb_log_debug("%s: mouse_sess: %p\n",
     124            __FUNCTION__, mouse_dev->mouse_sess);
    133125
    134126        async_sess_t *sess =
    135127            async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
    136128        if (sess != NULL) {
    137                 if (*sess_ptr == NULL) {
    138                         *sess_ptr = sess;
     129                if (mouse_dev->mouse_sess == NULL) {
     130                        mouse_dev->mouse_sess = sess;
    139131                        usb_log_debug("Console session to %s set ok (%p).\n",
    140132                            fun->name, sess);
     
    144136                            fun->name);
    145137                        async_answer_0(icallid, ELIMIT);
     138                        async_hangup(sess);
    146139                }
    147140        } else {
     
    150143        }
    151144}
    152 
    153 /*----------------------------------------------------------------------------*/
    154 #if 0
    155 static void usb_mouse_send_wheel(const usb_mouse_t *mouse_dev, int wheel)
    156 {
    157         unsigned int key = (wheel > 0) ? KC_UP : KC_DOWN;
    158 
    159         if (mouse_dev->wheel_sess == NULL) {
    160                 usb_log_warning(
    161                     "Connection to console not ready, wheel roll discarded.\n");
    162                 return;
    163         }
    164 
    165         const unsigned count =
    166             ((wheel < 0) ? -wheel : wheel) * ARROWS_PER_SINGLE_WHEEL;
    167         for (unsigned i = 0; i < count; i++) {
    168                 /* Send arrow press and release. */
    169                 usb_log_debug2("Sending key %d to the console\n", key);
    170                
    171                 async_exch_t *exch = async_exchange_begin(mouse_dev->wheel_sess);
    172                
    173                 async_msg_4(exch, KBDEV_EVENT, KEY_PRESS, key, 0, 0);
    174                 async_msg_4(exch, KBDEV_EVENT, KEY_RELEASE, key, 0, 0);
    175                
    176                 async_exchange_end(exch);
    177         }
    178 }
    179 #endif
    180 /*----------------------------------------------------------------------------*/
    181 
     145/*----------------------------------------------------------------------------*/
    182146static int get_mouse_axis_move_value(uint8_t rid, usb_hid_report_t *report,
    183147    int32_t usage)
     
    203167        return result;
    204168}
    205 
     169/*----------------------------------------------------------------------------*/
    206170static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev,
    207171    usb_mouse_t *mouse_dev)
     
    230194                }
    231195        }
    232 #if 0
    233         if (wheel != 0)
    234                 (void)usb_mouse_send_wheel(mouse_dev, wheel);
    235 #endif
     196
    236197        /* Buttons */
    237198        usb_hid_report_path_t *path = usb_hid_report_path();
     
    342303        mouse->mouse_fun = fun;
    343304
    344         /*
    345          * Special function for acting as keyboard (wheel)
    346          */
    347         usb_log_debug("Creating DDF function %s...\n",
    348                       HID_MOUSE_WHEEL_FUN_NAME);
    349         fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,
    350             HID_MOUSE_WHEEL_FUN_NAME);
    351         if (fun == NULL) {
    352                 usb_log_error("Could not create DDF function node `%s'.\n",
    353                     HID_MOUSE_WHEEL_FUN_NAME);
    354                 FUN_UNBIND_DESTROY(mouse->mouse_fun);
    355                 mouse->mouse_fun = NULL;
    356                 return ENOMEM;
    357         }
    358 
    359         /*
    360          * Store the initialized HID device and HID ops
    361          * to the DDF function.
    362          */
    363         fun->ops = &mouse->ops;
    364         fun->driver_data = mouse;
    365 
    366         rc = ddf_fun_bind(fun);
    367         if (rc != EOK) {
    368                 usb_log_error("Could not bind DDF function `%s': %s.\n",
    369                     fun->name, str_error(rc));
    370                 FUN_UNBIND_DESTROY(mouse->mouse_fun);
    371                 mouse->mouse_fun = NULL;
    372 
    373                 fun->driver_data = NULL;
    374                 ddf_fun_destroy(fun);
    375                 return rc;
    376         }
    377 
    378         usb_log_debug("Adding DDF function to category %s...\n",
    379             HID_MOUSE_WHEEL_CATEGORY);
    380         rc = ddf_fun_add_to_category(fun, HID_MOUSE_WHEEL_CATEGORY);
    381         if (rc != EOK) {
    382                 usb_log_error(
    383                     "Could not add DDF function to category %s: %s.\n",
    384                     HID_MOUSE_WHEEL_CATEGORY, str_error(rc));
    385 
    386                 FUN_UNBIND_DESTROY(mouse->mouse_fun);
    387                 mouse->mouse_fun = NULL;
    388                 FUN_UNBIND_DESTROY(fun);
    389                 return rc;
    390         }
    391         mouse->wheel_fun = fun;
    392 
    393305        return EOK;
    394306}
    395 
    396 /*----------------------------------------------------------------------------*/
    397 
     307/*----------------------------------------------------------------------------*/
    398308/** Get highest index of a button mentioned in given report.
    399309 *
     
    517427        }
    518428
    519         if (mouse_dev->wheel_sess != NULL) {
    520                 const int ret = async_hangup(mouse_dev->wheel_sess);
    521                 if (ret != EOK)
    522                         usb_log_warning("Failed to hang up wheel session: "
    523                             "%p, %s.\n", mouse_dev->wheel_sess, str_error(ret));
    524         }
    525 
    526429        FUN_UNBIND_DESTROY(mouse_dev->mouse_fun);
    527         FUN_UNBIND_DESTROY(mouse_dev->wheel_fun);
    528430
    529431        free(mouse_dev->buttons);
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.h

    redb3cf2 r70172dc4  
    4848        /** IPC session to console (consumer). */
    4949        async_sess_t *mouse_sess;
    50         async_sess_t *wheel_sess;
    5150
    5251        /* Mouse buttons statuses. */
     
    5756        /* DDF mouse function */
    5857        ddf_fun_t *mouse_fun;
    59         /* DDF mouse function */
    60         ddf_fun_t *wheel_fun;
    6158} usb_mouse_t;
    6259
Note: See TracChangeset for help on using the changeset viewer.