Changeset 21bb58d in mainline


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.

Location:
uspace/drv/usbmouse
Files:
3 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;
  • uspace/drv/usbmouse/mouse.c

    r103ae7f8 r21bb58d  
    3737#include <usb/debug.h>
    3838#include <errno.h>
     39#include <ipc/mouse.h>
    3940
    4041int usb_mouse_polling_fibril(void *arg)
     
    9495                }
    9596
     97                if (mouse->console_phone >= 0) {
     98                        if ((shift_x != 0) || (shift_y != 0)) {
     99                                /* FIXME: guessed for QEMU */
     100                                async_req_2_0(mouse->console_phone,
     101                                    MEVENT_MOVE,
     102                                    - shift_x / 10,  - shift_y / 10);
     103                        }
     104                        if (butt) {
     105                                /* FIXME: proper button clicking. */
     106                                async_req_2_0(mouse->console_phone,
     107                                    MEVENT_BUTTON, 1, 1);
     108                                async_req_2_0(mouse->console_phone,
     109                                    MEVENT_BUTTON, 1, 0);
     110                        }
     111                }
     112
    96113                usb_log_debug("buttons=%s  dX=%+3d  dY=%+3d  wheel=%+3d\n",
    97114                   str_buttons, shift_x, shift_y, wheel);
  • uspace/drv/usbmouse/mouse.h

    r103ae7f8 r21bb58d  
    5050        usb_endpoint_pipe_t poll_pipe;
    5151        suseconds_t poll_interval_us;
     52        int console_phone;
    5253} usb_mouse_t;
    5354
Note: See TracChangeset for help on using the changeset viewer.