Changeset 2b0db98 in mainline for uspace/drv/usbkbd/main.c


Ignore:
Timestamp:
2011-01-07T14:02:56Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6986418
Parents:
d99120f (diff), 0f191a2 (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:

Merged development into lelian/hidd

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbkbd/main.c

    rd99120f r2b0db98  
    2929#include <driver.h>
    3030#include <ipc/driver.h>
     31#include <ipc/kbd.h>
     32#include <io/keycode.h>
     33#include <io/console.h>
    3134#include <errno.h>
    3235#include <fibril.h>
     
    4245#define GUESSED_POLL_ENDPOINT 1
    4346
     47static void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *);
     48static device_ops_t keyboard_ops = {
     49        .default_handler = default_connection_handler
     50};
     51
     52static int console_callback_phone = -1;
     53
     54/** Default handler for IPC methods not handled by DDF.
     55 *
     56 * @param dev Device handling the call.
     57 * @param icallid Call id.
     58 * @param icall Call data.
     59 */
     60void default_connection_handler(device_t *dev,
     61    ipc_callid_t icallid, ipc_call_t *icall)
     62{
     63        sysarg_t method = IPC_GET_IMETHOD(*icall);
     64
     65        if (method == IPC_M_CONNECT_TO_ME) {
     66                int callback = IPC_GET_ARG5(*icall);
     67
     68                if (console_callback_phone != -1) {
     69                        ipc_answer_0(icallid, ELIMIT);
     70                        return;
     71                }
     72
     73                console_callback_phone = callback;
     74                ipc_answer_0(icallid, EOK);
     75                return;
     76        }
     77
     78        ipc_answer_0(icallid, EINVAL);
     79}
     80
     81static void send_key(int key, int type, wchar_t c) {
     82        async_msg_4(console_callback_phone, KBD_EVENT, type, key,
     83            KM_NUM_LOCK, c);
     84}
     85
     86static void send_alnum(int key, wchar_t c) {
     87        printf(NAME ": sending key '%lc' to console\n", (wint_t) c);
     88        send_key(key, KEY_PRESS, c);
     89        send_key(key, KEY_RELEASE, c);
     90}
     91
    4492/*
    4593 * Callbacks for parser
     
    119167        // get phone to my HC and save it as my parent's phone
    120168        // TODO: maybe not a good idea if DDF will use parent_phone
    121         kbd_dev->device->parent_phone = usb_drv_hc_connect(dev, 0);
     169        kbd_dev->device->parent_phone = usb_drv_hc_connect_auto(dev, 0);
    122170
    123171        kbd_dev->address = usb_drv_get_my_address(dev->parent_phone,
     
    160208        callbacks->keyboard = usbkbd_process_keycodes;
    161209
     210        if (console_callback_phone != -1) {
     211                static size_t counter = 0;
     212                counter++;
     213                if (counter > 3) {
     214                        counter = 0;
     215                        send_alnum(KC_A, L'a');
     216                }
     217        }
     218
    162219        usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks,
    163220            NULL);
     
    244301         * Not supported yet, skip..
    245302         */
    246 //      int phone = usb_drv_hc_connect(dev, 0);
     303//      int phone = usb_drv_hc_connect_auto(dev, 0);
    247304//      if (phone < 0) {
    248305//              /*
     
    265322        fibril_add_ready(fid);
    266323
     324        dev->ops = &keyboard_ops;
     325
     326        add_device_to_class(dev, "keyboard");
     327
    267328        /*
    268329         * Hurrah, device is initialized.
Note: See TracChangeset for help on using the changeset viewer.