Changeset 93fb170c in mainline for uspace/drv/usbkbd/main.c
- Timestamp:
- 2011-01-08T18:51:31Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 15be932
- Parents:
- 8f748215 (diff), a523af4 (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
r8f748215 r93fb170c 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> … … 41 44 #define GUESSED_POLL_ENDPOINT 1 42 45 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", (wint_t) c); 87 send_key(key, KEY_PRESS, c); 88 send_key(key, KEY_RELEASE, c); 89 } 90 43 91 /* 44 92 * Callbacks for parser … … 142 190 // get phone to my HC and save it as my parent's phone 143 191 // TODO: maybe not a good idea if DDF will use parent_phone 144 kbd_dev->device->parent_phone = usb_drv_hc_connect (dev, 0);192 kbd_dev->device->parent_phone = usb_drv_hc_connect_auto(dev, 0); 145 193 146 194 kbd_dev->address = usb_drv_get_my_address(dev->parent_phone, … … 183 231 sizeof(usb_hid_report_in_callbacks_t)); 184 232 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 } 185 242 186 243 usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks, … … 268 325 * Not supported yet, skip.. 269 326 */ 270 // int phone = usb_drv_hc_connect (dev, 0);327 // int phone = usb_drv_hc_connect_auto(dev, 0); 271 328 // if (phone < 0) { 272 329 // /* … … 289 346 fibril_add_ready(fid); 290 347 348 dev->ops = &keyboard_ops; 349 350 add_device_to_class(dev, "keyboard"); 351 291 352 /* 292 353 * Hurrah, device is initialized.
Note:
See TracChangeset
for help on using the changeset viewer.