Changeset 2b0db98 in mainline for uspace/drv/usbkbd/main.c
- Timestamp:
- 2011-01-07T14:02:56Z (14 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbkbd/main.c
rd99120f r2b0db98 29 29 #include <driver.h> 30 30 #include <ipc/driver.h> 31 #include <ipc/kbd.h> 32 #include <io/keycode.h> 33 #include <io/console.h> 31 34 #include <errno.h> 32 35 #include <fibril.h> … … 42 45 #define GUESSED_POLL_ENDPOINT 1 43 46 47 static void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *); 48 static device_ops_t keyboard_ops = { 49 .default_handler = default_connection_handler 50 }; 51 52 static 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 */ 60 void 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 81 static 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 86 static 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 44 92 /* 45 93 * Callbacks for parser … … 119 167 // get phone to my HC and save it as my parent's phone 120 168 // 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); 122 170 123 171 kbd_dev->address = usb_drv_get_my_address(dev->parent_phone, … … 160 208 callbacks->keyboard = usbkbd_process_keycodes; 161 209 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 162 219 usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks, 163 220 NULL); … … 244 301 * Not supported yet, skip.. 245 302 */ 246 // int phone = usb_drv_hc_connect (dev, 0);303 // int phone = usb_drv_hc_connect_auto(dev, 0); 247 304 // if (phone < 0) { 248 305 // /* … … 265 322 fibril_add_ready(fid); 266 323 324 dev->ops = &keyboard_ops; 325 326 add_device_to_class(dev, "keyboard"); 327 267 328 /* 268 329 * Hurrah, device is initialized.
Note:
See TracChangeset
for help on using the changeset viewer.