Changeset 101ef25c in mainline for uspace/drv/usbkbd/main.c
- Timestamp:
- 2010-12-10T17:02:22Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 243cb86
- Parents:
- 70c85211
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbkbd/main.c
r70c85211 r101ef25c 50 50 kbd_dev->device = dev; 51 51 52 // get phone to my HC and save it as my parent's phone 53 // TODO: maybe not a good idea if DDF will use parent_phone 54 kbd_dev->device->parent_phone = usb_drv_hc_connect(dev, 0); 55 52 56 kbd_dev->address = usb_drv_get_my_address(dev->parent_phone, 53 57 dev); 54 58 55 if (kbd_dev->address < 0) { 56 fprintf(stderr, NAME ": No device address!\n"); 57 free(kbd_dev); 58 return NULL; 59 } 59 // doesn't matter now that we have no address 60 // if (kbd_dev->address < 0) { 61 // fprintf(stderr, NAME ": No device address!\n"); 62 // free(kbd_dev); 63 // return NULL; 64 // } 60 65 61 66 // default endpoint … … 69 74 } 70 75 71 /* Call this periodically to check keyboard status changes. */ 76 static void usbkbd_process_interrupt_in(usb_hid_dev_kbd_t *kbd_dev, 77 char *buffer, size_t actual_size) 78 { 79 /* 80 * here, the parser will be called, probably with some callbacks 81 * now only take last 6 bytes and process, i.e. send to kbd 82 */ 83 } 84 72 85 static void usbkbd_poll_keyboard(usb_hid_dev_kbd_t *kbd_dev) 73 86 { … … 89 102 }; 90 103 91 rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone, 92 poll_target, buffer, BUFFER_SIZE, &actual_size, &handle); 93 94 if (rc != EOK) { 95 return; 96 } 97 98 rc = usb_drv_async_wait_for(handle); 99 if (rc != EOK) { 100 return; 101 } 102 103 /* 104 * If the keyboard answered with NAK, it returned no data. 105 * This implies that no change happened since last query. 106 */ 107 if (actual_size == 0) { 108 return; 109 } 110 111 /* 112 * TODO: Process pressed keys. 113 */ 104 while (true) { 105 rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone, 106 poll_target, buffer, BUFFER_SIZE, &actual_size, &handle); 107 108 if (rc != EOK) { 109 continue; 110 } 111 112 rc = usb_drv_async_wait_for(handle); 113 if (rc != EOK) { 114 continue; 115 } 116 117 /* 118 * If the keyboard answered with NAK, it returned no data. 119 * This implies that no change happened since last query. 120 */ 121 if (actual_size == 0) { 122 continue; 123 } 124 125 /* 126 * TODO: Process pressed keys. 127 */ 128 usbkbd_process_interrupt_in(kbd_dev, buffer, actual_size); 129 } 130 131 // not reached 132 assert(0); 114 133 } 115 134 … … 136 155 { 137 156 /* For now, fail immediately. */ 138 return ENOTSUP;157 //return ENOTSUP; 139 158 140 159 /*
Note:
See TracChangeset
for help on using the changeset viewer.