Changes in uspace/drv/usbkbd/main.c [6986418:38c5dfa] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbkbd/main.c
r6986418 r38c5dfa 38 38 #include <usb/devreq.h> 39 39 #include <usb/descriptor.h> 40 #include "descparser.h"41 40 42 41 #define BUFFER_SIZE 32 … … 79 78 } 80 79 80 #if 0 81 81 static void send_key(int key, int type, wchar_t c) { 82 82 async_msg_4(console_callback_phone, KBD_EVENT, type, key, 83 83 KM_NUM_LOCK, c); 84 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 } 85 #endif 91 86 92 87 /* … … 96 91 void *arg) 97 92 { 98 printf("Got keys: "); 99 unsigned i; 100 for (i = 0; i < count; ++i) { 101 printf("%d ", key_codes[i]); 102 } 103 printf("\n"); 93 104 94 } 105 95 … … 107 97 * Kbd functions 108 98 */ 109 static int usbkbd_get_report_descriptor(usb_hid_dev_kbd_t *kbd_dev) 110 { 111 // iterate over all configurations and interfaces 112 // TODO: more configurations!! 113 unsigned i; 114 for (i = 0; i < kbd_dev->conf->config_descriptor.interface_count; ++i) { 115 uint8_t type = 116 kbd_dev->conf->interfaces[i].hid_desc.report_desc_info.type; 117 // TODO: endianness 118 uint16_t length = 119 kbd_dev->conf->interfaces[i].hid_desc.report_desc_info.length; 120 121 // allocate space for the report descriptor 122 kbd_dev->conf->interfaces[i].report_desc = (uint8_t *)malloc(length); 123 // get the descriptor from the device 124 125 } 126 } 127 128 static int usbkbd_process_descriptors(usb_hid_dev_kbd_t *kbd_dev) 129 { 130 // get the first configuration descriptor (TODO: parse also other!) 99 static int usbkbd_parse_descriptors(usb_hid_dev_kbd_t *kbd_dev, 100 const uint8_t *data, size_t size) 101 { 102 // const uint8_t *pos = data; 103 104 // // get the configuration descriptor (should be first) 105 // if (*pos != sizeof(usb_standard_configuration_descriptor_t) 106 // || *(pos + 1) != USB_DESCTYPE_CONFIGURATION) { 107 // fprintf(stderr, "Wrong format of configuration descriptor"); 108 // return EINVAL; 109 // } 110 111 // usb_standard_configuration_descriptor_t config_descriptor; 112 // memcpy(&config_descriptor, pos, 113 // sizeof(usb_standard_configuration_descriptor_t)); 114 // pos += sizeof(usb_standard_configuration_descriptor_t); 115 116 // // parse other descriptors 117 // while (pos - data < size) { 118 // //uint8_t desc_size = *pos; 119 // uint8_t desc_type = *(pos + 1); 120 // switch (desc_type) { 121 // case USB_DESCTYPE_INTERFACE: 122 // break; 123 // case USB_DESCTYPE_ENDPOINT: 124 // break; 125 // case USB_DESCTYPE_HID: 126 // break; 127 // case USB_DESCTYPE_HID_REPORT: 128 // break; 129 // case USB_DESCTYPE_HID_PHYSICAL: 130 // break; 131 // } 132 // } 133 134 return EOK; 135 } 136 137 static int usbkbd_get_descriptors(usb_hid_dev_kbd_t *kbd_dev) 138 { 139 // get the first configuration descriptor (TODO: or some other??) 131 140 usb_standard_configuration_descriptor_t config_desc; 132 141 … … 157 166 } 158 167 159 kbd_dev->conf = (usb_hid_configuration_t *)calloc(1, 160 sizeof(usb_hid_configuration_t)); 161 if (kbd_dev->conf == NULL) { 162 free(descriptors); 163 return ENOMEM; 164 } 165 166 rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf); 168 rc = usbkbd_parse_descriptors(kbd_dev, descriptors, transferred); 167 169 free(descriptors); 168 169 // get and report descriptors170 rc = usbkbd_get_report_descriptor(kbd_dev);171 172 usbkbd_print_config(kbd_dev->conf);173 170 174 171 return rc; … … 177 174 static usb_hid_dev_kbd_t *usbkbd_init_device(device_t *dev) 178 175 { 179 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *) calloc(1,180 176 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)malloc( 177 sizeof(usb_hid_dev_kbd_t)); 181 178 182 179 if (kbd_dev == NULL) { … … 211 208 */ 212 209 213 // TODO: get descriptors, parse descriptors and save endpoints 214 usbkbd_process_descriptors(kbd_dev); 210 // TODO: get descriptors 211 usbkbd_get_descriptors(kbd_dev); 212 // TODO: parse descriptors and save endpoints 215 213 216 214 return kbd_dev; … … 230 228 callbacks->keyboard = usbkbd_process_keycodes; 231 229 232 if (console_callback_phone != -1) {233 static size_t counter = 0;234 counter++;235 if (counter > 3) {236 counter = 0;237 send_alnum(KC_A, L'a');238 }239 }240 241 230 usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks, 242 231 NULL); … … 245 234 static void usbkbd_poll_keyboard(usb_hid_dev_kbd_t *kbd_dev) 246 235 { 247 return;248 249 236 int rc; 250 237 usb_handle_t handle;
Note:
See TracChangeset
for help on using the changeset viewer.