Ignore:
File:
1 edited

Legend:

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

    r700af62 rf9a0cef  
    2929#include <driver.h>
    3030#include <ipc/driver.h>
    31 #include <ipc/kbd.h>
    32 #include <io/keycode.h>
    33 #include <io/console.h>
    3431#include <errno.h>
    3532#include <fibril.h>
     
    4441#define GUESSED_POLL_ENDPOINT 1
    4542
    46 static void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *);
    47 static device_ops_t keyboard_ops = {
    48         .default_handler = default_connection_handler
    49 };
    50 
    51 static 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  */
    59 void 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 
    80 static 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 
    85 static void send_alnum(int key, wchar_t c) {
    86         printf(NAME ": sending key '%lc' to console\n", c);
    87         send_key(key, KEY_PRESS, c);
    88         send_key(key, KEY_RELEASE, c);
    89 }
    90 
    9143/*
    9244 * Callbacks for parser
     
    231183                sizeof(usb_hid_report_in_callbacks_t));
    232184        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         }
    242185
    243186        usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks,
     
    346289        fibril_add_ready(fid);
    347290
    348         dev->ops = &keyboard_ops;
    349 
    350         add_device_to_class(dev, "keyboard");
    351 
    352291        /*
    353292         * Hurrah, device is initialized.
Note: See TracChangeset for help on using the changeset viewer.