Changeset 91db50ac in mainline for uspace/drv/usbkbd/main.c
- Timestamp:
- 2010-11-19T21:50:46Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7034be15
- Parents:
- 63b4f90
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbkbd/main.c
r63b4f90 r91db50ac 30 30 #include <errno.h> 31 31 32 #define BUFFER_SIZE 32 33 34 /* Call this periodically to check keyboard status changes. */ 35 static void poll_keyboard(device_t *dev) 36 { 37 int rc; 38 usb_handle_t handle; 39 char buffer[BUFFER_SIZE]; 40 size_t actual_size; 41 usb_endpoint_t poll_endpoint = 1; 42 43 rc = usb_drv_async_interrupt_in(dev->parent_phone, poll_endpoint, 44 buffer, BUFFER_SIZE, &actual_size, &handle); 45 if (rc != EOK) { 46 return; 47 } 48 49 rc = usb_drv_async_wait_for(handle); 50 if (rc != EOK) { 51 return; 52 } 53 54 /* 55 * If the keyboard answered with NAK, it returned no data. 56 * This implies that no change happened since last query. 57 */ 58 if (actual_size == 0) { 59 return; 60 } 61 62 /* 63 * Process pressed keys. 64 */ 65 } 66 32 67 static int add_kbd_device(device_t *dev) 33 68 { … … 38 73 * When everything is okay, connect to "our" HC. 39 74 */ 40 int rc= usb_drv_hc_connect(dev, 0);41 if ( rc != EOK) {75 int phone = usb_drv_hc_connect(dev, 0); 76 if (phone < 0) { 42 77 /* 43 78 * Connecting to HC failed, roll-back and announce 44 79 * failure. 45 80 */ 46 return rc;81 return phone; 47 82 } 83 84 dev->parent_phone = phone; 85 86 /* 87 * Just for fun ;-). 88 */ 89 poll_keyboard(dev); 48 90 49 91 /*
Note:
See TracChangeset
for help on using the changeset viewer.