Changeset 21bb58d in mainline for uspace/drv/usbmouse/init.c


Ignore:
Timestamp:
2011-03-02T20:20:42Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
24aa62c, 5dd9209
Parents:
103ae7f8
Message:

USB mouse sends events to console

The values are not properly scaled, the clicking is very simple
(doubt that the console is able to handle something more
complicated) but it is possible to switch consoles with the mouse.

Tested in QEMU only.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbmouse/init.c

    r103ae7f8 r21bb58d  
    100100}
    101101
     102static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
     103static ddf_dev_ops_t mouse_ops = {
     104        .default_handler = default_connection_handler
     105};
     106
     107/** Default handler for IPC methods not handled by DDF.
     108 *
     109 * @param dev Device handling the call.
     110 * @param icallid Call id.
     111 * @param icall Call data.
     112 */
     113void default_connection_handler(ddf_fun_t *fun,
     114    ipc_callid_t icallid, ipc_call_t *icall)
     115{
     116        sysarg_t method = IPC_GET_IMETHOD(*icall);
     117
     118        usb_mouse_t *mouse = (usb_mouse_t *) fun->driver_data;
     119        assert(mouse != NULL);
     120
     121        if (method == IPC_M_CONNECT_TO_ME) {
     122                int callback = IPC_GET_ARG5(*icall);
     123
     124                if (mouse->console_phone != -1) {
     125                        async_answer_0(icallid, ELIMIT);
     126                        return;
     127                }
     128
     129                mouse->console_phone = callback;
     130                async_answer_0(icallid, EOK);
     131                return;
     132        }
     133
     134        async_answer_0(icallid, EINVAL);
     135}
     136
    102137
    103138int usb_mouse_create(ddf_dev_t *dev)
     
    108143        }
    109144        mouse->device = dev;
     145        mouse->console_phone = -1;
    110146
    111147        int rc;
     
    144180                goto leave;
    145181        }
     182
     183        mouse->mouse_fun->ops = &mouse_ops;
     184
    146185        rc = ddf_fun_bind(mouse->mouse_fun);
    147186        if (rc != EOK) {
     
    157196        /* Everything allright. */
    158197        dev->driver_data = mouse;
     198        mouse->mouse_fun->driver_data = mouse;
    159199
    160200        return EOK;
Note: See TracChangeset for help on using the changeset viewer.