Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5f7d96e in mainline for uspace/drv/usbkbd/main.c


Ignore:
Timestamp:
2010-12-27T18:18:03Z (11 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master
Children:
43c3937
Parents:
e080332 (diff), e84d65a (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 from development

File:
1 edited

Legend:

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

    re080332 r5f7d96e  
    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>
     
    4144#define GUESSED_POLL_ENDPOINT 1
    4245
     46static void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *);
     47static device_ops_t keyboard_ops = {
     48        .default_handler = default_connection_handler
     49};
     50
     51static int console_callback_phone = -1;
     52
     53/** Default handler for IPC methods not handled by DDF.
     54 *
     55 * @param dev Device handling the call.
     56 * @param icallid Call id.
     57 * @param icall Call data.
     58 */
     59void default_connection_handler(device_t *dev,
     60    ipc_callid_t icallid, ipc_call_t *icall)
     61{
     62        sysarg_t method = IPC_GET_IMETHOD(*icall);
     63
     64        if (method == IPC_M_CONNECT_TO_ME) {
     65                int callback = IPC_GET_ARG5(*icall);
     66
     67                if (console_callback_phone != -1) {
     68                        ipc_answer_0(icallid, ELIMIT);
     69                        return;
     70                }
     71
     72                console_callback_phone = callback;
     73                ipc_answer_0(icallid, EOK);
     74                return;
     75        }
     76
     77        ipc_answer_0(icallid, EINVAL);
     78}
     79
     80static void send_key(int key, int type, wchar_t c) {
     81        async_msg_4(console_callback_phone, KBD_EVENT, type, key,
     82            KM_NUM_LOCK, c);
     83}
     84
     85static void send_alnum(int key, wchar_t c) {
     86        printf(NAME ": sending key '%lc' to console\n", (wint_t) c);
     87        send_key(key, KEY_PRESS, c);
     88        send_key(key, KEY_RELEASE, c);
     89}
     90
    4391/*
    4492 * Callbacks for parser
     
    183231                sizeof(usb_hid_report_in_callbacks_t));
    184232        callbacks->keyboard = usbkbd_process_keycodes;
     233
     234        if (console_callback_phone != -1) {
     235                static size_t counter = 0;
     236                counter++;
     237                if (counter > 3) {
     238                        counter = 0;
     239                        send_alnum(KC_A, L'a');
     240                }
     241        }
    185242
    186243        usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks,
     
    289346        fibril_add_ready(fid);
    290347
     348        dev->ops = &keyboard_ops;
     349
     350        add_device_to_class(dev, "keyboard");
     351
    291352        /*
    292353         * Hurrah, device is initialized.
Note: See TracChangeset for help on using the changeset viewer.