Ignore:
Timestamp:
2011-09-16T21:13:57Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3a11f17
Parents:
c0e53ff (diff), fd07e526 (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 mainline changes

File:
1 edited

Legend:

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

    rc0e53ff r432a269  
    4242#include <errno.h>
    4343#include <async.h>
    44 #include <async_obsolete.h>
    4544#include <str_error.h>
    4645#include <ipc/mouseev.h>
     
    5655#define ARROWS_PER_SINGLE_WHEEL 3
    5756
    58 // FIXME: remove this header
    59 #include <abi/ipc/methods.h>
    60 
    61 #define NAME "mouse"
     57#define NAME  "mouse"
    6258
    6359/*----------------------------------------------------------------------------*/
     
    128124    ipc_callid_t icallid, ipc_call_t *icall)
    129125{
    130         sysarg_t method = IPC_GET_IMETHOD(*icall);
    131        
    132         usb_mouse_t *mouse_dev = (usb_mouse_t *)fun->driver_data;
     126        usb_mouse_t *mouse_dev = (usb_mouse_t *) fun->driver_data;
    133127       
    134128        if (mouse_dev == NULL) {
     
    141135        usb_log_debug("default_connection_handler: fun->name: %s\n",
    142136                      fun->name);
    143         usb_log_debug("default_connection_handler: mouse_phone: %d, wheel "
    144             "phone: %d\n", mouse_dev->mouse_phone, mouse_dev->wheel_phone);
    145        
    146         int *phone = (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0)
    147                      ? &mouse_dev->mouse_phone : &mouse_dev->wheel_phone;
    148        
    149         if (method == IPC_M_CONNECT_TO_ME) {
    150                 int callback = IPC_GET_ARG5(*icall);
    151 
    152                 if (*phone != -1) {
     137        usb_log_debug("default_connection_handler: mouse_sess: %p, "
     138            "wheel_sess: %p\n", mouse_dev->mouse_sess, mouse_dev->wheel_sess);
     139       
     140        async_sess_t **sess_ptr =
     141            (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0) ?
     142            &mouse_dev->mouse_sess : &mouse_dev->wheel_sess;
     143       
     144        async_sess_t *sess =
     145            async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
     146        if (sess != NULL) {
     147                if (*sess_ptr == NULL) {
     148                        *sess_ptr = sess;
     149                        usb_log_debug("Console session to mouse set ok (%p).\n",
     150                            sess);
     151                        async_answer_0(icallid, EOK);
     152                } else {
    153153                        usb_log_debug("default_connection_handler: Console "
    154                             "phone to mouse already set.\n");
     154                            "session to mouse already set.\n");
    155155                        async_answer_0(icallid, ELIMIT);
    156                         return;
    157156                }
    158 
    159                 *phone = callback;
    160                 usb_log_debug("Console phone to mouse set ok (%d).\n", *phone);
    161                 async_answer_0(icallid, EOK);
    162                 return;
    163         }
    164 
    165         usb_log_debug("default_connection_handler: Invalid function.\n");
    166         async_answer_0(icallid, EINVAL);
     157        } else {
     158                usb_log_debug("default_connection_handler: Invalid function.\n");
     159                async_answer_0(icallid, EINVAL);
     160        }
    167161}
    168162
     
    175169                return NULL;
    176170        }
    177         mouse->mouse_phone = -1;
    178         mouse->wheel_phone = -1;
     171        mouse->mouse_sess = NULL;
     172        mouse->wheel_sess = NULL;
    179173       
    180174        return mouse;
     
    187181        assert(mouse_dev != NULL);
    188182       
    189         // hangup phone to the console
    190         if (mouse_dev->mouse_phone >= 0) {
    191                 async_obsolete_hangup(mouse_dev->mouse_phone);
    192         }
    193        
    194         if (mouse_dev->wheel_phone >= 0) {
    195                 async_obsolete_hangup(mouse_dev->wheel_phone);
    196         }
     183        // hangup session to the console
     184        if (mouse_dev->mouse_sess != NULL)
     185                async_hangup(mouse_dev->mouse_sess);
     186       
     187        if (mouse_dev->wheel_sess != NULL)
     188                async_hangup(mouse_dev->wheel_sess);
    197189}
    198190
     
    203195        unsigned int key = (wheel > 0) ? KC_UP : KC_DOWN;
    204196
    205         if (mouse_dev->wheel_phone < 0) {
     197        if (mouse_dev->wheel_sess == NULL) {
    206198                usb_log_warning(
    207199                    "Connection to console not ready, wheel roll discarded.\n");
     
    215207                /* Send arrow press and release. */
    216208                usb_log_debug2("Sending key %d to the console\n", key);
    217                 async_obsolete_msg_4(mouse_dev->wheel_phone, KBDEV_EVENT,
    218                     KEY_PRESS, key, 0, 0);
    219                 async_obsolete_msg_4(mouse_dev->wheel_phone, KBDEV_EVENT,
    220                     KEY_RELEASE, key, 0, 0);
     209               
     210                async_exch_t *exch = async_exchange_begin(mouse_dev->wheel_sess);
     211               
     212                async_msg_4(exch, KBDEV_EVENT, KEY_PRESS, key, 0, 0);
     213                async_msg_4(exch, KBDEV_EVENT, KEY_RELEASE, key, 0, 0);
     214               
     215                async_exchange_end(exch);
    221216        }
    222217}
     
    253248        assert(mouse_dev != NULL);
    254249       
    255         if (mouse_dev->mouse_phone < 0) {
    256                 usb_log_warning(NAME " No console phone.\n");
     250        if (mouse_dev->mouse_sess == NULL) {
     251                usb_log_warning(NAME " No console session.\n");
    257252                return true;
    258253        }
     
    266261
    267262        if ((shift_x != 0) || (shift_y != 0)) {
    268                 async_obsolete_req_2_0(mouse_dev->mouse_phone,
    269                     MOUSEEV_MOVE_EVENT, shift_x, shift_y);
    270         }
    271 
    272         if (wheel != 0) {
     263                async_exch_t *exch = async_exchange_begin(mouse_dev->mouse_sess);
     264                async_req_2_0(exch, MOUSEEV_MOVE_EVENT, shift_x, shift_y);
     265                async_exchange_end(exch);
     266        }
     267       
     268        if (wheel != 0)
    273269                usb_mouse_send_wheel(mouse_dev, wheel);
    274         }
    275270       
    276271        /*
     
    292287                if (mouse_dev->buttons[field->usage - field->usage_minimum] == 0
    293288                    && field->value != 0) {
    294                         async_obsolete_req_2_0(mouse_dev->mouse_phone,
    295                             MOUSEEV_BUTTON_EVENT, field->usage, 1);
     289                        async_exch_t *exch =
     290                            async_exchange_begin(mouse_dev->mouse_sess);
     291                        async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, field->usage, 1);
     292                        async_exchange_end(exch);
     293                       
    296294                        mouse_dev->buttons[field->usage - field->usage_minimum]
    297295                            = field->value;
    298296                } else if (mouse_dev->buttons[field->usage - field->usage_minimum] != 0
    299297                    && field->value == 0) {
    300                         async_obsolete_req_2_0(mouse_dev->mouse_phone,
    301                            MOUSEEV_BUTTON_EVENT, field->usage, 0);
     298                        async_exch_t *exch =
     299                            async_exchange_begin(mouse_dev->mouse_sess);
     300                        async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, field->usage, 0);
     301                        async_exchange_end(exch);
     302                       
    302303                        mouse_dev->buttons[field->usage - field->usage_minimum] =
    303304                           field->value;
Note: See TracChangeset for help on using the changeset viewer.